RJIT: Share rb_vm_insns_count for vm_insns_count
This commit is contained in:
parent
dee45ac231
commit
eb872d1752
@ -3947,18 +3947,11 @@ AC_ARG_ENABLE(rjit,
|
|||||||
)
|
)
|
||||||
|
|
||||||
AS_CASE(["$RJIT_SUPPORT"],
|
AS_CASE(["$RJIT_SUPPORT"],
|
||||||
[yes|dev|disasm], [
|
[yes|dev], [
|
||||||
AS_CASE(["$RJIT_SUPPORT"],
|
AS_CASE(["$RJIT_SUPPORT"],
|
||||||
[dev], [
|
[dev], [
|
||||||
# Link libcapstone for --rjit-dump-disasm
|
# Link libcapstone for --rjit-dump-disasm
|
||||||
AC_CHECK_LIB([capstone], [cs_disasm])
|
AC_CHECK_LIB([capstone], [cs_disasm])
|
||||||
|
|
||||||
# Enable extra stats (vm_insns_count, ratio_in_rjit)
|
|
||||||
AC_DEFINE(RJIT_STATS, 1)
|
|
||||||
],
|
|
||||||
[disasm], [
|
|
||||||
# Link libcapstone for --rjit-dump-disasm
|
|
||||||
AC_CHECK_LIB([capstone], [cs_disasm])
|
|
||||||
])
|
])
|
||||||
|
|
||||||
AC_DEFINE(USE_RJIT, 1)
|
AC_DEFINE(USE_RJIT, 1)
|
||||||
|
@ -15,6 +15,7 @@ module RubyVM::RJIT
|
|||||||
C.rb_rjit_runtime_counters.members.each do |member|
|
C.rb_rjit_runtime_counters.members.each do |member|
|
||||||
stats[member] = C.rb_rjit_counters.public_send(member)
|
stats[member] = C.rb_rjit_counters.public_send(member)
|
||||||
end
|
end
|
||||||
|
stats[:vm_insns_count] = C.rb_vm_insns_count
|
||||||
|
|
||||||
# Other stats are calculated here
|
# Other stats are calculated here
|
||||||
stats[:side_exit_count] = stats.select { |name, _count| name.start_with?('exit_') }.sum(&:last)
|
stats[:side_exit_count] = stats.select { |name, _count| name.start_with?('exit_') }.sum(&:last)
|
||||||
|
15
rjit.c
15
rjit.c
@ -151,12 +151,10 @@ rb_rjit_setup_options(const char *s, struct rb_rjit_options *rjit_opt)
|
|||||||
|
|
||||||
#define M(shortopt, longopt, desc) RUBY_OPT_MESSAGE(shortopt, longopt, desc)
|
#define M(shortopt, longopt, desc) RUBY_OPT_MESSAGE(shortopt, longopt, desc)
|
||||||
const struct ruby_opt_message rb_rjit_option_messages[] = {
|
const struct ruby_opt_message rb_rjit_option_messages[] = {
|
||||||
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) ")"),
|
M("--rjit-exec-mem-size=num", "", "Size of executable memory block in MiB (default: " STRINGIZE(DEFAULT_EXEC_MEM_SIZE) ")"),
|
||||||
M("--rjit-call-threshold=num", "", "Number of calls to trigger JIT (default: " STRINGIZE(DEFAULT_CALL_THRESHOLD) ")"),
|
M("--rjit-call-threshold=num", "", "Number of calls to trigger JIT (default: " STRINGIZE(DEFAULT_CALL_THRESHOLD) ")"),
|
||||||
|
M("--rjit-stats", "", "Enable collecting RJIT statistics"),
|
||||||
|
M("--rjit-trace-exits", "", "Trace side exit locations"),
|
||||||
#ifdef HAVE_LIBCAPSTONE
|
#ifdef HAVE_LIBCAPSTONE
|
||||||
M("--rjit-dump-disasm", "", "Dump all JIT code"),
|
M("--rjit-dump-disasm", "", "Dump all JIT code"),
|
||||||
#endif
|
#endif
|
||||||
@ -166,15 +164,6 @@ const struct ruby_opt_message rb_rjit_option_messages[] = {
|
|||||||
|
|
||||||
struct rb_rjit_runtime_counters rb_rjit_counters = { 0 };
|
struct rb_rjit_runtime_counters rb_rjit_counters = { 0 };
|
||||||
|
|
||||||
#if RJIT_STATS
|
|
||||||
void
|
|
||||||
rb_rjit_collect_vm_usage_insn(int insn)
|
|
||||||
{
|
|
||||||
if (!rjit_stats_p) return;
|
|
||||||
rb_rjit_counters.vm_insns_count++;
|
|
||||||
}
|
|
||||||
#endif // YJIT_STATS
|
|
||||||
|
|
||||||
extern VALUE rb_gc_enable(void);
|
extern VALUE rb_gc_enable(void);
|
||||||
extern VALUE rb_gc_disable(void);
|
extern VALUE rb_gc_disable(void);
|
||||||
|
|
||||||
|
4
rjit.h
4
rjit.h
@ -14,10 +14,6 @@
|
|||||||
|
|
||||||
# if USE_RJIT
|
# if USE_RJIT
|
||||||
|
|
||||||
#ifndef RJIT_STATS
|
|
||||||
# define RJIT_STATS RUBY_DEBUG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "ruby.h"
|
#include "ruby.h"
|
||||||
#include "vm_core.h"
|
#include "vm_core.h"
|
||||||
|
|
||||||
|
1
rjit_c.h
1
rjit_c.h
@ -17,7 +17,6 @@ extern uint8_t *rb_rjit_mem_block;
|
|||||||
|
|
||||||
#define RJIT_RUNTIME_COUNTERS(...) struct rb_rjit_runtime_counters { size_t __VA_ARGS__; };
|
#define RJIT_RUNTIME_COUNTERS(...) struct rb_rjit_runtime_counters { size_t __VA_ARGS__; };
|
||||||
RJIT_RUNTIME_COUNTERS(
|
RJIT_RUNTIME_COUNTERS(
|
||||||
vm_insns_count,
|
|
||||||
rjit_insns_count,
|
rjit_insns_count,
|
||||||
|
|
||||||
send_args_splat_kw_splat,
|
send_args_splat_kw_splat,
|
||||||
|
@ -512,6 +512,10 @@ module RubyVM::RJIT # :nodoc: all
|
|||||||
Primitive.cexpr! %q{ SIZET2NUM(rb_rjit_global_events) }
|
Primitive.cexpr! %q{ SIZET2NUM(rb_rjit_global_events) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def C.rb_vm_insns_count
|
||||||
|
Primitive.cexpr! %q{ SIZET2NUM(rb_vm_insns_count) }
|
||||||
|
end
|
||||||
|
|
||||||
def C.rb_ary_clear
|
def C.rb_ary_clear
|
||||||
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ary_clear) }
|
Primitive.cexpr! %q{ SIZET2NUM((size_t)rb_ary_clear) }
|
||||||
end
|
end
|
||||||
@ -1335,7 +1339,6 @@ module RubyVM::RJIT # :nodoc: all
|
|||||||
def C.rb_rjit_runtime_counters
|
def C.rb_rjit_runtime_counters
|
||||||
@rb_rjit_runtime_counters ||= CType::Struct.new(
|
@rb_rjit_runtime_counters ||= CType::Struct.new(
|
||||||
"rb_rjit_runtime_counters", Primitive.cexpr!("SIZEOF(struct rb_rjit_runtime_counters)"),
|
"rb_rjit_runtime_counters", Primitive.cexpr!("SIZEOF(struct rb_rjit_runtime_counters)"),
|
||||||
vm_insns_count: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), vm_insns_count)")],
|
|
||||||
rjit_insns_count: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), rjit_insns_count)")],
|
rjit_insns_count: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), rjit_insns_count)")],
|
||||||
send_args_splat_kw_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_args_splat_kw_splat)")],
|
send_args_splat_kw_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_args_splat_kw_splat)")],
|
||||||
send_args_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_args_splat)")],
|
send_args_splat: [CType::Immediate.parse("size_t"), Primitive.cexpr!("OFFSETOF((*((struct rb_rjit_runtime_counters *)NULL)), send_args_splat)")],
|
||||||
|
@ -501,6 +501,7 @@ generator = BindingGenerator.new(
|
|||||||
rb_cTrueClass
|
rb_cTrueClass
|
||||||
rb_rjit_global_events
|
rb_rjit_global_events
|
||||||
rb_mRubyVMFrozenCore
|
rb_mRubyVMFrozenCore
|
||||||
|
rb_vm_insns_count
|
||||||
idRespond_to_missing
|
idRespond_to_missing
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -16,23 +16,13 @@ RUBY_EXTERN rb_serial_t ruby_vm_constant_cache_invalidations;
|
|||||||
RUBY_EXTERN rb_serial_t ruby_vm_constant_cache_misses;
|
RUBY_EXTERN rb_serial_t ruby_vm_constant_cache_misses;
|
||||||
RUBY_EXTERN rb_serial_t ruby_vm_global_cvar_state;
|
RUBY_EXTERN rb_serial_t ruby_vm_global_cvar_state;
|
||||||
|
|
||||||
#ifndef RJIT_STATS
|
#if USE_YJIT || USE_RJIT // We want vm_insns_count on any JIT-enabled build.
|
||||||
# define RJIT_STATS RUBY_DEBUG
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if USE_YJIT // We want vm_insns_count on any YJIT-enabled build
|
|
||||||
// Increment vm_insns_count for --yjit-stats. We increment this even when
|
// Increment vm_insns_count for --yjit-stats. We increment this even when
|
||||||
// --yjit or --yjit-stats is not used because branching to skip it is slower.
|
// --yjit or --yjit-stats is not used because branching to skip it is slower.
|
||||||
// We also don't use ATOMIC_INC for performance, allowing inaccuracy on Ractors.
|
// We also don't use ATOMIC_INC for performance, allowing inaccuracy on Ractors.
|
||||||
#define YJIT_COLLECT_USAGE_INSN(insn) rb_vm_insns_count++
|
#define JIT_COLLECT_USAGE_INSN(insn) rb_vm_insns_count++
|
||||||
#else
|
#else
|
||||||
#define YJIT_COLLECT_USAGE_INSN(insn) // none
|
#define JIT_COLLECT_USAGE_INSN(insn) // none
|
||||||
#endif
|
|
||||||
|
|
||||||
#if RJIT_STATS
|
|
||||||
#define RJIT_COLLECT_USAGE_INSN(insn) rb_rjit_collect_vm_usage_insn(insn)
|
|
||||||
#else
|
|
||||||
#define RJIT_COLLECT_USAGE_INSN(insn) // none
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if VM_COLLECT_USAGE_DETAILS
|
#if VM_COLLECT_USAGE_DETAILS
|
||||||
@ -40,7 +30,7 @@ RUBY_EXTERN rb_serial_t ruby_vm_global_cvar_state;
|
|||||||
#define COLLECT_USAGE_OPERAND(insn, n, op) vm_collect_usage_operand((insn), (n), ((VALUE)(op)))
|
#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))
|
#define COLLECT_USAGE_REGISTER(reg, s) vm_collect_usage_register((reg), (s))
|
||||||
#else
|
#else
|
||||||
#define COLLECT_USAGE_INSN(insn) YJIT_COLLECT_USAGE_INSN(insn); RJIT_COLLECT_USAGE_INSN(insn)
|
#define COLLECT_USAGE_INSN(insn) JIT_COLLECT_USAGE_INSN(insn)
|
||||||
#define COLLECT_USAGE_OPERAND(insn, n, op) // none
|
#define COLLECT_USAGE_OPERAND(insn, n, op) // none
|
||||||
#define COLLECT_USAGE_REGISTER(reg, s) // none
|
#define COLLECT_USAGE_REGISTER(reg, s) // none
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user