summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2022-01-25 16:04:17 -0500
committerAaron Patterson <aaron.patterson@gmail.com>2022-01-26 09:02:59 -0800
commit1a180b7e18a2d415282df637e27a446c71246ef7 (patch)
tree5aee0a8491ba2736379924d87b6ecfbfa3892717 /vm_insnhelper.c
parent3ce97a182f4310121e86dccf9fcd3ee3cb088107 (diff)
Streamline cached attr reader / writer indexes
This commit removes the need to increment and decrement the indexes used by vm_cc_attr_index getters and setters. It also introduces a vm_cc_attr_index_p predicate function, and a vm_cc_attr_index_initalize function.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5485
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 271b347d3b..27d9d13aac 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1108,7 +1108,7 @@ fill_ivar_cache(const rb_iseq_t *iseq, IVC ic, const struct rb_callcache *cc, in
RB_OBJ_WRITTEN(iseq, Qundef, ent->class_value);
}
else {
- vm_cc_attr_index_set(cc, (int)ent->index + 1);
+ vm_cc_attr_index_set(cc, ent->index);
}
}
@@ -1123,10 +1123,10 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call
// frozen?
}
else if (LIKELY(is_attr ?
- RB_DEBUG_COUNTER_INC_UNLESS(ivar_get_ic_miss_unset, vm_cc_attr_index(cc) > 0) :
+ 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) - 1);
+ uint32_t index = !is_attr ? ic->entry->index: (vm_cc_attr_index(cc));
RB_DEBUG_COUNTER_INC(ivar_get_ic_hit);
@@ -1215,7 +1215,7 @@ vm_setivar_slowpath(VALUE obj, ID id, VALUE val, const rb_iseq_t *iseq, IVC ic,
rb_raise(rb_eArgError, "too many instance variables");
}
else {
- vm_cc_attr_index_set(cc, (int)(ent->index + 1));
+ vm_cc_attr_index_set(cc, (int)(ent->index));
}
uint32_t index = ent->index;
@@ -1258,8 +1258,8 @@ vm_setivar(VALUE obj, ID id, VALUE val, const rb_iseq_t *iseq, IVC ic, const str
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_unset, vm_cc_attr_index(cc) > 0)))) {
- uint32_t index = !is_attr ? ic->entry->index : vm_cc_attr_index(cc)-1;
+ ( 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);
if (UNLIKELY(index >= ROBJECT_NUMIV(obj))) {
rb_init_iv_list(obj);
@@ -3643,7 +3643,7 @@ vm_call_method_each_type(rb_execution_context_t *ec, rb_control_frame_t *cfp, st
CALLER_REMOVE_EMPTY_KW_SPLAT(cfp, calling, ci);
rb_check_arity(calling->argc, 1, 1);
- vm_cc_attr_index_set(cc, 0);
+ vm_cc_attr_index_initialize(cc);
const unsigned int aset_mask = (VM_CALL_ARGS_SPLAT | VM_CALL_KW_SPLAT | VM_CALL_KWARG);
VM_CALL_METHOD_ATTR(v,
vm_call_attrset(ec, cfp, calling),
@@ -3654,7 +3654,7 @@ vm_call_method_each_type(rb_execution_context_t *ec, rb_control_frame_t *cfp, st
CALLER_SETUP_ARG(cfp, calling, ci);
CALLER_REMOVE_EMPTY_KW_SPLAT(cfp, calling, ci);
rb_check_arity(calling->argc, 0, 0);
- vm_cc_attr_index_set(cc, 0);
+ vm_cc_attr_index_initialize(cc);
const unsigned int ivar_mask = (VM_CALL_ARGS_SPLAT | VM_CALL_KW_SPLAT);
VM_CALL_METHOD_ATTR(v,
vm_call_ivar(ec, cfp, calling),