Use rb_gc_vm_weak_table_foreach for reference updating

We can use rb_gc_vm_weak_table_foreach for reference updating of weak tables
in the default GC.
This commit is contained in:
Peter Zhu 2025-01-24 10:16:27 -05:00
parent 9e5ff79c5b
commit 98b36f6f36
Notes: git 2025-01-27 15:28:55 +00:00
6 changed files with 26 additions and 48 deletions

View file

@ -1136,42 +1136,6 @@ rb_mark_generic_ivar(VALUE obj)
}
}
static int
rb_generic_ivar_update_references_i(st_data_t key, st_data_t val, st_data_t _data)
{
VALUE orig_obj = (VALUE)key;
VALUE obj = rb_gc_location(orig_obj);
struct gen_ivtbl *ivtbl = (struct gen_ivtbl *)val;
if (rb_shape_obj_too_complex(obj)) {
rb_gc_ref_update_table_values_only(ivtbl->as.complex.table);
}
else {
for (uint32_t i = 0; i < ivtbl->as.shape.numiv; i++) {
ivtbl->as.shape.ivptr[i] = rb_gc_location(ivtbl->as.shape.ivptr[i]);
}
}
if (obj != orig_obj) {
st_insert(generic_iv_tbl_, (st_data_t)obj, (st_data_t)ivtbl);
return ST_DELETE;
}
else {
return ST_CONTINUE;
}
}
void
rb_generic_ivar_update_references(void)
{
DURING_GC_COULD_MALLOC_REGION_START();
{
st_foreach(generic_iv_tbl_, rb_generic_ivar_update_references_i, (st_data_t)0);
}
DURING_GC_COULD_MALLOC_REGION_END();
}
void
rb_free_generic_ivar(VALUE obj)
{