зеркало из https://github.com/github/ruby.git
RJIT: Add --rjit-trace to allow TracePoint during JIT
This commit is contained in:
Родитель
c18edc5b5d
Коммит
64c52cd1c2
23
rjit.c
23
rjit.c
|
@ -121,15 +121,21 @@ rb_rjit_setup_options(const char *s, struct rb_rjit_options *rjit_opt)
|
||||||
if (l == 0) {
|
if (l == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (opt_match_arg(s, l, "call-threshold")) {
|
|
||||||
rjit_opt->call_threshold = atoi(s + 1);
|
|
||||||
}
|
|
||||||
else if (opt_match_arg(s, l, "exec-mem-size")) {
|
else if (opt_match_arg(s, l, "exec-mem-size")) {
|
||||||
rjit_opt->exec_mem_size = atoi(s + 1);
|
rjit_opt->exec_mem_size = atoi(s + 1);
|
||||||
}
|
}
|
||||||
|
else if (opt_match_arg(s, l, "call-threshold")) {
|
||||||
|
rjit_opt->call_threshold = atoi(s + 1);
|
||||||
|
}
|
||||||
else if (opt_match_noarg(s, l, "stats")) {
|
else if (opt_match_noarg(s, l, "stats")) {
|
||||||
rjit_opt->stats = true;
|
rjit_opt->stats = true;
|
||||||
}
|
}
|
||||||
|
else if (opt_match_noarg(s, l, "disable")) {
|
||||||
|
rjit_opt->disable = true;
|
||||||
|
}
|
||||||
|
else if (opt_match_noarg(s, l, "trace")) {
|
||||||
|
rjit_opt->trace_exits = true;
|
||||||
|
}
|
||||||
else if (opt_match_noarg(s, l, "trace-exits")) {
|
else if (opt_match_noarg(s, l, "trace-exits")) {
|
||||||
rjit_opt->trace_exits = true;
|
rjit_opt->trace_exits = true;
|
||||||
}
|
}
|
||||||
|
@ -139,9 +145,6 @@ rb_rjit_setup_options(const char *s, struct rb_rjit_options *rjit_opt)
|
||||||
else if (opt_match_noarg(s, l, "verify-ctx")) {
|
else if (opt_match_noarg(s, l, "verify-ctx")) {
|
||||||
rjit_opt->verify_ctx = true;
|
rjit_opt->verify_ctx = true;
|
||||||
}
|
}
|
||||||
else if (opt_match_noarg(s, l, "disable")) {
|
|
||||||
rjit_opt->disable = true;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
rb_raise(rb_eRuntimeError,
|
rb_raise(rb_eRuntimeError,
|
||||||
"invalid RJIT option `%s' (--help will show valid RJIT options)", s);
|
"invalid RJIT option `%s' (--help will show valid RJIT options)", s);
|
||||||
|
@ -153,6 +156,8 @@ const struct ruby_opt_message rb_rjit_option_messages[] = {
|
||||||
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-stats", "", "Enable collecting RJIT statistics"),
|
||||||
|
M("--rjit-disable", "", "Disable RJIT for lazily enabling it with RubyVM::RJIT.enable"),
|
||||||
|
M("--rjit-trace", "", "Allow TracePoint during JIT compilation"),
|
||||||
M("--rjit-trace-exits", "", "Trace side exit locations"),
|
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"),
|
||||||
|
@ -167,12 +172,12 @@ extern VALUE rb_gc_enable(void);
|
||||||
extern VALUE rb_gc_disable(void);
|
extern VALUE rb_gc_disable(void);
|
||||||
extern uint64_t rb_vm_insns_count;
|
extern uint64_t rb_vm_insns_count;
|
||||||
|
|
||||||
// Disable GC, TracePoint, and VM insns counter
|
// Disable GC, TracePoint, JIT, and VM insns counter
|
||||||
#define WITH_RJIT_ISOLATED(stmt) do { \
|
#define WITH_RJIT_ISOLATED(stmt) do { \
|
||||||
VALUE was_disabled = rb_gc_disable(); \
|
VALUE was_disabled = rb_gc_disable(); \
|
||||||
rb_hook_list_t *global_hooks = rb_ec_ractor_hooks(GET_EC()); \
|
rb_hook_list_t *global_hooks = rb_ec_ractor_hooks(GET_EC()); \
|
||||||
rb_rjit_global_events = global_hooks->events; \
|
rb_rjit_global_events = global_hooks->events; \
|
||||||
global_hooks->events = 0; \
|
if (!rb_rjit_opts.trace) global_hooks->events = 0; \
|
||||||
bool original_call_p = rb_rjit_call_p; \
|
bool original_call_p = rb_rjit_call_p; \
|
||||||
rjit_stats_p = false; \
|
rjit_stats_p = false; \
|
||||||
rb_rjit_call_p = false; \
|
rb_rjit_call_p = false; \
|
||||||
|
@ -181,7 +186,7 @@ extern uint64_t rb_vm_insns_count;
|
||||||
rb_vm_insns_count = insns_count; \
|
rb_vm_insns_count = insns_count; \
|
||||||
rb_rjit_call_p = (rjit_cancel_p ? false : original_call_p); \
|
rb_rjit_call_p = (rjit_cancel_p ? false : original_call_p); \
|
||||||
rjit_stats_p = rb_rjit_opts.stats; \
|
rjit_stats_p = rb_rjit_opts.stats; \
|
||||||
global_hooks->events = rb_rjit_global_events; \
|
if (!rb_rjit_opts.trace) global_hooks->events = rb_rjit_global_events; \
|
||||||
if (!was_disabled) rb_gc_enable(); \
|
if (!was_disabled) rb_gc_enable(); \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
|
|
10
rjit.h
10
rjit.h
|
@ -22,20 +22,22 @@ struct rb_rjit_options {
|
||||||
// Converted from "rjit" feature flag to tell the enablement
|
// Converted from "rjit" feature flag to tell the enablement
|
||||||
// information to ruby_show_version().
|
// information to ruby_show_version().
|
||||||
bool on;
|
bool on;
|
||||||
// Number of calls to trigger JIT compilation.
|
|
||||||
unsigned int call_threshold;
|
|
||||||
// Size of executable memory block in MiB
|
// Size of executable memory block in MiB
|
||||||
unsigned int exec_mem_size;
|
unsigned int exec_mem_size;
|
||||||
|
// Number of calls to trigger JIT compilation
|
||||||
|
unsigned int call_threshold;
|
||||||
// Collect RJIT statistics
|
// Collect RJIT statistics
|
||||||
bool stats;
|
bool stats;
|
||||||
|
// Do not start RJIT until RJIT.enable is called
|
||||||
|
bool disable;
|
||||||
|
// Allow TracePoint during JIT compilation
|
||||||
|
bool trace;
|
||||||
// Trace side exit locations
|
// Trace side exit locations
|
||||||
bool trace_exits;
|
bool trace_exits;
|
||||||
// Enable disasm of all JIT code
|
// Enable disasm of all JIT code
|
||||||
bool dump_disasm;
|
bool dump_disasm;
|
||||||
// Verify context objects
|
// Verify context objects
|
||||||
bool verify_ctx;
|
bool verify_ctx;
|
||||||
// [experimental] Do not start RJIT until RJIT.resume is called.
|
|
||||||
bool disable;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
RUBY_SYMBOL_EXPORT_BEGIN
|
RUBY_SYMBOL_EXPORT_BEGIN
|
||||||
|
|
2
ruby.c
2
ruby.c
|
@ -389,7 +389,7 @@ usage(const char *name, int help, int highlight, int columns)
|
||||||
M("yjit", "", "in-process JIT compiler (default: disabled)"),
|
M("yjit", "", "in-process JIT compiler (default: disabled)"),
|
||||||
#endif
|
#endif
|
||||||
#if USE_RJIT
|
#if USE_RJIT
|
||||||
M("rjit", "", "pure-Ruby JIT compiler (default: disabled)"),
|
M("rjit", "", "pure-Ruby JIT compiler (experimental, default: disabled)"),
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
static const struct ruby_opt_message warn_categories[] = {
|
static const struct ruby_opt_message warn_categories[] = {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче