Skip to content

Commit

Permalink
get rid of offset, bring "should have gen2" out of loop, batch to 1024
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Apr 3, 2016
1 parent 217b0ff commit 68238b6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
16 changes: 12 additions & 4 deletions src/6model/reprs/MVMArray.c
Expand Up @@ -57,8 +57,12 @@ static void gc_mark(MVMThreadContext *tc, MVMSTable *st, void *data, MVMGCWorkli
case MVM_ARRAY_OBJ: {
MVMObject **slots = body->slots.o;
slots += start;
if (elems > 256) {
MVM_gc_worklist_add_vector(tc, worklist, &slots[0], elems, (char *)&slots[1] - (char *)&slots[0]);
if (elems > 1024) {
MVMuint32 start;
for (start = 0; start < elems; start += 1024) {
MVM_gc_worklist_add_vector(tc, worklist, &slots[start], elems - start > 1024 ? 1024 : elems - start);
}
/*MVM_gc_worklist_add_vector(tc, worklist, &slots[0], elems);*/
} else {
while (i < elems) {
MVM_gc_worklist_add(tc, worklist, &slots[i]);
Expand All @@ -70,8 +74,12 @@ static void gc_mark(MVMThreadContext *tc, MVMSTable *st, void *data, MVMGCWorkli
case MVM_ARRAY_STR: {
MVMString **slots = body->slots.s;
slots += start;
if (elems > 256) {
MVM_gc_worklist_add_vector(tc, worklist, (MVMCollectable **)&slots[0], elems, (char *)&slots[1] - (char *)&slots[0]);
if (elems > 1024) {
MVMuint32 start;
for (start = 0; start < elems; start += 1024) {
MVM_gc_worklist_add_vector(tc, worklist, &slots[start], elems - start > 1024 ? 1024 : elems - start);
}
/*MVM_gc_worklist_add_vector(tc, worklist, &slots[0], elems);*/
} else {
while (i < elems) {
MVM_gc_worklist_add(tc, worklist, &slots[i]);
Expand Down
23 changes: 19 additions & 4 deletions src/gc/worklist.c
Expand Up @@ -33,8 +33,10 @@ void MVM_gc_worklist_add_frame_slow(MVMThreadContext *tc, MVMGCWorklist *worklis
}

/* Adds a lot of items to the worklist that are laid out consecutively in memory, expanding it if needed. */
void MVM_gc_worklist_add_vector(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMCollectable **firstitem, MVMuint32 count, MVMuint32 offset) {
void MVM_gc_worklist_add_vector(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMCollectable **firstitem, MVMuint32 count) {
MVMint32 index = 0;

/*MVMuint32 beginning_item = worklist->items;*/
while (worklist->items + count > worklist->alloc) {
index = 1;
worklist->alloc *= 2;
Expand All @@ -43,10 +45,23 @@ void MVM_gc_worklist_add_vector(MVMThreadContext *tc, MVMGCWorklist *worklist, M
worklist->list = MVM_realloc(worklist->list, worklist->alloc * sizeof(MVMCollectable **));
}

for (index = 0; index < count; index++) {
worklist->list[worklist->items++] = firstitem;
firstitem = (MVMCollectable **)((char *)firstitem + offset);
if (worklist->include_gen2) {
for (index = 0; index < count; index++) {
if (*firstitem) {
worklist->list[worklist->items++] = firstitem;
}
firstitem++;
}
} else {
for (index = 0; index < count; index++) {
if (*firstitem && !((*firstitem)->flags & MVM_CF_SECOND_GEN)) {
worklist->list[worklist->items++] = firstitem;
}
firstitem++;
}
}
/*fprintf(stderr, "items went from %d to %d for %d count (should be %d)\n",*/
/*beginning_item, worklist->items, count, beginning_item + count);*/
}

/* Pre-sizes the worklist in expectation a certain number of items is about to be
Expand Down
2 changes: 1 addition & 1 deletion src/gc/worklist.h
Expand Up @@ -94,7 +94,7 @@ struct MVMGCWorklist {
MVMGCWorklist * MVM_gc_worklist_create(MVMThreadContext *tc, MVMuint8 include_gen2, MVMuint8 always_frames);
MVM_PUBLIC void MVM_gc_worklist_add_slow(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMCollectable **item);
MVM_PUBLIC void MVM_gc_worklist_add_frame_slow(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMFrame *frame);
MVM_PUBLIC void MVM_gc_worklist_add_vector(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMCollectable **first, MVMuint32 count, MVMuint32 offset);
MVM_PUBLIC void MVM_gc_worklist_add_vector(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMCollectable **first, MVMuint32 count);
void MVM_gc_worklist_presize_for(MVMThreadContext *tc, MVMGCWorklist *worklist, MVMint32 items);
void MVM_gc_worklist_destroy(MVMThreadContext *tc, MVMGCWorklist *worklist);
void MVM_gc_worklist_mark_frame_roots(MVMThreadContext *tc, MVMGCWorklist *worklist);
Expand Down

0 comments on commit 68238b6

Please sign in to comment.