Skip to content

Commit 51ab44d

Browse files
committed
Remove VM lock acquire during finalize_list and run_final
Each objspace has its own finalizer list since RLGC landed so there aren't concurrency issues here. This used to be a global table that all Ractors shared. This affects only the default GC.
1 parent c4e235f commit 51ab44d

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

gc/default/default.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3877,8 +3877,8 @@ get_final(long i, void *data)
38773877
return RARRAY_AREF(table, i + 1);
38783878
}
38793879

3880-
static unsigned int
3881-
run_final(rb_objspace_t *objspace, VALUE zombie, unsigned int lev)
3880+
static void
3881+
run_final(rb_objspace_t *objspace, VALUE zombie)
38823882
{
38833883
if (RZOMBIE(zombie)->dfree) {
38843884
RZOMBIE(zombie)->dfree(RZOMBIE(zombie)->data);
@@ -3889,9 +3889,7 @@ run_final(rb_objspace_t *objspace, VALUE zombie, unsigned int lev)
38893889
FL_UNSET(zombie, FL_FINALIZE);
38903890
st_data_t table;
38913891
if (st_delete(finalizer_table, &key, &table)) {
3892-
RB_GC_VM_UNLOCK(lev);
38933892
rb_gc_run_obj_finalizer(RARRAY_AREF(table, 0), RARRAY_LEN(table) - 1, get_final, (void *)table);
3894-
lev = RB_GC_VM_LOCK();
38953893
}
38963894
else {
38973895
rb_bug("FL_FINALIZE flag is set, but finalizers are not found");
@@ -3900,7 +3898,6 @@ run_final(rb_objspace_t *objspace, VALUE zombie, unsigned int lev)
39003898
else {
39013899
GC_ASSERT(!st_lookup(finalizer_table, key, NULL));
39023900
}
3903-
return lev;
39043901
}
39053902

39063903
static void
@@ -3913,9 +3910,7 @@ finalize_list(rb_objspace_t *objspace, VALUE zombie)
39133910
next_zombie = RZOMBIE(zombie)->next;
39143911
page = GET_HEAP_PAGE(zombie);
39153912

3916-
unsigned int lev = RB_GC_VM_LOCK();
3917-
3918-
lev = run_final(objspace, zombie, lev);
3913+
run_final(objspace, zombie);
39193914
{
39203915
GC_ASSERT(BUILTIN_TYPE(zombie) == T_ZOMBIE);
39213916
GC_ASSERT(page->heap->final_slots_count > 0);
@@ -3928,7 +3923,6 @@ finalize_list(rb_objspace_t *objspace, VALUE zombie)
39283923
heap_page_add_free_region(objspace, page, zombie);
39293924
page->heap->total_freed_objects++;
39303925
}
3931-
RB_GC_VM_UNLOCK(lev);
39323926

39333927
zombie = next_zombie;
39343928
}

0 commit comments

Comments
 (0)