@@ -1660,7 +1660,7 @@ rb_obj_init_too_complex(VALUE obj, st_table *table)
16601660 // This method is meant to be called on newly allocated object.
16611661 RUBY_ASSERT (!rb_shape_obj_too_complex_p (obj ));
16621662 RUBY_ASSERT (rb_shape_id_canonical_p (RBASIC_SHAPE_ID (obj )));
1663- RUBY_ASSERT (rb_obj_shape ( obj )-> next_field_index == 0 );
1663+ RUBY_ASSERT (RSHAPE_LEN ( RBASIC_SHAPE_ID ( obj )) == 0 );
16641664
16651665 obj_transition_too_complex (obj , table );
16661666}
@@ -1673,8 +1673,7 @@ rb_evict_fields_to_hash(VALUE obj)
16731673
16741674 RUBY_ASSERT (!rb_shape_obj_too_complex_p (obj ));
16751675
1676- rb_shape_t * shape = rb_obj_shape (obj );
1677- st_table * table = st_init_numtable_with_size (shape -> next_field_index );
1676+ st_table * table = st_init_numtable_with_size (RSHAPE_LEN (RBASIC_SHAPE_ID (obj )));
16781677 rb_obj_copy_fields_to_hash_table (obj , table );
16791678 obj_transition_too_complex (obj , table );
16801679
@@ -1771,28 +1770,28 @@ general_field_set(VALUE obj, shape_id_t target_shape_id, VALUE val, void *data,
17711770 void (* transition_too_complex_func )(VALUE , void * ),
17721771 st_table * (* too_complex_table_func )(VALUE , void * ))
17731772{
1774- rb_shape_t * current_shape = rb_obj_shape (obj );
1773+ shape_id_t current_shape_id = RBASIC_SHAPE_ID (obj );
17751774
17761775 if (UNLIKELY (rb_shape_id_too_complex_p (target_shape_id ))) {
1777- if (UNLIKELY (!rb_shape_too_complex_p ( current_shape ))) {
1776+ if (UNLIKELY (!rb_shape_id_too_complex_p ( current_shape_id ))) {
17781777 transition_too_complex_func (obj , data );
17791778 }
17801779
17811780 st_table * table = too_complex_table_func (obj , data );
1782- if (RSHAPE (target_shape_id )-> next_field_index > current_shape -> next_field_index ) {
1781+ if (RSHAPE_LEN (target_shape_id ) > RSHAPE_LEN ( current_shape_id ) ) {
17831782 set_shape_id_func (obj , target_shape_id , data );
17841783 }
17851784
1786- st_insert (table , (st_data_t )RSHAPE (target_shape_id )-> edge_name , (st_data_t )val );
1785+ st_insert (table , (st_data_t )RSHAPE_EDGE_NAME (target_shape_id ), (st_data_t )val );
17871786 RB_OBJ_WRITTEN (obj , Qundef , val );
17881787 }
17891788 else {
1790- attr_index_t index = RSHAPE (target_shape_id )-> next_field_index - 1 ;
1791- if (index >= current_shape -> capacity ) {
1792- shape_resize_fields_func (obj , current_shape -> capacity , RSHAPE (target_shape_id )-> capacity , data );
1789+ attr_index_t index = RSHAPE_INDEX (target_shape_id );
1790+ if (index >= RSHAPE_CAPACITY ( current_shape_id ) ) {
1791+ shape_resize_fields_func (obj , RSHAPE_CAPACITY ( current_shape_id ), RSHAPE_CAPACITY (target_shape_id ), data );
17931792 }
17941793
1795- if (RSHAPE (target_shape_id )-> next_field_index > current_shape -> next_field_index ) {
1794+ if (RSHAPE_LEN (target_shape_id ) > RSHAPE_LEN ( current_shape_id ) ) {
17961795 set_shape_id_func (obj , target_shape_id , data );
17971796 }
17981797
@@ -2257,19 +2256,18 @@ obj_fields_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg, b
22572256 .ivar_only = ivar_only ,
22582257 };
22592258
2260- rb_shape_t * shape = rb_obj_shape (obj );
2261- if (rb_shape_too_complex_p ( shape )) {
2259+ shape_id_t shape_id = RBASIC_SHAPE_ID (obj );
2260+ if (rb_shape_id_too_complex_p ( shape_id )) {
22622261 rb_st_foreach (ROBJECT_FIELDS_HASH (obj ), each_hash_iv , (st_data_t )& itr_data );
22632262 }
22642263 else {
2265- iterate_over_shapes_with_callback (shape , func , & itr_data );
2264+ iterate_over_shapes_with_callback (RSHAPE ( shape_id ) , func , & itr_data );
22662265 }
22672266}
22682267
22692268static void
22702269gen_fields_each (VALUE obj , rb_ivar_foreach_callback_func * func , st_data_t arg , bool ivar_only )
22712270{
2272- rb_shape_t * shape = rb_obj_shape (obj );
22732271 struct gen_fields_tbl * fields_tbl ;
22742272 if (!rb_gen_fields_tbl_get (obj , 0 , & fields_tbl )) return ;
22752273
@@ -2281,11 +2279,12 @@ gen_fields_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg, b
22812279 .ivar_only = ivar_only ,
22822280 };
22832281
2284- if (rb_shape_obj_too_complex_p (obj )) {
2282+ shape_id_t shape_id = RBASIC_SHAPE_ID (obj );
2283+ if (rb_shape_id_too_complex_p (shape_id )) {
22852284 rb_st_foreach (fields_tbl -> as .complex .table , each_hash_iv , (st_data_t )& itr_data );
22862285 }
22872286 else {
2288- iterate_over_shapes_with_callback (shape , func , & itr_data );
2287+ iterate_over_shapes_with_callback (RSHAPE ( shape_id ) , func , & itr_data );
22892288 }
22902289}
22912290
@@ -2294,19 +2293,19 @@ class_fields_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg,
22942293{
22952294 RUBY_ASSERT (RB_TYPE_P (obj , T_CLASS ) || RB_TYPE_P (obj , T_MODULE ));
22962295
2297- rb_shape_t * shape = rb_obj_shape (obj );
22982296 struct iv_itr_data itr_data = {
22992297 .obj = obj ,
23002298 .arg = arg ,
23012299 .func = func ,
23022300 .ivar_only = ivar_only ,
23032301 };
23042302
2305- if (rb_shape_obj_too_complex_p (obj )) {
2303+ shape_id_t shape_id = RBASIC_SHAPE_ID (obj );
2304+ if (rb_shape_id_too_complex_p (shape_id )) {
23062305 rb_st_foreach (RCLASS_WRITABLE_FIELDS_HASH (obj ), each_hash_iv , (st_data_t )& itr_data );
23072306 }
23082307 else {
2309- iterate_over_shapes_with_callback (shape , func , & itr_data );
2308+ iterate_over_shapes_with_callback (RSHAPE ( shape_id ) , func , & itr_data );
23102309 }
23112310}
23122311
@@ -4738,7 +4737,7 @@ rb_fields_tbl_copy(VALUE dst, VALUE src)
47384737 RUBY_ASSERT (rb_type (dst ) == rb_type (src ));
47394738 RUBY_ASSERT (RB_TYPE_P (dst , T_CLASS ) || RB_TYPE_P (dst , T_MODULE ));
47404739
4741- RUBY_ASSERT (rb_obj_shape ( dst )-> type == SHAPE_ROOT );
4740+ RUBY_ASSERT (RSHAPE_TYPE_P ( RBASIC_SHAPE_ID ( dst ), SHAPE_ROOT ) );
47424741 RUBY_ASSERT (!RCLASS_PRIME_FIELDS (dst ));
47434742
47444743 rb_ivar_foreach (src , tbl_copy_i , dst );
0 commit comments