@@ -1322,7 +1322,7 @@ rb_obj_field_get(VALUE obj, shape_id_t target_shape_id)
1322
1322
RUBY_ASSERT (!SPECIAL_CONST_P (obj ));
1323
1323
RUBY_ASSERT (RSHAPE (target_shape_id )-> type == SHAPE_IVAR || RSHAPE (target_shape_id )-> type == SHAPE_OBJ_ID );
1324
1324
1325
- if (rb_shape_id_too_complex_p (target_shape_id )) {
1325
+ if (rb_shape_too_complex_p (target_shape_id )) {
1326
1326
st_table * fields_hash ;
1327
1327
switch (BUILTIN_TYPE (obj )) {
1328
1328
case T_CLASS :
@@ -1386,7 +1386,7 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef)
1386
1386
VALUE val ;
1387
1387
1388
1388
RB_VM_LOCKING () {
1389
- if (rb_shape_id_too_complex_p (shape_id )) {
1389
+ if (rb_shape_too_complex_p (shape_id )) {
1390
1390
st_table * iv_table = RCLASS_FIELDS_HASH (obj );
1391
1391
if (rb_st_lookup (iv_table , (st_data_t )id , (st_data_t * )& val )) {
1392
1392
found = true;
@@ -1422,7 +1422,7 @@ rb_ivar_lookup(VALUE obj, ID id, VALUE undef)
1422
1422
}
1423
1423
case T_OBJECT :
1424
1424
{
1425
- if (rb_shape_id_too_complex_p (shape_id )) {
1425
+ if (rb_shape_too_complex_p (shape_id )) {
1426
1426
st_table * iv_table = ROBJECT_FIELDS_HASH (obj );
1427
1427
VALUE val ;
1428
1428
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)
1496
1496
}
1497
1497
1498
1498
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 )) {
1500
1500
goto too_complex ;
1501
1501
}
1502
1502
@@ -1510,7 +1510,7 @@ rb_ivar_delete(VALUE obj, ID id, VALUE undef)
1510
1510
return undef ;
1511
1511
}
1512
1512
1513
- if (UNLIKELY (rb_shape_id_too_complex_p (next_shape_id ))) {
1513
+ if (UNLIKELY (rb_shape_too_complex_p (next_shape_id ))) {
1514
1514
rb_evict_fields_to_hash (obj );
1515
1515
goto too_complex ;
1516
1516
}
@@ -1714,33 +1714,31 @@ general_ivar_set(VALUE obj, ID id, VALUE val, void *data,
1714
1714
1715
1715
shape_id_t current_shape_id = RBASIC_SHAPE_ID (obj );
1716
1716
1717
- if (UNLIKELY (rb_shape_id_too_complex_p (current_shape_id ))) {
1717
+ if (UNLIKELY (rb_shape_too_complex_p (current_shape_id ))) {
1718
1718
goto too_complex ;
1719
1719
}
1720
1720
1721
1721
attr_index_t index ;
1722
1722
if (!rb_shape_get_iv_index (current_shape_id , id , & index )) {
1723
1723
result .existing = false;
1724
- rb_shape_t * current_shape = RSHAPE (current_shape_id );
1725
1724
1726
- index = current_shape -> next_field_index ;
1725
+ index = RSHAPE_LEN ( current_shape_id ) ;
1727
1726
if (index >= SHAPE_MAX_FIELDS ) {
1728
1727
rb_raise (rb_eArgError , "too many instance variables" );
1729
1728
}
1730
1729
1731
1730
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 ))) {
1734
1732
transition_too_complex_func (obj , data );
1735
1733
goto too_complex ;
1736
1734
}
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 );
1740
1738
}
1741
1739
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 ) ));
1744
1742
set_shape_id_func (obj , next_shape_id , data );
1745
1743
}
1746
1744
@@ -1772,8 +1770,8 @@ general_field_set(VALUE obj, shape_id_t target_shape_id, VALUE val, void *data,
1772
1770
{
1773
1771
shape_id_t current_shape_id = RBASIC_SHAPE_ID (obj );
1774
1772
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 ))) {
1777
1775
transition_too_complex_func (obj , data );
1778
1776
}
1779
1777
@@ -2062,7 +2060,7 @@ void rb_obj_freeze_inline(VALUE x)
2062
2060
2063
2061
// If we're transitioning from "not complex" to "too complex"
2064
2062
// 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 )) {
2066
2064
rb_evict_fields_to_hash (x );
2067
2065
}
2068
2066
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
2257
2255
};
2258
2256
2259
2257
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 )) {
2261
2259
rb_st_foreach (ROBJECT_FIELDS_HASH (obj ), each_hash_iv , (st_data_t )& itr_data );
2262
2260
}
2263
2261
else {
@@ -2280,7 +2278,7 @@ gen_fields_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg, b
2280
2278
};
2281
2279
2282
2280
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 )) {
2284
2282
rb_st_foreach (fields_tbl -> as .complex .table , each_hash_iv , (st_data_t )& itr_data );
2285
2283
}
2286
2284
else {
@@ -2301,7 +2299,7 @@ class_fields_each(VALUE obj, rb_ivar_foreach_callback_func *func, st_data_t arg,
2301
2299
};
2302
2300
2303
2301
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 )) {
2305
2303
rb_st_foreach (RCLASS_WRITABLE_FIELDS_HASH (obj ), each_hash_iv , (st_data_t )& itr_data );
2306
2304
}
2307
2305
else {
@@ -2334,7 +2332,7 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
2334
2332
2335
2333
FL_SET (dest , FL_EXIVAR );
2336
2334
2337
- if (rb_shape_id_too_complex_p (src_shape_id )) {
2335
+ if (rb_shape_too_complex_p (src_shape_id )) {
2338
2336
rb_shape_copy_complex_ivars (dest , obj , src_shape_id , obj_fields_tbl -> as .complex .table );
2339
2337
return ;
2340
2338
}
@@ -2346,7 +2344,7 @@ rb_copy_generic_ivar(VALUE dest, VALUE obj)
2346
2344
RUBY_ASSERT (RSHAPE (initial_shape_id )-> type == SHAPE_ROOT );
2347
2345
2348
2346
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 ))) {
2350
2348
st_table * table = rb_st_init_numtable_with_size (src_num_ivs );
2351
2349
rb_obj_copy_ivs_to_hash_table (obj , table );
2352
2350
rb_obj_init_too_complex (dest , table );
0 commit comments