RJIT: Support --rjit-stats on release build as well

This commit is contained in:
Takashi Kokubun 2023-03-17 22:31:41 -07:00
Родитель b9f411b3a8
Коммит 644c998525
5 изменённых файлов: 9 добавлений и 20 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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

4
rjit.c
Просмотреть файл

@ -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