Skip to content

Commit 530c233

Browse files
committed
---
yaml --- r: 5503 b: refs/heads/master c: 0c4e0fd h: refs/heads/master i: 5501: 354dac2 5499: 13ba8b7 5495: 36ba25e 5487: f96a61a 5471: 7effc77 5439: 1dab41c 5375: 4883ddc v: v3
1 parent 7536606 commit 530c233

File tree

6 files changed

+53
-29
lines changed

6 files changed

+53
-29
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 6164de90e2277aac21f85894acf79ed0561cd3ae
2+
refs/heads/master: 0c4e0fdfae2fad4a132bdfef3cb856ec5dde84c9

trunk/src/rt/rust_cc.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ irc::compute_ircs(rust_task *task, irc_map &ircs) {
169169
begin(task->local_allocs.begin()), end(task->local_allocs.end());
170170
while (begin != end) {
171171
uint8_t *p = reinterpret_cast<uint8_t *>(begin->first);
172-
p += sizeof(uintptr_t); // Skip over the reference count.
173172

174173
const type_desc *tydesc = begin->second;
175174

@@ -178,9 +177,9 @@ irc::compute_ircs(rust_task *task, irc_map &ircs) {
178177

179178
shape::arena arena;
180179
shape::type_param *params =
181-
shape::type_param::from_tydesc(&tydesc, arena);
182-
irc irc(task, true, tydesc->shape, params, tydesc->shape_tables, p,
183-
ircs);
180+
shape::type_param::from_tydesc_and_data(tydesc, p, arena);
181+
irc irc(task, true, tydesc->shape, params, tydesc->shape_tables,
182+
p + sizeof(uintptr_t), ircs);
184183
irc.walk();
185184

186185
#if 0
@@ -374,26 +373,25 @@ mark::do_mark(rust_task *task, const std::vector<void *> &roots,
374373
if (marked.find(alloc) == marked.end()) {
375374
marked.insert(alloc);
376375

377-
uint8_t *p = reinterpret_cast<uint8_t *>(alloc);
378-
p += sizeof(uintptr_t); // Skip over the reference count.
379-
380-
const type_desc *tydesc = task->local_allocs[*begin];
376+
const type_desc *tydesc = task->local_allocs[alloc];
381377

382378
//DPRINT("marking: %p, tydesc=%p\n", p, tydesc);
383379

380+
uint8_t *p = reinterpret_cast<uint8_t *>(alloc);
384381
shape::arena arena;
385382
shape::type_param *params =
386-
shape::type_param::from_tydesc(&tydesc, arena);
383+
shape::type_param::from_tydesc_and_data(tydesc, p, arena);
387384

388-
#if 0
385+
// We skip over the reference count here.
389386
shape::log log(task, true, tydesc->shape, params,
390-
tydesc->shape_tables, p, std::cerr);
387+
tydesc->shape_tables, p + sizeof(uintptr_t),
388+
std::cerr);
391389
log.walk();
392390
DPRINT("\n");
393-
#endif
394391

392+
// We skip over the reference count here.
395393
mark mark(task, true, tydesc->shape, params, tydesc->shape_tables,
396-
p, marked);
394+
p + sizeof(uintptr_t), marked);
397395
mark.walk();
398396
}
399397

trunk/src/rt/rust_gc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ gc::mark(std::vector<root> &roots) {
105105

106106
shape::arena arena;
107107
shape::type_param *params =
108-
shape::type_param::from_tydesc(&ri->tydesc, arena);
108+
shape::type_param::from_tydesc_and_data(ri->tydesc, ri->data,
109+
arena);
109110
shape::log log(task, true, ri->tydesc->shape, params,
110111
ri->tydesc->shape_tables, ri->data, std::cerr);
111112
log.walk();

trunk/src/rt/rust_obstack.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,13 @@ rust_obstack::dump() const {
160160
iterator b = begin(), e = end();
161161
while (b != e) {
162162
std::pair<const type_desc *,void *> data = *b;
163+
uint8_t *dp = reinterpret_cast<uint8_t *>(data.second);
164+
163165
shape::arena arena;
164166
shape::type_param *params =
165-
shape::type_param::from_tydesc(&data.first, arena);
167+
shape::type_param::from_tydesc_and_data(data.first, dp, arena);
166168
shape::log log(task, true, data.first->shape, params,
167-
data.first->shape_tables,
168-
reinterpret_cast<uint8_t *>(data.second), std::cerr);
169+
data.first->shape_tables, dp, std::cerr);
169170
log.walk();
170171
std::cerr << "\n";
171172

trunk/src/rt/rust_shape.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ type_param::make(const type_desc **tydescs, unsigned n_tydescs,
3737
const type_desc *subtydesc = tydescs[i];
3838
ptrs[i].shape = subtydesc->shape;
3939
ptrs[i].tables = subtydesc->shape_tables;
40-
ptrs[i].params = from_tydesc(&subtydesc, arena);
40+
41+
// FIXME: Doesn't handle a type-parametric object closing over a
42+
// type-parametric object type properly.
43+
ptrs[i].params = from_tydesc(subtydesc, arena);
4144
}
4245
return ptrs;
4346
}
@@ -531,8 +534,12 @@ upcall_cmp_type(int8_t *result, rust_task *task, const type_desc *tydesc,
531534
const type_desc **subtydescs, uint8_t *data_0,
532535
uint8_t *data_1, uint8_t cmp_type) {
533536
shape::arena arena;
537+
538+
// FIXME: This may well be broken when comparing two closures or objects
539+
// that close over different sets of type parameters.
534540
shape::type_param *params =
535-
shape::type_param::from_tydesc(&tydesc, arena);
541+
shape::type_param::from_tydesc_and_data(tydesc, data_0, arena);
542+
536543
shape::cmp cmp(task, true, tydesc->shape, params, tydesc->shape_tables,
537544
data_0, data_1);
538545
cmp.walk();
@@ -552,7 +559,7 @@ upcall_log_type(rust_task *task, const type_desc *tydesc, uint8_t *data,
552559

553560
shape::arena arena;
554561
shape::type_param *params =
555-
shape::type_param::from_tydesc(&tydesc, arena);
562+
shape::type_param::from_tydesc_and_data(tydesc, data, arena);
556563

557564
std::stringstream ss;
558565
shape::log log(task, true, tydesc->shape, params, tydesc->shape_tables,

trunk/src/rt/rust_shape.h

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,27 +310,44 @@ class type_param {
310310
}
311311

312312
// Creates type parameters from a type descriptor.
313-
static inline type_param *from_tydesc(const type_desc **tydesc,
313+
static inline type_param *from_tydesc(const type_desc *tydesc,
314314
arena &arena) {
315-
if ((*tydesc)->n_obj_params) {
316-
uintptr_t n_obj_params = (*tydesc)->n_obj_params;
315+
// In order to find the type parameters of objects and functions, we
316+
// have to actually have the data pointer, since we don't statically
317+
// know from the type of an object or function which type parameters
318+
// it closes over.
319+
assert(!tydesc->n_obj_params && "Type-parametric objects and "
320+
"functions must go through from_tydesc_and_data() instead!");
321+
322+
return make(tydesc->first_param, tydesc->n_params, arena);
323+
}
324+
325+
static type_param *from_tydesc_and_data(const type_desc *tydesc,
326+
uint8_t *dp, arena &arena) {
327+
if (tydesc->n_obj_params) {
328+
uintptr_t n_obj_params = tydesc->n_obj_params;
317329
const type_desc **first_param;
318330
if (n_obj_params & 0x80000000) {
319331
// Function closure.
320332
DPRINT("n_obj_params FN %lu, tydesc %p, starting at %p\n",
321-
(unsigned long)n_obj_params, tydesc, tydesc + 4);
333+
(unsigned long)n_obj_params, tydesc,
334+
dp + sizeof(uintptr_t) + tydesc->size);
322335
n_obj_params &= 0x7fffffff;
336+
// FIXME: Is this right?
323337
first_param = (const type_desc **)
324-
((uint8_t *)(tydesc + 4) + (*tydesc)->size);
338+
(dp + sizeof(uintptr_t) + tydesc->size);
325339
} else {
326340
// Object closure.
327341
DPRINT("n_obj_params OBJ %lu, tydesc %p, starting at %p\n",
328-
(unsigned long)n_obj_params, tydesc, tydesc + 4);
329-
first_param = tydesc + 4;
342+
(unsigned long)n_obj_params, tydesc,
343+
dp + sizeof(uintptr_t) * 2);
344+
first_param = (const type_desc **)
345+
(dp + sizeof(uintptr_t) * 2);
330346
}
347+
return make(first_param, n_obj_params, arena);
331348
}
332349

333-
return make((*tydesc)->first_param, (*tydesc)->n_params, arena);
350+
return make(tydesc->first_param, tydesc->n_params, arena);
334351
}
335352
};
336353

0 commit comments

Comments
 (0)