summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2023-02-14 14:41:23 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2023-02-15 08:47:26 -0800
commitae2340c9d793e00000186a461a37596b09268370 (patch)
tree1d9456baa481d028d8132e82ab396f69d410a429 /vm_insnhelper.c
parent847a0df058a4adb60266213cb8db7bb537c1d09e (diff)
downloadruby-ae2340c9d793e00000186a461a37596b09268370.tar.gz
Refactor / document instance variable debug counters
This commit is refactoring and documenting the debug counters related to instance variables.
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 79247c277b..e7571020dd 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1231,10 +1231,17 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call
}
val = ivar_list[index];
+#if USE_DEBUG_COUNTER
+ RB_DEBUG_COUNTER_INC(ivar_get_ic_hit);
+
+ if (RB_TYPE_P(obj, T_OBJECT)) {
+ RB_DEBUG_COUNTER_INC(ivar_get_obj_hit);
+ }
+#endif
RUBY_ASSERT(!UNDEF_P(val));
}
else { // cache miss case
-#if RUBY_DEBUG
+#if USE_DEBUG_COUNTER
if (is_attr) {
if (cached_id != INVALID_SHAPE_ID) {
RB_DEBUG_COUNTER_INC(ivar_get_cc_miss_set);
@@ -1251,6 +1258,11 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call
RB_DEBUG_COUNTER_INC(ivar_get_ic_miss_unset);
}
}
+ RB_DEBUG_COUNTER_INC(ivar_get_ic_miss);
+
+ if (RB_TYPE_P(obj, T_OBJECT)) {
+ RB_DEBUG_COUNTER_INC(ivar_get_obj_miss);
+ }
#endif
rb_shape_t *shape = rb_shape_get_shape_by_id(shape_id);
@@ -1322,6 +1334,8 @@ static VALUE
vm_setivar_slowpath(VALUE obj, ID id, VALUE val, const rb_iseq_t *iseq, IVC ic, const struct rb_callcache *cc, int is_attr)
{
#if OPT_IC_FOR_IVAR
+ RB_DEBUG_COUNTER_INC(ivar_set_ic_miss);
+
switch (BUILTIN_TYPE(obj)) {
case T_OBJECT:
{
@@ -1335,7 +1349,7 @@ vm_setivar_slowpath(VALUE obj, ID id, VALUE val, const rb_iseq_t *iseq, IVC ic,
populate_cache(index, next_shape_id, id, iseq, ic, cc, is_attr);
}
- RB_DEBUG_COUNTER_INC(ivar_set_ic_miss_iv_hit);
+ RB_DEBUG_COUNTER_INC(ivar_set_obj_miss);
return val;
}
case T_CLASS:
@@ -1363,7 +1377,6 @@ vm_setivar_slowpath(VALUE obj, ID id, VALUE val, const rb_iseq_t *iseq, IVC ic,
}
}
#endif
- RB_DEBUG_COUNTER_INC(ivar_set_ic_miss);
return rb_ivar_set(obj, id, val);
}
@@ -1469,6 +1482,7 @@ vm_setivar(VALUE obj, ID id, VALUE val, shape_id_t dest_shape_id, attr_index_t i
RB_OBJ_WRITE(obj, &ptr[index], val);
RB_DEBUG_COUNTER_INC(ivar_set_ic_hit);
+ RB_DEBUG_COUNTER_INC(ivar_set_obj_hit);
return val;
}
break;