diff options
author | ywenc <ywenc@github.com> | 2023-08-18 18:27:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-18 18:27:59 -0400 |
commit | 3dff315ed3e01f54980410008b73c6a838528e08 (patch) | |
tree | 9e6555c1f9239bd95f0acaebb89c23f4049a28d8 /yjit | |
parent | 07833049dffad4dd29435dd290b4e31d1c1e4f9a (diff) |
YJIT: Quiet mode when running with `--yjit-stats` (#8251)
Quiet mode for running with --yjit-stats
Notes
Notes:
Merged-By: maximecb <maximecb@ruby-lang.org>
Diffstat (limited to 'yjit')
-rw-r--r-- | yjit/src/options.rs | 17 | ||||
-rw-r--r-- | yjit/src/stats.rs | 11 |
2 files changed, 26 insertions, 2 deletions
diff --git a/yjit/src/options.rs b/yjit/src/options.rs index f08217bfc2..4448ece8ec 100644 --- a/yjit/src/options.rs +++ b/yjit/src/options.rs @@ -26,9 +26,12 @@ pub struct Options { // The number of registers allocated for stack temps pub num_temp_regs: usize, - // Capture and print out stats + // Capture stats pub gen_stats: bool, + // Print stats on exit (when gen_stats is also true) + pub print_stats: bool, + // Trace locations of exits pub gen_trace_exits: bool, @@ -62,6 +65,7 @@ pub static mut OPTIONS: Options = Options { num_temp_regs: 5, gen_stats: false, gen_trace_exits: false, + print_stats: true, trace_exits_sample_rate: 0, pause: false, dump_insns: false, @@ -176,7 +180,16 @@ pub fn parse_option(str_ptr: *const std::os::raw::c_char) -> Option<()> { ("greedy-versioning", "") => unsafe { OPTIONS.greedy_versioning = true }, ("no-type-prop", "") => unsafe { OPTIONS.no_type_prop = true }, - ("stats", "") => unsafe { OPTIONS.gen_stats = true }, + ("stats", _) => match opt_val.to_string().as_str() { + "" => unsafe { OPTIONS.gen_stats = true }, + "quiet" => { + unsafe { OPTIONS.gen_stats = true } + unsafe { OPTIONS.print_stats = false } + }, + _ => { + return None; + } + }, ("trace-exits", "") => unsafe { OPTIONS.gen_trace_exits = true; OPTIONS.gen_stats = true; OPTIONS.trace_exits_sample_rate = 0 }, ("trace-exits-sample-rate", sample_rate) => unsafe { OPTIONS.gen_trace_exits = true; OPTIONS.gen_stats = true; OPTIONS.trace_exits_sample_rate = sample_rate.parse().unwrap(); }, ("dump-insns", "") => unsafe { OPTIONS.dump_insns = true }, diff --git a/yjit/src/stats.rs b/yjit/src/stats.rs index 9ef3e8e94c..ef4d25d051 100644 --- a/yjit/src/stats.rs +++ b/yjit/src/stats.rs @@ -463,6 +463,17 @@ pub extern "C" fn rb_yjit_stats_enabled_p(_ec: EcPtr, _ruby_self: VALUE) -> VALU } } +/// Primitive called in yjit.rb +/// Check if stats generation should print at exit +#[no_mangle] +pub extern "C" fn rb_yjit_print_stats_p(_ec: EcPtr, _ruby_self: VALUE) -> VALUE { + if get_option!(print_stats) { + return Qtrue; + } else { + return Qfalse; + } +} + /// Primitive called in yjit.rb. /// Export all YJIT statistics as a Ruby hash. #[no_mangle] |