File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1810,6 +1810,16 @@ 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+
18131823static VALUE
18141824object_id (VALUE obj )
18151825{
Original file line number Diff line number Diff line change @@ -262,6 +262,8 @@ void ruby_sized_xfree(void *x, size_t size);
262262const char * rb_gc_active_gc_name (void );
263263int rb_gc_modular_gc_loaded_p (void );
264264
265+ bool rb_gc_update_id_to_obj_table (VALUE obj , VALUE id );
266+
265267RUBY_SYMBOL_EXPORT_END
266268
267269int rb_ec_stack_check (struct rb_execution_context_struct * ec );
Original file line number Diff line number Diff line change @@ -1590,6 +1590,13 @@ 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+ // We need to ensure the object ID is registered in id_to_obj_table
1596+ // before transitioning to too complex.
1597+ rb_gc_update_id_to_obj_table (obj , id );
1598+ }
1599+
15931600 obj_transition_too_complex (obj , table );
15941601
15951602 RUBY_ASSERT (rb_shape_obj_too_complex (obj ));
You can’t perform that action at this time.
0 commit comments