@@ -1345,12 +1345,12 @@ gen_fields_tbl_count(VALUE obj, const struct gen_fields_tbl *fields_tbl)
13451345}
13461346
13471347VALUE
1348- rb_obj_field_get (VALUE obj , rb_shape_t * target_shape )
1348+ rb_obj_field_get (VALUE obj , shape_id_t target_shape_id )
13491349{
13501350 RUBY_ASSERT (!SPECIAL_CONST_P (obj ));
1351- RUBY_ASSERT (target_shape -> type == SHAPE_IVAR || target_shape -> type == SHAPE_OBJ_ID );
1351+ RUBY_ASSERT (RSHAPE ( target_shape_id ) -> type == SHAPE_IVAR || RSHAPE ( target_shape_id ) -> type == SHAPE_OBJ_ID );
13521352
1353- if (rb_shape_too_complex_p ( target_shape )) {
1353+ if (rb_shape_id_too_complex_p ( target_shape_id )) {
13541354 st_table * fields_hash ;
13551355 switch (BUILTIN_TYPE (obj )) {
13561356 case T_CLASS :
@@ -1370,12 +1370,12 @@ rb_obj_field_get(VALUE obj, rb_shape_t *target_shape)
13701370 break ;
13711371 }
13721372 VALUE value = Qundef ;
1373- st_lookup (fields_hash , target_shape -> edge_name , & value );
1373+ st_lookup (fields_hash , RSHAPE ( target_shape_id ) -> edge_name , & value );
13741374 RUBY_ASSERT (!UNDEF_P (value ));
13751375 return value ;
13761376 }
13771377
1378- attr_index_t attr_index = target_shape -> next_field_index - 1 ;
1378+ attr_index_t attr_index = RSHAPE ( target_shape_id ) -> next_field_index - 1 ;
13791379 VALUE * fields ;
13801380 switch (BUILTIN_TYPE (obj )) {
13811381 case T_CLASS :
@@ -1689,7 +1689,7 @@ static struct general_ivar_set_result
16891689general_ivar_set (VALUE obj , ID id , VALUE val , void * data ,
16901690 VALUE * (* shape_fields_func )(VALUE , void * ),
16911691 void (* shape_resize_fields_func )(VALUE , attr_index_t , attr_index_t , void * ),
1692- void (* set_shape_func )(VALUE , rb_shape_t * , void * ),
1692+ void (* set_shape_id_func )(VALUE , shape_id_t , void * ),
16931693 void (* transition_too_complex_func )(VALUE , void * ),
16941694 st_table * (* too_complex_table_func )(VALUE , void * ))
16951695{
@@ -1726,7 +1726,7 @@ general_ivar_set(VALUE obj, ID id, VALUE val, void *data,
17261726
17271727 RUBY_ASSERT (next_shape -> type == SHAPE_IVAR );
17281728 RUBY_ASSERT (index == (next_shape -> next_field_index - 1 ));
1729- set_shape_func (obj , next_shape , data );
1729+ set_shape_id_func (obj , next_shape_id , data );
17301730 }
17311731
17321732 VALUE * table = shape_fields_func (obj , data );
@@ -1748,34 +1748,36 @@ general_ivar_set(VALUE obj, ID id, VALUE val, void *data,
17481748}
17491749
17501750static void
1751- general_field_set (VALUE obj , rb_shape_t * target_shape , VALUE val , void * data ,
1751+ general_field_set (VALUE obj , shape_id_t target_shape_id , VALUE val , void * data ,
17521752 VALUE * (* shape_fields_func )(VALUE , void * ),
17531753 void (* shape_resize_fields_func )(VALUE , attr_index_t , attr_index_t , void * ),
1754- void (* set_shape_func )(VALUE , rb_shape_t * , void * ),
1754+ void (* set_shape_id_func )(VALUE , shape_id_t , void * ),
17551755 void (* transition_too_complex_func )(VALUE , void * ),
17561756 st_table * (* too_complex_table_func )(VALUE , void * ))
17571757{
17581758 rb_shape_t * current_shape = rb_obj_shape (obj );
17591759
1760- if (UNLIKELY (rb_shape_too_complex_p ( target_shape ))) {
1760+ if (UNLIKELY (rb_shape_id_too_complex_p ( target_shape_id ))) {
17611761 if (UNLIKELY (!rb_shape_too_complex_p (current_shape ))) {
17621762 transition_too_complex_func (obj , data );
17631763 }
17641764
1765- set_shape_func (obj , target_shape , data );
1766-
17671765 st_table * table = too_complex_table_func (obj , data );
1768- st_insert (table , (st_data_t )target_shape -> edge_name , (st_data_t )val );
1766+ if (RSHAPE (target_shape_id )-> next_field_index > current_shape -> next_field_index ) {
1767+ set_shape_id_func (obj , target_shape_id , data );
1768+ }
1769+
1770+ st_insert (table , (st_data_t )RSHAPE (target_shape_id )-> edge_name , (st_data_t )val );
17691771 RB_OBJ_WRITTEN (obj , Qundef , val );
17701772 }
17711773 else {
1772- attr_index_t index = target_shape -> next_field_index - 1 ;
1774+ attr_index_t index = RSHAPE ( target_shape_id ) -> next_field_index - 1 ;
17731775 if (index >= current_shape -> capacity ) {
1774- shape_resize_fields_func (obj , current_shape -> capacity , target_shape -> capacity , data );
1776+ shape_resize_fields_func (obj , current_shape -> capacity , RSHAPE ( target_shape_id ) -> capacity , data );
17751777 }
17761778
1777- if (target_shape -> next_field_index > current_shape -> next_field_index ) {
1778- set_shape_func (obj , target_shape , data );
1779+ if (RSHAPE ( target_shape_id ) -> next_field_index > current_shape -> next_field_index ) {
1780+ set_shape_id_func (obj , target_shape_id , data );
17791781 }
17801782
17811783 VALUE * table = shape_fields_func (obj , data );
@@ -1787,7 +1789,7 @@ struct gen_fields_lookup_ensure_size {
17871789 VALUE obj ;
17881790 ID id ;
17891791 struct gen_fields_tbl * fields_tbl ;
1790- rb_shape_t * shape ;
1792+ shape_id_t shape_id ;
17911793 bool resize ;
17921794};
17931795
@@ -1801,25 +1803,25 @@ generic_fields_lookup_ensure_size(st_data_t *k, st_data_t *v, st_data_t u, int e
18011803
18021804 if (!existing || fields_lookup -> resize ) {
18031805 if (existing ) {
1804- RUBY_ASSERT (fields_lookup -> shape -> type == SHAPE_IVAR || fields_lookup -> shape -> type == SHAPE_OBJ_ID );
1805- RUBY_ASSERT (RSHAPE (fields_lookup -> shape -> parent_id )-> capacity < fields_lookup -> shape -> capacity );
1806+ RUBY_ASSERT (RSHAPE ( fields_lookup -> shape_id ) -> type == SHAPE_IVAR || RSHAPE ( fields_lookup -> shape_id ) -> type == SHAPE_OBJ_ID );
1807+ RUBY_ASSERT (RSHAPE (RSHAPE ( fields_lookup -> shape_id ) -> parent_id )-> capacity < RSHAPE ( fields_lookup -> shape_id ) -> capacity );
18061808 }
18071809 else {
18081810 FL_SET_RAW ((VALUE )* k , FL_EXIVAR );
18091811 }
18101812
1811- fields_tbl = gen_fields_tbl_resize (fields_tbl , fields_lookup -> shape -> capacity );
1813+ fields_tbl = gen_fields_tbl_resize (fields_tbl , RSHAPE ( fields_lookup -> shape_id ) -> capacity );
18121814 * v = (st_data_t )fields_tbl ;
18131815 }
18141816
18151817 RUBY_ASSERT (FL_TEST ((VALUE )* k , FL_EXIVAR ));
18161818
18171819 fields_lookup -> fields_tbl = fields_tbl ;
1818- if (fields_lookup -> shape ) {
1820+ if (fields_lookup -> shape_id ) {
18191821#if SHAPE_IN_BASIC_FLAGS
1820- rb_shape_set_shape (fields_lookup -> obj , fields_lookup -> shape );
1822+ rb_shape_set_shape_id (fields_lookup -> obj , fields_lookup -> shape_id );
18211823#else
1822- fields_tbl -> shape_id = rb_shape_id ( fields_lookup -> shape ) ;
1824+ fields_tbl -> shape_id = fields_lookup -> shape_id ;
18231825#endif
18241826 }
18251827
@@ -1853,11 +1855,11 @@ generic_ivar_set_shape_resize_fields(VALUE obj, attr_index_t _old_capa, attr_ind
18531855}
18541856
18551857static void
1856- generic_ivar_set_set_shape (VALUE obj , rb_shape_t * shape , void * data )
1858+ generic_ivar_set_set_shape_id (VALUE obj , shape_id_t shape_id , void * data )
18571859{
18581860 struct gen_fields_lookup_ensure_size * fields_lookup = data ;
18591861
1860- fields_lookup -> shape = shape ;
1862+ fields_lookup -> shape_id = shape_id ;
18611863}
18621864
18631865static void
@@ -1901,30 +1903,28 @@ generic_ivar_set(VALUE obj, ID id, VALUE val)
19011903 .obj = obj ,
19021904 .id = id ,
19031905 .resize = false,
1904- .shape = NULL ,
19051906 };
19061907
19071908 general_ivar_set (obj , id , val , & fields_lookup ,
19081909 generic_ivar_set_shape_fields ,
19091910 generic_ivar_set_shape_resize_fields ,
1910- generic_ivar_set_set_shape ,
1911+ generic_ivar_set_set_shape_id ,
19111912 generic_ivar_set_transition_too_complex ,
19121913 generic_ivar_set_too_complex_table );
19131914}
19141915
19151916static void
1916- generic_field_set (VALUE obj , rb_shape_t * target_shape , VALUE val )
1917+ generic_field_set (VALUE obj , shape_id_t target_shape_id , VALUE val )
19171918{
19181919 struct gen_fields_lookup_ensure_size fields_lookup = {
19191920 .obj = obj ,
19201921 .resize = false,
1921- .shape = NULL ,
19221922 };
19231923
1924- general_field_set (obj , target_shape , val , & fields_lookup ,
1924+ general_field_set (obj , target_shape_id , val , & fields_lookup ,
19251925 generic_ivar_set_shape_fields ,
19261926 generic_ivar_set_shape_resize_fields ,
1927- generic_ivar_set_set_shape ,
1927+ generic_ivar_set_set_shape_id ,
19281928 generic_ivar_set_transition_too_complex ,
19291929 generic_ivar_set_too_complex_table );
19301930}
@@ -1982,9 +1982,9 @@ obj_ivar_set_shape_resize_fields(VALUE obj, attr_index_t old_capa, attr_index_t
19821982}
19831983
19841984static void
1985- obj_ivar_set_set_shape (VALUE obj , rb_shape_t * shape , void * _data )
1985+ obj_ivar_set_set_shape_id (VALUE obj , shape_id_t shape_id , void * _data )
19861986{
1987- rb_shape_set_shape (obj , shape );
1987+ rb_shape_set_shape_id (obj , shape_id );
19881988}
19891989
19901990static void
@@ -2007,18 +2007,18 @@ rb_obj_ivar_set(VALUE obj, ID id, VALUE val)
20072007 return general_ivar_set (obj , id , val , NULL ,
20082008 obj_ivar_set_shape_fields ,
20092009 obj_ivar_set_shape_resize_fields ,
2010- obj_ivar_set_set_shape ,
2010+ obj_ivar_set_set_shape_id ,
20112011 obj_ivar_set_transition_too_complex ,
20122012 obj_ivar_set_too_complex_table ).index ;
20132013}
20142014
20152015static void
2016- obj_field_set (VALUE obj , rb_shape_t * target_shape , VALUE val )
2016+ obj_field_set (VALUE obj , shape_id_t target_shape_id , VALUE val )
20172017{
2018- general_field_set (obj , target_shape , val , NULL ,
2018+ general_field_set (obj , target_shape_id , val , NULL ,
20192019 obj_ivar_set_shape_fields ,
20202020 obj_ivar_set_shape_resize_fields ,
2021- obj_ivar_set_set_shape ,
2021+ obj_ivar_set_set_shape_id ,
20222022 obj_ivar_set_transition_too_complex ,
20232023 obj_ivar_set_too_complex_table );
20242024}
@@ -2138,22 +2138,22 @@ rb_ivar_set_internal(VALUE obj, ID id, VALUE val)
21382138 ivar_set (obj , id , val );
21392139}
21402140
2141- static void class_field_set (VALUE obj , rb_shape_t * target_shape , VALUE val );
2141+ static void class_field_set (VALUE obj , shape_id_t target_shape_id , VALUE val );
21422142
21432143void
2144- rb_obj_field_set (VALUE obj , rb_shape_t * target_shape , VALUE val )
2144+ rb_obj_field_set (VALUE obj , shape_id_t target_shape_id , VALUE val )
21452145{
21462146 switch (BUILTIN_TYPE (obj )) {
21472147 case T_OBJECT :
2148- obj_field_set (obj , target_shape , val );
2148+ obj_field_set (obj , target_shape_id , val );
21492149 break ;
21502150 case T_CLASS :
21512151 case T_MODULE :
21522152 ASSERT_vm_locking ();
2153- class_field_set (obj , target_shape , val );
2153+ class_field_set (obj , target_shape_id , val );
21542154 break ;
21552155 default :
2156- generic_field_set (obj , target_shape , val );
2156+ generic_field_set (obj , target_shape_id , val );
21572157 break ;
21582158 }
21592159}
@@ -4739,9 +4739,9 @@ class_ivar_set_shape_resize_fields(VALUE obj, attr_index_t _old_capa, attr_index
47394739}
47404740
47414741static void
4742- class_ivar_set_set_shape (VALUE obj , rb_shape_t * shape , void * _data )
4742+ class_ivar_set_set_shape_id (VALUE obj , shape_id_t shape_id , void * _data )
47434743{
4744- rb_shape_set_shape (obj , shape );
4744+ rb_shape_set_shape_id (obj , shape_id );
47454745}
47464746
47474747static void
@@ -4772,7 +4772,7 @@ rb_class_ivar_set(VALUE obj, ID id, VALUE val)
47724772 existing = general_ivar_set (obj , id , val , NULL ,
47734773 class_ivar_set_shape_fields ,
47744774 class_ivar_set_shape_resize_fields ,
4775- class_ivar_set_set_shape ,
4775+ class_ivar_set_set_shape_id ,
47764776 class_ivar_set_transition_too_complex ,
47774777 class_ivar_set_too_complex_table ).existing ;
47784778 }
@@ -4782,13 +4782,13 @@ rb_class_ivar_set(VALUE obj, ID id, VALUE val)
47824782}
47834783
47844784static void
4785- class_field_set (VALUE obj , rb_shape_t * target_shape , VALUE val )
4785+ class_field_set (VALUE obj , shape_id_t target_shape_id , VALUE val )
47864786{
47874787 RUBY_ASSERT (RB_TYPE_P (obj , T_CLASS ) || RB_TYPE_P (obj , T_MODULE ));
4788- general_field_set (obj , target_shape , val , NULL ,
4788+ general_field_set (obj , target_shape_id , val , NULL ,
47894789 class_ivar_set_shape_fields ,
47904790 class_ivar_set_shape_resize_fields ,
4791- class_ivar_set_set_shape ,
4791+ class_ivar_set_set_shape_id ,
47924792 class_ivar_set_transition_too_complex ,
47934793 class_ivar_set_too_complex_table );
47944794}
0 commit comments