diff options
author | Takashi Kokubun <[email protected]> | 2023-03-17 22:31:41 -0700 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2023-03-17 22:31:41 -0700 |
commit | 644c9985256e8bf52d8ec362dcebe4a437e7fd51 (patch) | |
tree | e70f0f8b29fc28df34403026bceadb3a85bcf5f6 | |
parent | b9f411b3a855f13b3ab9f5b0fa9845a078e1bc93 (diff) |
RJIT: Support --rjit-stats on release build as well
-rw-r--r-- | doc/rjit/rjit.md | 5 | ||||
-rw-r--r-- | lib/ruby_vm/rjit/stats.rb | 2 | ||||
-rw-r--r-- | rjit.c | 4 | ||||
-rw-r--r-- | rjit_c.c | 2 | ||||
-rw-r--r-- | rjit_c.rb | 16 |
5 files changed, 9 insertions, 20 deletions
diff --git a/doc/rjit/rjit.md b/doc/rjit/rjit.md index 77be56bfb5..feac739b02 100644 --- a/doc/rjit/rjit.md +++ b/doc/rjit/rjit.md @@ -22,7 +22,8 @@ You may still manually pass `--enable-rjit` to try RJIT on unsupported platforms ### --enable-rjit=dev -`--enable-rjit=dev` makes the interpreter slower, but enables `ruby --rjit-stats` to work. +`--enable-rjit=dev` makes the interpreter slower, but enables `vm_insns_count` and `ratio_in_rjit` +in `ruby --rjit-stats` to work. ## make ### rjit-bindgen @@ -35,7 +36,7 @@ macOS seems to have libclang by default. On Ubuntu, you can install it with `apt ## ruby ### --rjit-stats -This prints RJIT stats at exit. Available with `--enable-rjit=dev` on configure. +This prints RJIT stats at exit. Some stats are available only with `--enable-rjit=dev` on configure. ### --rjit-dump-disasm diff --git a/lib/ruby_vm/rjit/stats.rb b/lib/ruby_vm/rjit/stats.rb index 65bb962aac..8c4253880a 100644 --- a/lib/ruby_vm/rjit/stats.rb +++ b/lib/ruby_vm/rjit/stats.rb @@ -22,6 +22,8 @@ module RubyVM::RJIT retired_in_rjit = stats[:rjit_insns_count] - stats[:side_exit_count] stats[:total_insns_count] = retired_in_rjit + stats[:vm_insns_count] stats[:ratio_in_rjit] = 100.0 * retired_in_rjit / stats[:total_insns_count] + else + stats.delete(:vm_insns_count) end stats @@ -145,8 +145,8 @@ rb_rjit_setup_options(const char *s, struct rjit_options *rjit_opt) #define M(shortopt, longopt, desc) RUBY_OPT_MESSAGE(shortopt, longopt, desc) const struct ruby_opt_message rb_rjit_option_messages[] = { -#if RJIT_STATS M("--rjit-stats", "", "Enable collecting RJIT statistics"), +#if RJIT_STATS M("--rjit-trace-exits", "", "Trace side exit locations"), #endif M("--rjit-exec-mem-size=num", "", "Size of executable memory block in MiB (default: " STRINGIZE(DEFAULT_EXEC_MEM_SIZE) ")"), @@ -158,9 +158,9 @@ const struct ruby_opt_message rb_rjit_option_messages[] = { }; #undef M -#if RJIT_STATS struct rb_rjit_runtime_counters rb_rjit_counters = { 0 }; +#if RJIT_STATS void rb_rjit_collect_vm_usage_insn(int insn) { @@ -406,10 +406,8 @@ rjit_exit_traces(void) #define SIZEOF(type) RB_SIZE2NUM(sizeof(type)) #define SIGNED_TYPE_P(type) RBOOL((type)(-1) < (type)(1)) -#if RJIT_STATS // Insn side exit counters static size_t rjit_insn_exits[VM_INSTRUCTION_SIZE] = { 0 }; -#endif // YJIT_STATS // macOS: brew install capstone // Ubuntu/Debian: apt-get install libcapstone-dev @@ -18,13 +18,7 @@ module RubyVM::RJIT # :nodoc: all end def rjit_insn_exits - addr = Primitive.cstmt! %{ - #if RJIT_STATS - return SIZET2NUM((size_t)rjit_insn_exits); - #else - return SIZET2NUM(0); - #endif - } + addr = Primitive.cexpr! 'SIZET2NUM((size_t)rjit_insn_exits)' CType::Immediate.parse("size_t").new(addr) end @@ -36,13 +30,7 @@ module RubyVM::RJIT # :nodoc: all end def rb_rjit_counters - addr = Primitive.cstmt! %{ - #if RJIT_STATS - return SIZET2NUM((size_t)&rb_rjit_counters); - #else - return SIZET2NUM(0); - #endif - } + addr = Primitive.cexpr! 'SIZET2NUM((size_t)&rb_rjit_counters)' rb_rjit_runtime_counters.new(addr) end |