Avoid marking IDs in too_complex tables and rename gc_update_tbl_refs()

Marking both keys and values versus marking just values is an important
distinction, but previously, gc_update_tbl_refs() and gc_update_table_refs()
had names that were too similar.

The st_table storing ivars for too_complex T_OBJECTs have IDs as keys,
but we were marking the IDs unnecessary previously, maybe due to the
confusing naming.
This commit is contained in:
Alan Wu 2023-11-23 18:26:58 -05:00
parent f05d586cc9
commit 22de08811e

10
gc.c
View File

@ -10123,13 +10123,15 @@ gc_ref_update_array(rb_objspace_t * objspace, VALUE v)
} }
} }
static void gc_ref_update_table_values_only(rb_objspace_t *objspace, st_table *tbl);
static void static void
gc_ref_update_object(rb_objspace_t *objspace, VALUE v) gc_ref_update_object(rb_objspace_t *objspace, VALUE v)
{ {
VALUE *ptr = ROBJECT_IVPTR(v); VALUE *ptr = ROBJECT_IVPTR(v);
if (rb_shape_obj_too_complex(v)) { if (rb_shape_obj_too_complex(v)) {
rb_gc_update_tbl_refs(ROBJECT_IV_HASH(v)); gc_ref_update_table_values_only(objspace, ROBJECT_IV_HASH(v));
return; return;
} }
@ -10207,7 +10209,7 @@ hash_foreach_replace_value(st_data_t key, st_data_t value, st_data_t argp, int e
} }
static void static void
gc_update_tbl_refs(rb_objspace_t * objspace, st_table *tbl) gc_ref_update_table_values_only(rb_objspace_t *objspace, st_table *tbl)
{ {
if (!tbl || tbl->num_entries == 0) return; if (!tbl || tbl->num_entries == 0) return;
@ -10226,7 +10228,7 @@ gc_update_table_refs(rb_objspace_t * objspace, st_table *tbl)
} }
} }
/* Update MOVED references in an st_table */ /* Update MOVED references in a VALUE=>VALUE st_table */
void void
rb_gc_update_tbl_refs(st_table *ptr) rb_gc_update_tbl_refs(st_table *ptr)
{ {
@ -10846,7 +10848,7 @@ gc_update_references(rb_objspace_t *objspace)
rb_gc_update_global_tbl(); rb_gc_update_global_tbl();
global_symbols.ids = rb_gc_location(global_symbols.ids); global_symbols.ids = rb_gc_location(global_symbols.ids);
global_symbols.dsymbol_fstr_hash = rb_gc_location(global_symbols.dsymbol_fstr_hash); global_symbols.dsymbol_fstr_hash = rb_gc_location(global_symbols.dsymbol_fstr_hash);
gc_update_tbl_refs(objspace, objspace->obj_to_id_tbl); gc_ref_update_table_values_only(objspace, objspace->obj_to_id_tbl);
gc_update_table_refs(objspace, objspace->id_to_obj_tbl); gc_update_table_refs(objspace, objspace->id_to_obj_tbl);
gc_update_table_refs(objspace, global_symbols.str_sym); gc_update_table_refs(objspace, global_symbols.str_sym);
gc_update_table_refs(objspace, finalizer_table); gc_update_table_refs(objspace, finalizer_table);