summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2022-06-06 10:48:42 -0400
committerAaron Patterson <aaron.patterson@gmail.com>2022-07-18 12:44:01 -0700
commitecff3349953e17491630ef7b68c5ac6b095d39bf (patch)
tree084ea5e0c33bd4597d09ae9e45cae791513c8049 /vm_insnhelper.c
parentf240e28dfe373bee30a170fd78d11cc5d71ef945 (diff)
Extract vm_ic_entry API to mimic vm_cc behavior
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5978
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 8db11be5e5..5a77484b74 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1104,8 +1104,7 @@ fill_ivar_cache(const rb_iseq_t *iseq, IVC ic, const struct rb_callcache *cc, in
{
// fill cache
if (!is_attr) {
- ic->entry = ent;
- RB_OBJ_WRITTEN(iseq, Qundef, ent->class_value);
+ vm_ic_entry_set(ic, ent, iseq);
}
else {
vm_cc_attr_index_set(cc, ent->index);
@@ -1124,9 +1123,8 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call
}
else if (LIKELY(is_attr ?
RB_DEBUG_COUNTER_INC_UNLESS(ivar_get_ic_miss_unset, vm_cc_attr_index_p(cc)) :
- RB_DEBUG_COUNTER_INC_UNLESS(ivar_get_ic_miss_serial,
- ic->entry && ic->entry->class_serial == RCLASS_SERIAL(RBASIC(obj)->klass)))) {
- uint32_t index = !is_attr ? ic->entry->index: (vm_cc_attr_index(cc));
+ RB_DEBUG_COUNTER_INC_UNLESS(ivar_get_ic_miss_serial, vm_ic_entry_p(ic) && ic->entry->class_serial == RCLASS_SERIAL(RBASIC(obj)->klass)))) {
+ uint32_t index = !is_attr ? vm_ic_entry_index(ic): (vm_cc_attr_index(cc));
RB_DEBUG_COUNTER_INC(ivar_get_ic_hit);
@@ -1208,8 +1206,7 @@ vm_setivar_slowpath(VALUE obj, ID id, VALUE val, const rb_iseq_t *iseq, IVC ic,
if (iv_index_tbl_lookup(iv_index_tbl, id, &ent)) {
if (!is_attr) {
- ic->entry = ent;
- RB_OBJ_WRITTEN(iseq, Qundef, ent->class_value);
+ vm_ic_entry_set(ic, ent, iseq);
}
else if (ent->index >= INT_MAX) {
rb_raise(rb_eArgError, "too many instance variables");
@@ -1257,9 +1254,9 @@ vm_setivar(VALUE obj, ID id, VALUE val, const rb_iseq_t *iseq, IVC ic, const str
VM_ASSERT(!rb_ractor_shareable_p(obj));
if (LIKELY(
- (!is_attr && RB_DEBUG_COUNTER_INC_UNLESS(ivar_set_ic_miss_serial, ic->entry && ic->entry->class_serial == RCLASS_SERIAL(RBASIC(obj)->klass))) ||
+ (!is_attr && RB_DEBUG_COUNTER_INC_UNLESS(ivar_set_ic_miss_serial, vm_ic_entry_p(ic) && ic->entry->class_serial == RCLASS_SERIAL(RBASIC(obj)->klass))) ||
( is_attr && RB_DEBUG_COUNTER_INC_UNLESS(ivar_set_ic_miss_unset, vm_cc_attr_index_p(cc))))) {
- uint32_t index = !is_attr ? ic->entry->index : vm_cc_attr_index(cc);
+ uint32_t index = !is_attr ? vm_ic_entry_index(ic) : vm_cc_attr_index(cc);
if (UNLIKELY(index >= ROBJECT_NUMIV(obj))) {
rb_init_iv_list(obj);