File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed 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 = {
1810
1810
.flags = RUBY_TYPED_WB_PROTECTED | RUBY_TYPED_FREE_IMMEDIATELY
1811
1811
};
1812
1812
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
+
1813
1823
static VALUE
1814
1824
object_id (VALUE obj )
1815
1825
{
Original file line number Diff line number Diff line change @@ -262,6 +262,8 @@ void ruby_sized_xfree(void *x, size_t size);
262
262
const char * rb_gc_active_gc_name (void );
263
263
int rb_gc_modular_gc_loaded_p (void );
264
264
265
+ bool rb_gc_update_id_to_obj_table (VALUE obj , VALUE id );
266
+
265
267
RUBY_SYMBOL_EXPORT_END
266
268
267
269
int rb_ec_stack_check (struct rb_execution_context_struct * ec );
Original file line number Diff line number Diff line change @@ -1590,6 +1590,15 @@ rb_evict_fields_to_hash(VALUE obj)
1590
1590
1591
1591
// Evacuate all previous values from shape into id_table
1592
1592
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_shape_t * object_id_shape = rb_shape_object_id_shape (obj );
1598
+ VALUE id = rb_field_get (obj , object_id_shape );
1599
+ rb_gc_update_id_to_obj_table (obj , id );
1600
+ }
1601
+
1593
1602
obj_transition_too_complex (obj , table );
1594
1603
1595
1604
RUBY_ASSERT (rb_shape_obj_too_complex (obj ));
You can’t perform that action at this time.
0 commit comments