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

ruby-changes:69280

From: Alan <ko1@a...>
Date: Thu, 21 Oct 2021 08:23:18 +0900 (JST)
Subject: [ruby-changes:69280] 4b58d698b1 (master): Count interpreter instructions when -DYJIT_STATS=1

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

From 4b58d698b14752f4dfd405637df384c758cae396 Mon Sep 17 00:00:00 2001
From: Alan Wu <XrXr@u...>
Date: Wed, 8 Sep 2021 12:01:39 -0400
Subject: Count interpreter instructions when -DYJIT_STATS=1

The interpreter instruction count was enabled based on RUBY_DEBUG as
opposed to YJIT_STATS. In builds with YJIT_STATS=1 but RUBY_DEBUG=0,
the count was not available.

Move YJIT_STATS in yjit.h where declarations are expoed to code outside
of YJIT. Also reduce the changes made to the interpreter for calling
into YJIT's instruction counting function.
---
 vm.c            | 14 +-------------
 vm_insnhelper.h |  4 ++--
 yjit.h          |  6 ++++++
 3 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/vm.c b/vm.c
index 733c2c24d1..d4f555df6c 100644
--- a/vm.c
+++ b/vm.c
@@ -28,6 +28,7 @@ https://github.com/ruby/ruby/blob/trunk/vm.c#L28
 #include "internal/sanitizers.h"
 #include "iseq.h"
 #include "mjit.h"
+#include "yjit.h"
 #include "ruby/st.h"
 #include "ruby/vm.h"
 #include "vm_core.h"
@@ -37,7 +38,6 @@ https://github.com/ruby/ruby/blob/trunk/vm.c#L38
 #include "vm_insnhelper.h"
 #include "ractor_core.h"
 #include "vm_sync.h"
-#include "yjit.h"
 
 #include "builtin.h"
 
@@ -345,10 +345,6 @@ static void vm_collect_usage_insn(int insn); https://github.com/ruby/ruby/blob/trunk/vm.c#L345
 static void vm_collect_usage_register(int reg, int isset);
 #endif
 
-#if RUBY_DEBUG
-static void vm_yjit_collect_usage_insn(int insn);
-#endif
-
 static VALUE vm_make_env_object(const rb_execution_context_t *ec, rb_control_frame_t *cfp);
 extern VALUE rb_vm_invoke_bmethod(rb_execution_context_t *ec, rb_proc_t *proc, VALUE self,
                                   int argc, const VALUE *argv, int kw_splat, VALUE block_handler,
@@ -4061,14 +4057,6 @@ MAYBE_UNUSED(static void (*ruby_vm_collect_usage_func_register)(int reg, int iss https://github.com/ruby/ruby/blob/trunk/vm.c#L4057
 
 #endif
 
-#if RUBY_DEBUG
-static void
-vm_yjit_collect_usage_insn(int insn)
-{
-    rb_yjit_collect_vm_usage_insn(insn);
-}
-#endif
-
 #if VM_COLLECT_USAGE_DETAILS
 /* @param insn instruction number */
 static void
diff --git a/vm_insnhelper.h b/vm_insnhelper.h
index 22a181f95a..459f567106 100644
--- a/vm_insnhelper.h
+++ b/vm_insnhelper.h
@@ -25,9 +25,9 @@ MJIT_SYMBOL_EXPORT_END https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L25
 #define COLLECT_USAGE_OPERAND(insn, n, op) vm_collect_usage_operand((insn), (n), ((VALUE)(op)))
 
 #define COLLECT_USAGE_REGISTER(reg, s)     vm_collect_usage_register((reg), (s))
-#elif RUBY_DEBUG
+#elif YJIT_STATS
 /* for --yjit-stats */
-#define COLLECT_USAGE_INSN(insn)           vm_yjit_collect_usage_insn(insn)
+#define COLLECT_USAGE_INSN(insn)           rb_yjit_collect_vm_usage_insn(insn)
 #define COLLECT_USAGE_OPERAND(insn, n, op)	/* none */
 #define COLLECT_USAGE_REGISTER(reg, s)		/* none */
 #else
diff --git a/yjit.h b/yjit.h
index 2844fb2511..e3dd3a2f05 100644
--- a/yjit.h
+++ b/yjit.h
@@ -5,6 +5,8 @@ https://github.com/ruby/ruby/blob/trunk/yjit.h#L5
 #ifndef YJIT_H
 #define YJIT_H 1
 
+#include "ruby/internal/config.h"
+#include "ruby_assert.h" // for RUBY_DEBUG
 #include "vm_core.h"
 #include "method.h"
 
@@ -26,6 +28,10 @@ https://github.com/ruby/ruby/blob/trunk/yjit.h#L28
 #define YJIT_DUMP_MODE 0
 #endif
 
+#ifndef YJIT_STATS
+# define YJIT_STATS RUBY_DEBUG
+#endif // ifndef YJIT_STATS
+
 #ifndef rb_iseq_t
 typedef struct rb_iseq_struct rb_iseq_t;
 #define rb_iseq_t rb_iseq_t
-- 
cgit v1.2.1


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

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