@@ -1322,7 +1322,7 @@ rb_obj_field_get(VALUE obj, shape_id_t target_shape_id)
13221322 RUBY_ASSERT (!SPECIAL_CONST_P (obj ));
13231323 RUBY_ASSERT (RSHAPE (target_shape_id )-> type == SHAPE_IVAR || RSHAPE (target_shape_id )-> type == SHAPE_OBJ_ID );
13241324
1325- if (rb_shape_id_too_complex_p (target_shape_id )) {
1325+ if (rb_shape_too_complex_p (target_shape_id )) {
13261326 st_table * fields_hash ;
13271327 switch (BUILTIN_TYPE (obj )) {
13281328 case T_CLASS :
@@ -1386,7 +1386,7 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef)
13861386 VALUE val ;
13871387
13881388 RB_VM_LOCKING () {
1389- if (rb_shape_id_too_complex_p (shape_id )) {
1389+ if (rb_shape_too_complex_p (shape_id )) {
13901390 st_table * iv_table = RCLASS_FIELDS_HASH (obj );
13911391 if (rb_st_lookup (iv_table , (st_data_t )id , (st_data_t * )& val )) {
13921392 found = true;
@@ -1422,7 +1422,7 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef)
14221422 }
14231423 case T_OBJECT :
14241424 {
1425- if (rb_shape_id_too_complex_p (shape_id )) {
1425+ if (rb_shape_too_complex_p (shape_id )) {
14261426 st_table * iv_table = ROBJECT_FIELDS_HASH (obj );
14271427 VALUE val ;
14281428 if (rb_st_lookup (iv_table , (st_data_t )id , (st_data_t * )& val )) {
@@ -1496,7 +1496,7 @@ rb_ivar_delete(VALUE obj, ID id, VALUE undef)
14961496 }
14971497
14981498 shape_id_t old_shape_id = rb_obj_shape_id (obj );
1499- if (rb_shape_id_too_complex_p (old_shape_id )) {
1499+ if (rb_shape_too_complex_p (old_shape_id )) {
15001500 goto too_complex ;
15011501 }
15021502
@@ -1510,7 +1510,7 @@ rb_ivar_delete(VALUE obj, ID id, VALUE undef)
15101510 return undef ;
15111511 }
15121512
1513- if (UNLIKELY (rb_shape_id_too_complex_p (next_shape_id ))) {
1513+ if (UNLIKELY (rb_shape_too_complex_p (next_shape_id ))) {
15141514 rb_evict_fields_to_hash (obj );
15151515 goto too_complex ;
15161516 }
@@ -1714,33 +1714,31 @@ general_ivar_set(VALUE obj, ID id, VALUE val, void *data,
17141714
17151715 shape_id_t current_shape_id = RBASIC_SHAPE_ID (obj );
17161716
1717- if (UNLIKELY (rb_shape_id_too_complex_p (current_shape_id ))) {
1717+ if (UNLIKELY (rb_shape_too_complex_p (current_shape_id ))) {
17181718 goto too_complex ;
17191719 }
17201720
17211721 attr_index_t index ;
17221722 if (!rb_shape_get_iv_index (current_shape_id , id , & index )) {
17231723 result .existing = false;
1724- rb_shape_t * current_shape = RSHAPE (current_shape_id );
17251724
1726- index = current_shape -> next_field_index ;
1725+ index = RSHAPE_LEN ( current_shape_id ) ;
17271726 if (index >= SHAPE_MAX_FIELDS ) {
17281727 rb_raise (rb_eArgError , "too many instance variables" );
17291728 }
17301729
17311730 shape_id_t next_shape_id = rb_shape_transition_add_ivar (obj , id );
1732- rb_shape_t * next_shape = RSHAPE (next_shape_id );
1733- if (UNLIKELY (rb_shape_too_complex_p (next_shape ))) {
1731+ if (UNLIKELY (rb_shape_too_complex_p (next_shape_id ))) {
17341732 transition_too_complex_func (obj , data );
17351733 goto too_complex ;
17361734 }
1737- else if (UNLIKELY (next_shape -> capacity != current_shape -> capacity )) {
1738- RUBY_ASSERT (next_shape -> capacity > current_shape -> capacity );
1739- shape_resize_fields_func (obj , current_shape -> capacity , next_shape -> capacity , data );
1735+ else if (UNLIKELY (RSHAPE_CAPACITY ( next_shape_id ) != RSHAPE_CAPACITY ( current_shape_id ) )) {
1736+ RUBY_ASSERT (RSHAPE_CAPACITY ( next_shape_id ) > RSHAPE_CAPACITY ( current_shape_id ) );
1737+ shape_resize_fields_func (obj , RSHAPE_CAPACITY ( current_shape_id ), RSHAPE_CAPACITY ( next_shape_id ) , data );
17401738 }
17411739
1742- RUBY_ASSERT (next_shape -> type == SHAPE_IVAR );
1743- RUBY_ASSERT (index == (next_shape -> next_field_index - 1 ));
1740+ RUBY_ASSERT (RSHAPE_TYPE_P ( next_shape_id , SHAPE_IVAR ) );
1741+ RUBY_ASSERT (index == (RSHAPE_INDEX ( next_shape_id ) ));
17441742 set_shape_id_func (obj , next_shape_id , data );
17451743 }
17461744
@@ -1772,8 +1770,8 @@ general_field_set(VALUE obj, shape_id_t target_shape_id, VALUE val, void *data,
17721770{
17731771 shape_id_t current_shape_id = RBASIC_SHAPE_ID (obj );
17741772
1775- if (UNLIKELY (rb_shape_id_too_complex_p (target_shape_id ))) {
1776- if (UNLIKELY (!rb_shape_id_too_complex_p (current_shape_id ))) {
1773+ if (UNLIKELY (rb_shape_too_complex_p (target_shape_id ))) {
1774+ if (UNLIKELY (!rb_shape_too_complex_p (current_shape_id ))) {
17771775 transition_too_complex_func (obj , data );
17781776 }
17791777
@@ -2062,7 +2060,7 @@ void rb_obj_freeze_inline(VALUE x)
20622060
20632061 // If we're transitioning from "not complex" to "too complex"
20642062 // then evict ivars. This can happen if we run out of shapes
2065- if (rb_shape_id_too_complex_p (next_shape_id ) && !rb_shape_obj_too_complex_p (x )) {
2063+ if (rb_shape_too_complex_p (next_shape_id ) && !rb_shape_obj_too_complex_p (x )) {
20662064 rb_evict_fields_to_hash (x );
20672065 }
20682066 rb_shape_set_shape_id (x , next_shape_id );
@@ -2257,7 +2255,7 @@ obj_fields_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg, b
22572255 };
22582256
22592257 shape_id_t shape_id = RBASIC_SHAPE_ID (obj );
2260- if (rb_shape_id_too_complex_p (shape_id )) {
2258+ if (rb_shape_too_complex_p (shape_id )) {
22612259 rb_st_foreach (ROBJECT_FIELDS_HASH (obj ), each_hash_iv , (st_data_t )& itr_data );
22622260 }
22632261 else {
@@ -2280,7 +2278,7 @@ gen_fields_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg, b
22802278 };
22812279
22822280 shape_id_t shape_id = RBASIC_SHAPE_ID (obj );
2283- if (rb_shape_id_too_complex_p (shape_id )) {
2281+ if (rb_shape_too_complex_p (shape_id )) {
22842282 rb_st_foreach (fields_tbl -> as .complex .table , each_hash_iv , (st_data_t )& itr_data );
22852283 }
22862284 else {
@@ -2301,7 +2299,7 @@ class_fields_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg,
23012299 };
23022300
23032301 shape_id_t shape_id = RBASIC_SHAPE_ID (obj );
2304- if (rb_shape_id_too_complex_p (shape_id )) {
2302+ if (rb_shape_too_complex_p (shape_id )) {
23052303 rb_st_foreach (RCLASS_WRITABLE_FIELDS_HASH (obj ), each_hash_iv , (st_data_t )& itr_data );
23062304 }
23072305 else {
@@ -2334,7 +2332,7 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
23342332
23352333 FL_SET (dest , FL_EXIVAR );
23362334
2337- if (rb_shape_id_too_complex_p (src_shape_id )) {
2335+ if (rb_shape_too_complex_p (src_shape_id )) {
23382336 rb_shape_copy_complex_ivars (dest , obj , src_shape_id , obj_fields_tbl -> as .complex .table );
23392337 return ;
23402338 }
@@ -2346,7 +2344,7 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
23462344 RUBY_ASSERT (RSHAPE (initial_shape_id )-> type == SHAPE_ROOT );
23472345
23482346 dest_shape_id = rb_shape_rebuild (initial_shape_id , src_shape_id );
2349- if (UNLIKELY (rb_shape_id_too_complex_p (dest_shape_id ))) {
2347+ if (UNLIKELY (rb_shape_too_complex_p (dest_shape_id ))) {
23502348 st_table * table = rb_st_init_numtable_with_size (src_num_ivs );
23512349 rb_obj_copy_ivs_to_hash_table (obj , table );
23522350 rb_obj_init_too_complex (dest , table );
0 commit comments