NonMovingScav: Account for new allocations
authorBen Gamari <ben@smart-cactus.org>
Tue, 21 May 2019 00:27:48 +0000 (20:27 -0400)
committerBen Gamari <ben@smart-cactus.org>
Wed, 19 Jun 2019 01:44:01 +0000 (21:44 -0400)
Previously if we evacuated any objects to the segment that we were
scavenging we would exit the scavenge loop before having scavenged them.
This isn't a correctness issue since we would try again to scavenge
later but it is slightly more efficient to handle newly-allocated
objects ASAP after we allocate them.

rts/sm/NonMovingScav.c

index f4c14aa..82b8059 100644 (file)
@@ -370,13 +370,12 @@ scavengeNonmovingSegment (struct NonmovingSegment *seg)
     ASSERT(seg_block->u.scan >= (P_)nonmovingSegmentGetBlock(seg, 0));
     ASSERT(seg_block->u.scan <= (P_)nonmovingSegmentGetBlock(seg, seg->next_free));
 
-    StgPtr scan_end = (P_)nonmovingSegmentGetBlock(seg, seg->next_free);
-    if (seg_block->u.scan == scan_end)
+    nonmoving_block_idx p_idx = nonmovingGetBlockIdx(seg_block->u.scan);
+    if (p_idx == seg->next_free)
         return;
     trace_dump_note("scavenging segment");
 
-    nonmoving_block_idx p_idx = nonmovingGetBlockIdx(seg_block->u.scan);
-    while (seg_block->u.scan < scan_end) {
+    while (p_idx < seg->next_free) {
         StgClosure *p = (StgClosure*)seg_block->u.scan;
         trace_dump_set_source_closure(p);