summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 24709eee2e..7efcdba8a4 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,11 +1248,17 @@ 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_class_fields_ptr(fields_obj);
+ shape_id = rb_obj_shape_id(fields_obj);
+
break;
}
default:
- if (FL_TEST_RAW(obj, FL_EXIVAR)) {
+ if (rb_obj_exivar_p(obj)) {
struct gen_fields_tbl *fields_tbl;
rb_gen_fields_tbl_get(obj, id, &fields_tbl);
ivar_list = fields_tbl->as.shape.fields;
@@ -1318,7 +1325,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_class_fields_complex_tbl(fields_obj);
break;
case T_OBJECT:
@@ -1374,6 +1381,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:
@@ -1455,9 +1463,7 @@ vm_setivar_default(VALUE obj, ID id, VALUE val, shape_id_t dest_shape_id, attr_i
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 {
@@ -1498,10 +1504,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);