[前][次][番号順一覧][スレッド一覧]

ruby-changes:61611

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Tue, 9 Jun 2020 09:53:08 +0900 (JST)
Subject: [ruby-changes:61611] 3928c151a6 (master): vm_search_method_fastpath: avoid rb_vm_empty_cc()

https://git.ruby-lang.org/ruby.git/commit/?id=3928c151a6

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?=
 <shyouhei@r...>
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.

diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 0774217..25b5db8 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 https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L36
 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) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1571
 
     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) https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1632
                       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 v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]