diff --git a/depend b/depend index 697a9a5eb7..8db2d7a675 100644 --- a/depend +++ b/depend @@ -16680,7 +16680,6 @@ shape.$(OBJEXT): $(top_srcdir)/internal/object.h shape.$(OBJEXT): $(top_srcdir)/internal/sanitizers.h shape.$(OBJEXT): $(top_srcdir)/internal/serial.h shape.$(OBJEXT): $(top_srcdir)/internal/set_table.h -shape.$(OBJEXT): $(top_srcdir)/internal/st.h shape.$(OBJEXT): $(top_srcdir)/internal/static_assert.h shape.$(OBJEXT): $(top_srcdir)/internal/string.h shape.$(OBJEXT): $(top_srcdir)/internal/struct.h diff --git a/internal/variable.h b/internal/variable.h index d743a7033f..1b3c01f546 100644 --- a/internal/variable.h +++ b/internal/variable.h @@ -49,7 +49,7 @@ VALUE rb_mod_set_temporary_name(VALUE, VALUE); void rb_obj_replace_fields(VALUE obj, VALUE fields_obj); void rb_obj_copy_ivs_to_hash_table(VALUE obj, st_table *table); -void rb_evict_ivars_to_hash(VALUE obj); +VALUE rb_obj_complex_fields_build(VALUE obj); VALUE rb_obj_field_get(VALUE obj, shape_id_t target_shape_id); void rb_ivar_set_internal(VALUE obj, ID id, VALUE val); void rb_ivar_foreach_buffered(VALUE obj, int (*func)(ID name, VALUE val, st_data_t arg), st_data_t arg); diff --git a/object.c b/object.c index 52b80e1e2d..033b3dc35f 100644 --- a/object.c +++ b/object.c @@ -342,10 +342,7 @@ rb_obj_copy_ivar(VALUE dest, VALUE obj) shape_id_t dest_shape_id = rb_shape_rebuild(initial_shape_id, src_shape_id); if (UNLIKELY(rb_shape_complex_p(dest_shape_id))) { - VALUE fields_obj = rb_imemo_fields_new_complex(dest, dest_shape_id, rb_ivar_count(obj), false); - st_table *table = rb_imemo_fields_complex_tbl(fields_obj); - rb_obj_copy_ivs_to_hash_table(obj, table); - rb_obj_replace_fields(dest, fields_obj); + rb_obj_replace_fields(dest, rb_obj_complex_fields_build(obj)); return; } diff --git a/shape.c b/shape.c index a0b12b4759..0004d4cc56 100644 --- a/shape.c +++ b/shape.c @@ -9,7 +9,6 @@ #include "internal/object.h" #include "internal/symbol.h" #include "internal/variable.h" -#include "internal/st.h" #include "variable.h" #include @@ -1155,24 +1154,6 @@ rb_shape_copy_fields(VALUE dest, VALUE *dest_buf, shape_id_t dest_shape_id, VALU } } -void -rb_shape_copy_complex_ivars(VALUE dest, VALUE src) -{ - RUBY_ASSERT(IMEMO_TYPE_P(src, imemo_fields)); - RUBY_ASSERT(IMEMO_TYPE_P(dest, imemo_fields)); - - shape_id_t dest_shape_id = RBASIC_SHAPE_ID(src); - st_table *dest_table = rb_imemo_fields_complex_tbl(dest); - st_replace(dest_table, rb_imemo_fields_complex_tbl(src)); - - if (rb_shape_has_object_id(dest_shape_id)) { - st_data_t stkey = (st_data_t)id_object_id; - st_delete(dest_table, &stkey, NULL); - } - - RBASIC_SET_SHAPE_ID(dest, ROOT_COMPLEX_SHAPE_ID); -} - size_t rb_shape_edges_count(shape_id_t shape_id) { diff --git a/shape.h b/shape.h index 2c67d33123..c2cf158c72 100644 --- a/shape.h +++ b/shape.h @@ -267,7 +267,6 @@ shape_id_t rb_shape_transition_add_ivar_no_warnings(shape_id_t shape_id, ID id, shape_id_t rb_shape_object_id(shape_id_t original_shape_id); shape_id_t rb_shape_rebuild(shape_id_t initial_shape_id, shape_id_t dest_shape_id); void rb_shape_copy_fields(VALUE dest, VALUE *dest_buf, shape_id_t dest_shape_id, VALUE *src_buf, shape_id_t src_shape_id); -void rb_shape_copy_complex_ivars(VALUE dest, VALUE src); static inline bool rb_shape_frozen_p(shape_id_t shape_id) diff --git a/variable.c b/variable.c index 27fab5c591..f78c35cac1 100644 --- a/variable.c +++ b/variable.c @@ -1623,20 +1623,13 @@ rb_evict_fields_to_hash(VALUE obj) return new_shape_id; } -void -rb_evict_ivars_to_hash(VALUE obj) +VALUE +rb_obj_complex_fields_build(VALUE obj) { - RUBY_ASSERT(RB_TYPE_P(obj, T_OBJECT)); - RUBY_ASSERT(!rb_obj_shape_complex_p(obj)); - - shape_id_t new_shape_id = rb_obj_shape_transition_complex(obj); - VALUE fields_obj = rb_imemo_fields_new_complex(obj, new_shape_id, rb_ivar_count(obj), false); + VALUE fields_obj = rb_imemo_fields_new_complex(obj, ROOT_COMPLEX_SHAPE_ID, rb_ivar_count(obj), false); st_table *table = rb_imemo_fields_complex_tbl(fields_obj); rb_obj_copy_ivs_to_hash_table(obj, table); - ROBJECT_SET_EXTENDED(obj, fields_obj); - RBASIC_SET_FULL_SHAPE_ID(obj, rb_shape_transition_extended(new_shape_id)); - - RUBY_ASSERT(rb_obj_shape_complex_p(obj)); + return fields_obj; } static VALUE @@ -2290,10 +2283,7 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj) shape_id_t dest_shape_id = rb_shape_rebuild(initial_shape_id, src_shape_id); if (UNLIKELY(rb_shape_complex_p(dest_shape_id))) { - new_fields_obj = rb_imemo_fields_new_complex(dest, dest_shape_id, rb_ivar_count(obj), false); - st_table *table = rb_imemo_fields_complex_tbl(new_fields_obj); - rb_obj_copy_ivs_to_hash_table(obj, table); - rb_obj_replace_fields(dest, new_fields_obj); + rb_obj_replace_fields(dest, rb_obj_complex_fields_build(obj)); return; }