Skip to content

Commit 25e5095

Browse files
committed
Get rid of rb_gc_update_id_to_obj_table
It was a blind attempt at fixing a bug, but I'm pretty sure it's not necessary. In addition, `rb_evict_fields_to_hash` already copy the `object_id` in the `st_table` via `rb_obj_copy_fields_to_hash_table`. And `rb_evict_ivars_to_hash` shouldn't evict the `object_id`.
1 parent dc039da commit 25e5095

3 files changed

Lines changed: 3 additions & 35 deletions

File tree

gc.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,16 +1810,6 @@ static const rb_data_type_t id_to_obj_tbl_type = {
18101810
.flags = RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
18111811
};
18121812

1813-
bool
1814-
rb_gc_update_id_to_obj_table(VALUE obj, VALUE id)
1815-
{
1816-
if (id_to_obj_tbl && !st_lookup(id_to_obj_tbl, id, 0)) {
1817-
st_insert(id_to_obj_tbl, id, obj);
1818-
return true;
1819-
}
1820-
return false;
1821-
}
1822-
18231813
static VALUE
18241814
object_id(VALUE obj)
18251815
{

internal/gc.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ void ruby_sized_xfree(void *x, size_t size);
262262
const char *rb_gc_active_gc_name(void);
263263
int rb_gc_modular_gc_loaded_p(void);
264264

265-
bool rb_gc_update_id_to_obj_table(VALUE obj, VALUE id);
266-
267265
RUBY_SYMBOL_EXPORT_END
268266

269267
int rb_ec_stack_check(struct rb_execution_context_struct *ec);

variable.c

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,16 +1590,6 @@ rb_evict_fields_to_hash(VALUE obj)
15901590

15911591
// Evacuate all previous values from shape into id_table
15921592
rb_obj_copy_fields_to_hash_table(obj, table);
1593-
rb_shape_t *shape = rb_shape_get_shape(obj);
1594-
if (rb_shape_has_object_id(shape)) {
1595-
rb_shape_t *object_id_shape = rb_shape_object_id_shape(obj);
1596-
VALUE id = rb_field_get(obj, object_id_shape);
1597-
st_insert(table, internal_object_id, id);
1598-
1599-
// We need to ensure the object ID is registered in id_to_obj_table
1600-
// before transitioning to too complex
1601-
rb_gc_update_id_to_obj_table(obj, id);
1602-
}
16031593
obj_transition_too_complex(obj, table);
16041594

16051595
RUBY_ASSERT(rb_shape_obj_too_complex(obj));
@@ -1614,16 +1604,6 @@ rb_evict_ivars_to_hash(VALUE obj)
16141604

16151605
// Evacuate all previous values from shape into id_table
16161606
rb_obj_copy_ivs_to_hash_table(obj, table);
1617-
rb_shape_t *shape = rb_shape_get_shape(obj);
1618-
if (rb_shape_has_object_id(shape)) {
1619-
rb_shape_t *object_id_shape = rb_shape_object_id_shape(obj);
1620-
VALUE id = rb_field_get(obj, object_id_shape);
1621-
st_insert(table, internal_object_id, id);
1622-
1623-
// We need to ensure the object ID is registered in id_to_obj_table
1624-
// before transitioning to too complex
1625-
rb_gc_update_id_to_obj_table(obj, id);
1626-
}
16271607
obj_transition_too_complex(obj, table);
16281608

16291609
RUBY_ASSERT(rb_shape_obj_too_complex(obj));
@@ -1895,7 +1875,7 @@ rb_ensure_iv_list_size(VALUE obj, uint32_t current_capacity, uint32_t new_capaci
18951875
}
18961876

18971877
static int
1898-
rb_obj_copy_ivs_to_hash_table_i(ID key, VALUE val, st_data_t arg)
1878+
rb_obj_copy_fields_to_hash_table_i(ID key, VALUE val, st_data_t arg)
18991879
{
19001880
RUBY_ASSERT(!st_lookup((st_table *)arg, (st_data_t)key, NULL));
19011881

@@ -1906,13 +1886,13 @@ rb_obj_copy_ivs_to_hash_table_i(ID key, VALUE val, st_data_t arg)
19061886
void
19071887
rb_obj_copy_ivs_to_hash_table(VALUE obj, st_table *table)
19081888
{
1909-
rb_ivar_foreach(obj, rb_obj_copy_ivs_to_hash_table_i, (st_data_t)table);
1889+
rb_ivar_foreach(obj, rb_obj_copy_fields_to_hash_table_i, (st_data_t)table);
19101890
}
19111891

19121892
void
19131893
rb_obj_copy_fields_to_hash_table(VALUE obj, st_table *table)
19141894
{
1915-
rb_field_foreach(obj, rb_obj_copy_ivs_to_hash_table_i, (st_data_t)table, false);
1895+
rb_field_foreach(obj, rb_obj_copy_fields_to_hash_table_i, (st_data_t)table, false);
19161896
}
19171897

19181898
static VALUE *

0 commit comments

Comments
 (0)