diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-10-22 21:00:16 +0000 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2023-01-09 13:55:05 -0500 |
commit | 795eedcdb5c450b23c43f4996caaa6a36565bb89 (patch) | |
tree | 7a7aa843a2c85dd1a6fd3de3ed6ccb61395559c3 | |
parent | a24d71f976802db4747e6fa388c3e7ba11331044 (diff) | |
download | haskell-795eedcdb5c450b23c43f4996caaa6a36565bb89.tar.gz |
nonmoving: Clarify implementation
This makes the intent of this implementation a bit clearer.
-rw-r--r-- | rts/sm/NonMovingSweep.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/rts/sm/NonMovingSweep.c b/rts/sm/NonMovingSweep.c index ad2b422307..42344773d3 100644 --- a/rts/sm/NonMovingSweep.c +++ b/rts/sm/NonMovingSweep.c @@ -39,20 +39,20 @@ nonmovingSweepSegment(struct NonmovingSegment *seg) { if (seg->bitmap[i] == nonmovingMarkEpoch) { found_live = true; - } else if (!found_free) { - // This is the first free block we've found; set next_free, - // next_free_snap, and the scan pointer. - found_free = true; - seg->next_free = i; - nonmovingSegmentInfo(seg)->next_free_snap = i; - Bdescr((P_)seg)->u.scan = (P_)nonmovingSegmentGetBlock(seg, i); - seg->bitmap[i] = 0; } else { seg->bitmap[i] = 0; + if (!found_free) { + // This is the first free block we've found; set next_free, + // next_free_snap, and the scan pointer. + found_free = true; + seg->next_free = i; + nonmovingSegmentInfo(seg)->next_free_snap = i; + Bdescr((P_)seg)->u.scan = (P_)nonmovingSegmentGetBlock(seg, i); + } } if (found_free && found_live) { - // zero the remaining dead object's mark bits + // zero the remaining dead objects' mark bits for (; i < nonmovingSegmentBlockCount(seg); ++i) { if (seg->bitmap[i] != nonmovingMarkEpoch) { seg->bitmap[i] = 0; @@ -118,7 +118,8 @@ clear_segment_free_blocks(struct NonmovingSegment* seg) { unsigned int block_size = nonmovingSegmentBlockSize(seg); for (unsigned int p_idx = 0; p_idx < nonmovingSegmentBlockCount(seg); ++p_idx) { - // after mark, so bit not set == dead + // N.B. nonmovingSweepSegment helpfully clears the bitmap entries of + // dead blocks if (nonmovingGetMark(seg, p_idx) == 0) { memset(nonmovingSegmentGetBlock(seg, p_idx), 0, block_size); } |