summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-10-22 21:00:16 +0000
committerBen Gamari <ben@smart-cactus.org>2023-04-12 07:43:22 -0400
commit091841a2655156da1c73abc2a37581421d5f7ebf (patch)
tree0d941191b0a987fd5e8ed60c9eb309673aaa0432
parent8a373f232e79152896660c9d4bec2a4d1770865c (diff)
downloadhaskell-091841a2655156da1c73abc2a37581421d5f7ebf.tar.gz
nonmoving: Clarify implementation
This makes the intent of this implementation a bit clearer. (cherry picked from commit ba3c7b67bd74906de63b3988b18a14b01861d3c9)
-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 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);
}