summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-10-22 21:00:16 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-03-08 15:02:30 -0500
commit7eab831a7d17eda3108da4702a447656cd62334c (patch)
tree4a33adb12a232744dc344a75a11f3dcdc4ffaa7f
parent0edc543834d8172e54020c5272af1cf2d0b3437c (diff)
downloadhaskell-7eab831a7d17eda3108da4702a447656cd62334c.tar.gz
nonmoving: Clarify implementation
This makes the intent of this implementation a bit clearer.
-rw-r--r--rts/sm/NonMovingSweep.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/rts/sm/NonMovingSweep.c b/rts/sm/NonMovingSweep.c
index 2b0cd44a53..5cd763bc92 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;
@@ -120,7 +120,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);
}