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

ruby-changes:58906

From: Koichi <ko1@a...>
Date: Mon, 25 Nov 2019 14:11:13 +0900 (JST)
Subject: [ruby-changes:58906] e27acb6148 (master): add fast path for argc==0.

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

From e27acb61485189fd7647741b6ca19920989dec03 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Mon, 25 Nov 2019 14:02:15 +0900
Subject: add fast path for argc==0.

If calling builtin functions with no arguments, we don't need to
calculate argv location.

diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index e3087d3..9078903 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -4997,8 +4997,13 @@ vm_invoke_builtin_delegate(rb_execution_context_t *ec, rb_control_frame_t *cfp, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L4997
         fprintf(stderr, "%s %s(%d):%p\n", RUBY_FUNCTION_NAME_STRING, bf->name, bf->argc, bf->func_ptr);
     }
 
-    const VALUE *argv = cfp->ep - cfp->iseq->body->local_table_size - VM_ENV_DATA_SIZE + 1 + start_index;
-    return invoke_bf(ec, cfp, bf, argv);
+    if (bf->argc == 0) {
+        return invoke_bf(ec, cfp, bf, NULL);
+    }
+    else {
+        const VALUE *argv = cfp->ep - cfp->iseq->body->local_table_size - VM_ENV_DATA_SIZE + 1 + start_index;
+        return invoke_bf(ec, cfp, bf, argv);
+    }
 }
 
 // for __builtin_inline!()
-- 
cgit v0.10.2


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

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