Skip to content

Commit

Permalink
Fix gen2roots compaction optimization bug.
Browse files Browse the repository at this point in the history
The optimization found the first non-survivor, but then set i = 0 and
so started looking from the start of the list again.
  • Loading branch information
jnthn committed Mar 25, 2014
1 parent d9db2e3 commit 0629b9a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/gc/roots.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,17 +252,20 @@ void MVM_gc_root_gen2_cleanup(MVMThreadContext *tc) {
MVMuint32 i = 0;
MVMuint32 cur_survivor;

/* minor optimization, ignore moving object until find the first collected object. */
/* Find the first collected object. */
while(gen2roots[i]->flags & MVM_CF_GEN2_LIVE)
i++;

cur_survivor = i;

for (i = 0; i < num_roots; i++)
/* Slide others back so the alive ones are at the start of the list. */
while (i < num_roots) {
if (gen2roots[i]->flags & MVM_CF_GEN2_LIVE) {
assert(!(gen2roots[i]->flags & MVM_CF_FORWARDER_VALID));
gen2roots[cur_survivor++] = gen2roots[i];
}
i++;
}

tc->num_gen2roots = cur_survivor;
}

Expand Down

0 comments on commit 0629b9a

Please sign in to comment.