summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-06-05 10:14:06 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-09 09:52:46 +0900
commit3928c151a63b273ff10feb43906d6590c6592d1a (patch)
tree9dc2fa5acd1d8fc19f127220aaa611974f32136e /vm_insnhelper.c
parent877238f2d3522381f184d44b308f6e3b68367c56 (diff)
vm_search_method_fastpath: avoid rb_vm_empty_cc()
This is such a hot path that it's worth eliminating a function call. Use the static variable directly instead.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3179
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 0774217507..25b5db8a51 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -36,6 +36,10 @@ extern int rb_method_definition_eq(const rb_method_definition_t *d1, const rb_me
extern VALUE rb_make_no_method_exception(VALUE exc, VALUE format, VALUE obj,
int argc, const VALUE *argv, int priv);
+#ifndef MJIT_HEADER
+static const struct rb_callcache *vm_empty_cc;
+#endif
+
/* control stack frame */
static rb_control_frame_t *vm_get_ruby_level_caller_cfp(const rb_execution_context_t *ec, const rb_control_frame_t *cfp);
@@ -1567,8 +1571,8 @@ vm_search_cc(VALUE klass, const struct rb_callinfo *ci)
if (cme == NULL) {
// undef or not found: can't cache the information
- VM_ASSERT(vm_cc_cme(vm_cc_empty()) == NULL);
- return vm_cc_empty();
+ VM_ASSERT(vm_cc_cme(vm_empty_cc) == NULL);
+ return vm_empty_cc;
}
else {
const struct rb_callcache *cc = vm_cc_new(klass, cme, vm_call_general);
@@ -1628,7 +1632,12 @@ vm_search_method_fastpath(VALUE cd_owner, struct rb_call_data *cd, VALUE klass)
vm_cc_cme(cc)->called_id == vm_ci_mid(cd->ci)); // cme->called_id == ci->mid
return;
}
- cd->cc = vm_cc_empty();
+ cd->cc =
+#ifdef MJIT_HEADER
+ rb_vm_empty_cc();
+#else
+ vm_empty_cc;
+#endif
RB_DEBUG_COUNTER_INC(mc_inline_miss_invalidated);
}
else {