Skip to content

Commit 67a14e9

Browse files
committed
Set age bitmap outside of adding to freelist
This allows us to do less work when allocating a fresh page.
1 parent 795e290 commit 67a14e9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

gc/default/default.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,8 @@ heap_page_add_freeobj(rb_objspace_t *objspace, struct heap_page *page, VALUE obj
15871587
page->freelist = slot;
15881588
asan_lock_freelist(page);
15891589

1590-
RVALUE_AGE_SET_BITMAP(obj, 0);
1590+
// Should have already been reset
1591+
GC_ASSERT(RVALUE_AGE_GET(obj) == 0);
15911592

15921593
if (RGENGC_CHECK_MODE &&
15931594
/* obj should belong to page */
@@ -2894,6 +2895,7 @@ finalize_list(rb_objspace_t *objspace, VALUE zombie)
28942895
page->heap->final_slots_count--;
28952896
page->final_slots--;
28962897
page->free_slots++;
2898+
RVALUE_AGE_SET_BITMAP(zombie, 0);
28972899
heap_page_add_freeobj(objspace, page, zombie);
28982900
page->heap->total_freed_objects++;
28992901
}
@@ -3496,6 +3498,7 @@ gc_sweep_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bit
34963498
// always add free slots back to the swept pages freelist,
34973499
// so that if we're compacting, we can re-use the slots
34983500
(void)VALGRIND_MAKE_MEM_UNDEFINED((void*)p, BASE_SLOT_SIZE);
3501+
RVALUE_AGE_SET_BITMAP(vp, 0);
34993502
heap_page_add_freeobj(objspace, sweep_page, vp);
35003503
gc_report(3, objspace, "page_sweep: %s is added to freelist\n", rb_obj_info(vp));
35013504
ctx->freed_slots++;
@@ -3516,6 +3519,7 @@ gc_sweep_plane(rb_objspace_t *objspace, rb_heap_t *heap, uintptr_t p, bits_t bit
35163519
}
35173520
gc_report(3, objspace, "page_sweep: %s is added to freelist\n", rb_obj_info(vp));
35183521
ctx->empty_slots++;
3522+
RVALUE_AGE_SET_BITMAP(vp, 0);
35193523
heap_page_add_freeobj(objspace, sweep_page, vp);
35203524
break;
35213525
case T_ZOMBIE:
@@ -4023,6 +4027,7 @@ invalidate_moved_plane(rb_objspace_t *objspace, struct heap_page *page, uintptr_
40234027

40244028
struct heap_page *orig_page = GET_HEAP_PAGE(object);
40254029
orig_page->free_slots++;
4030+
RVALUE_AGE_SET_BITMAP(object, 0);
40264031
heap_page_add_freeobj(objspace, orig_page, object);
40274032

40284033
GC_ASSERT(RVALUE_MARKED(objspace, forwarding_object));

0 commit comments

Comments
 (0)