wingo pushed a commit to branch wip-whippet
in repository guile.

commit 7b4a56c51aa8249c0910f82b9b8750b9dd26d711
Author: Andy Wingo <wi...@igalia.com>
AuthorDate: Sun Aug 25 08:45:17 2024 +0200

    nofl: Fix sticky mark bit treatment for block marks
---
 src/nofl-space.h | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/nofl-space.h b/src/nofl-space.h
index fd05251a7..118b4e65b 100644
--- a/src/nofl-space.h
+++ b/src/nofl-space.h
@@ -930,9 +930,21 @@ nofl_space_update_mark_patterns(struct nofl_space *space,
   space->sweep_mask = broadcast_byte(space->live_mask);
 }
 
+static void
+nofl_space_clear_block_marks(struct nofl_space *space) {
+  for (size_t s = 0; s < space->nslabs; s++) {
+    struct nofl_slab *slab = &space->slabs[s];
+    memset(&slab->header.block_marks, 0, NOFL_BLOCKS_PER_SLAB / 8);
+  }
+}
+
 static void
 nofl_space_prepare_gc(struct nofl_space *space, enum gc_collection_kind kind) {
-  nofl_space_update_mark_patterns(space, !(kind == GC_COLLECTION_MINOR));
+  int is_minor = kind == GC_COLLECTION_MINOR;
+  if (!is_minor) {
+    nofl_space_update_mark_patterns(space, 1);
+    nofl_space_clear_block_marks(space);
+  }
 }
 
 static void
@@ -1122,7 +1134,6 @@ nofl_space_finish_gc(struct nofl_space *space,
     uintptr_t block;
     while ((block = nofl_pop_block(&space->to_sweep))) {
       if (nofl_block_is_marked(block)) {
-        nofl_block_clear_mark(block);
         nofl_push_block(&to_sweep, block);
       } else {
         // Block is empty.

Reply via email to