From 3928c151a63b273ff10feb43906d6590c6592d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Fri, 5 Jun 2020 10:14:06 +0900 Subject: 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. --- vm_insnhelper.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'vm_insnhelper.c') 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 { -- cgit v1.2.3