Skip to content

Commit

Permalink
describe_refs in MVMArray
Browse files Browse the repository at this point in the history
i wasn't able to see if it works, actually ...
  • Loading branch information
timo authored and jnthn committed Apr 6, 2016
1 parent 2c415d5 commit 0b95607
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/6model/reprs/MVMArray.c
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,37 @@ static MVMuint64 unmanaged_size(MVMThreadContext *tc, MVMSTable *st, void *data)
return body->ssize * repr_data->elem_size;
}

static void describe_refs (MVMThreadContext *tc, MVMHeapSnapshotState *ss, MVMSTable *st, void *data) {
MVMArrayREPRData *repr_data = (MVMArrayREPRData *) st->REPR_data;
MVMArrayBody *body = (MVMArrayBody *)data;
MVMuint64 elems = body->elems;
MVMuint64 start = body->start;
MVMuint64 i = 0;

switch (repr_data->slot_type) {
case MVM_ARRAY_OBJ: {
MVMObject **slots = body->slots.o;
slots += start;
while (i < elems) {
MVM_profile_heap_add_collectable_rel_idx(tc, ss,
(MVMCollectable *)slots[i], i);
i++;
}
break;
}
case MVM_ARRAY_STR: {
MVMString **slots = body->slots.s;
slots += start;
while (i < elems) {
MVM_profile_heap_add_collectable_rel_idx(tc, ss,
(MVMCollectable *)slots[i], i);
i++;
}
break;
}
}
}

/* Initializes the representation. */
const MVMREPROps * MVMArray_initialize(MVMThreadContext *tc) {
return &this_repr;
Expand Down Expand Up @@ -1248,5 +1279,5 @@ static const MVMREPROps this_repr = {
MVM_REPR_ID_MVMArray,
0, /* refs_frames */
unmanaged_size,
NULL, /* describe_refs */
describe_refs,
};

0 comments on commit 0b95607

Please sign in to comment.