summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2022-10-15 09:37:44 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2022-10-15 10:44:10 -0700
commitf0654b1027d2f24cbb6e3cfb0c5946b70f06739b (patch)
treee49476db3318c77362e7ad21433df7832f0ede95 /vm_insnhelper.c
parent8d20632df849833d8a98f3d6f5e61f32eefa0fa6 (diff)
More precisely iterate over Object instance variables
Shapes provides us with an (almost) exact count of instance variables. We only need to check for Qundef when an IV has been "undefined" Prefer to use ROBJECT_IV_COUNT when iterating IVs
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6555
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 3f1337c36c..8b19c6c10d 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1268,8 +1268,7 @@ vm_setivar_slowpath(VALUE obj, ID id, VALUE val, const rb_iseq_t *iseq, IVC ic,
if (shape != next_shape) {
RUBY_ASSERT(next_shape->parent_id == rb_shape_id(shape));
- rb_shape_set_shape(obj, next_shape);
- next_shape_id = ROBJECT_SHAPE_ID(obj);
+ next_shape_id = rb_shape_id(next_shape);
}
if (rb_shape_get_iv_index(next_shape, id, &index)) { // based off the hash stored in the transition tree
@@ -1289,6 +1288,9 @@ vm_setivar_slowpath(VALUE obj, ID id, VALUE val, const rb_iseq_t *iseq, IVC ic,
rb_init_iv_list(obj);
}
+ if (shape != next_shape) {
+ rb_shape_set_shape(obj, next_shape);
+ }
VALUE *ptr = ROBJECT_IVPTR(obj);
RB_OBJ_WRITE(obj, &ptr[index], val);
RB_DEBUG_COUNTER_INC(ivar_set_ic_miss_iv_hit);