diff options
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r-- | vm_insnhelper.c | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 24709eee2e..2fe5e26928 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1213,9 +1213,10 @@ ALWAYS_INLINE(static VALUE vm_getivar(VALUE, ID, const rb_iseq_t *, IVC, const s static inline VALUE vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_callcache *cc, int is_attr, VALUE default_value) { + VALUE fields_obj; #if OPT_IC_FOR_IVAR VALUE val = Qundef; - VALUE * ivar_list; + VALUE *ivar_list; if (SPECIAL_CONST_P(obj)) { return default_value; @@ -1247,14 +1248,22 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call } } - ivar_list = RCLASS_PRIME_FIELDS(obj); + fields_obj = RCLASS_WRITABLE_FIELDS_OBJ(obj); + if (!fields_obj) { + return default_value; + } + ivar_list = rb_imemo_fields_ptr(fields_obj); + shape_id = RBASIC_SHAPE_ID_FOR_READ(fields_obj); + break; } default: - if (FL_TEST_RAW(obj, FL_EXIVAR)) { - struct gen_fields_tbl *fields_tbl; - rb_gen_fields_tbl_get(obj, id, &fields_tbl); - ivar_list = fields_tbl->as.shape.fields; + if (rb_obj_exivar_p(obj)) { + VALUE fields_obj = 0; + if (!rb_gen_fields_tbl_get(obj, id, &fields_obj)) { + return default_value; + } + ivar_list = rb_imemo_fields_ptr(fields_obj); } else { return default_value; @@ -1318,7 +1327,7 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call switch (BUILTIN_TYPE(obj)) { case T_CLASS: case T_MODULE: - table = (st_table *)RCLASS_FIELDS_HASH(obj); + table = rb_imemo_fields_complex_tbl(fields_obj); break; case T_OBJECT: @@ -1326,9 +1335,9 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call break; default: { - struct gen_fields_tbl *fields_tbl; - if (rb_gen_fields_tbl_get(obj, 0, &fields_tbl)) { - table = fields_tbl->as.complex.table; + VALUE fields_obj; + if (rb_gen_fields_tbl_get(obj, 0, &fields_obj)) { + table = rb_imemo_fields_complex_tbl(fields_obj); } break; } @@ -1374,6 +1383,7 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call RUBY_ASSERT(!UNDEF_P(val)); } + RB_GC_GUARD(fields_obj); return val; general_path: @@ -1448,16 +1458,14 @@ vm_setivar_default(VALUE obj, ID id, VALUE val, shape_id_t dest_shape_id, attr_i { shape_id_t shape_id = RBASIC_SHAPE_ID(obj); - struct gen_fields_tbl *fields_tbl = 0; + VALUE fields_obj = 0; // Cache hit case if (shape_id == dest_shape_id) { RUBY_ASSERT(dest_shape_id != INVALID_SHAPE_ID && shape_id != INVALID_SHAPE_ID); } else if (dest_shape_id != INVALID_SHAPE_ID) { - rb_shape_t *dest_shape = RSHAPE(dest_shape_id); - - if (shape_id == dest_shape->parent_id && dest_shape->edge_name == id && RSHAPE_CAPACITY(shape_id) == RSHAPE_CAPACITY(dest_shape_id)) { + if (shape_id == RSHAPE_PARENT(dest_shape_id) && RSHAPE_EDGE_NAME(dest_shape_id) == id && RSHAPE_CAPACITY(shape_id) == RSHAPE_CAPACITY(dest_shape_id)) { RUBY_ASSERT(index < RSHAPE_CAPACITY(dest_shape_id)); } else { @@ -1468,13 +1476,13 @@ vm_setivar_default(VALUE obj, ID id, VALUE val, shape_id_t dest_shape_id, attr_i return Qundef; } - rb_gen_fields_tbl_get(obj, 0, &fields_tbl); + rb_gen_fields_tbl_get(obj, 0, &fields_obj); if (shape_id != dest_shape_id) { RBASIC_SET_SHAPE_ID(obj, dest_shape_id); } - RB_OBJ_WRITE(obj, &fields_tbl->as.shape.fields[index], val); + RB_OBJ_WRITE(obj, &rb_imemo_fields_ptr(fields_obj)[index], val); RB_DEBUG_COUNTER_INC(ivar_set_ic_hit); @@ -1498,10 +1506,9 @@ vm_setivar(VALUE obj, ID id, VALUE val, shape_id_t dest_shape_id, attr_index_t i VM_ASSERT(!rb_ractor_shareable_p(obj)); } else if (dest_shape_id != INVALID_SHAPE_ID) { - rb_shape_t *dest_shape = RSHAPE(dest_shape_id); - shape_id_t source_shape_id = dest_shape->parent_id; + shape_id_t source_shape_id = RSHAPE_PARENT(dest_shape_id); - if (shape_id == source_shape_id && dest_shape->edge_name == id && RSHAPE_CAPACITY(shape_id) == RSHAPE_CAPACITY(dest_shape_id)) { + if (shape_id == source_shape_id && RSHAPE_EDGE_NAME(dest_shape_id) == id && RSHAPE_CAPACITY(shape_id) == RSHAPE_CAPACITY(dest_shape_id)) { RUBY_ASSERT(dest_shape_id != INVALID_SHAPE_ID && shape_id != INVALID_SHAPE_ID); RBASIC_SET_SHAPE_ID(obj, dest_shape_id); @@ -5550,6 +5557,14 @@ vm_get_special_object(const VALUE *const reg_ep, } } +// ZJIT implementation is using the C function +// and needs to call a non-static function +VALUE +rb_vm_get_special_object(const VALUE *reg_ep, enum vm_special_object_type type) +{ + return vm_get_special_object(reg_ep, type); +} + static VALUE vm_concat_array(VALUE ary1, VALUE ary2st) { |