aboutsummaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2020-11-09 11:20:29 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2020-11-09 14:05:41 -0800
commitf259906eabac6038bb7c79e426c17ae850c8e017 (patch)
tree37fb06596e81816d3d5dab5bf5e3a84d4f88c042 /vm_insnhelper.c
parent6778ba48fddcab1bca56b9bccc7ea5f9583baba8 (diff)
downloadruby-f259906eabac6038bb7c79e426c17ae850c8e017.tar.gz
Avoid slow path ivar setting
If the ivar index table exists, we can avoid the slowest path for setting ivars.
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 398bbd741e..ea25de629f 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1237,6 +1237,17 @@ vm_setivar(VALUE obj, ID id, VALUE val, const rb_iseq_t *iseq, IVC ic, const str
else {
vm_cc_attr_index_set(cc, (int)(ent->index + 1));
}
+
+ index = ent->index;
+
+ VALUE *ptr = ROBJECT_IVPTR(obj);
+ if (index >= ROBJECT_NUMIV(obj)) {
+ rb_init_iv_list(obj, ROBJECT_NUMIV(obj), (uint32_t)iv_index_tbl->num_entries, iv_index_tbl);
+ ptr = ROBJECT_IVPTR(obj);
+ }
+ RB_OBJ_WRITE(obj, &ptr[index], val);
+
+ return val;
}
/* fall through */
}