diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2022-10-17 10:47:22 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-17 10:47:22 -0700 |
commit | f11765aef0cafb6fadf98216c94507f2390a0a70 (patch) | |
tree | 027106774a88e5f9d4e6f220535cf7a05ca33181 /yjit/src/options.rs | |
parent | 64c52c428285e7930aed62740cc9c54ee483178e (diff) | |
download | ruby-f11765aef0cafb6fadf98216c94507f2390a0a70.tar.gz |
YJIT: Allow --yjit-dump-disasm to dump into a file (#6552)
* YJIT: Allow --yjit-dump-disasm to dump into a file
* YJIT: Move IO implementation to disasm.rs
* YJIT: More consistent naming
Diffstat (limited to 'yjit/src/options.rs')
-rw-r--r-- | yjit/src/options.rs | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/yjit/src/options.rs b/yjit/src/options.rs index d2b43ecb26..303ae4980f 100644 --- a/yjit/src/options.rs +++ b/yjit/src/options.rs @@ -36,7 +36,7 @@ pub struct Options { pub dump_insns: bool, /// Dump all compiled instructions of target cbs. - pub dump_disasm: DumpDisasm, + pub dump_disasm: Option<DumpDisasm>, /// Print when specific ISEQ items are compiled or invalidated pub dump_iseq_disasm: Option<String>, @@ -62,26 +62,18 @@ pub static mut OPTIONS: Options = Options { gen_stats: false, gen_trace_exits: false, dump_insns: false, - dump_disasm: DumpDisasm::None, + dump_disasm: None, verify_ctx: false, global_constant_state: false, dump_iseq_disasm: None, }; -#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] pub enum DumpDisasm { - // Dump only inline cb - Inline, - // Dump both inline and outlined cbs - All, - // Dont dump anything - None, -} - -impl DumpDisasm { - pub fn is_enabled(&self) -> bool { - *self != DumpDisasm::None - } + // Dump to stdout + Stdout, + // Dump to "yjit_{pid}.log" file under the specified directory + File(String), } /// Macro to get an option value by name @@ -168,9 +160,13 @@ pub fn parse_option(str_ptr: *const std::os::raw::c_char) -> Option<()> { }, ("dump-disasm", _) => match opt_val.to_string().as_str() { - "all" => unsafe { OPTIONS.dump_disasm = DumpDisasm::All }, - "" => unsafe { OPTIONS.dump_disasm = DumpDisasm::Inline }, - _ => return None, + "" => unsafe { OPTIONS.dump_disasm = Some(DumpDisasm::Stdout) }, + directory => { + let pid = std::process::id(); + let path = format!("{directory}/yjit_{pid}.log"); + println!("YJIT disasm dump: {path}"); + unsafe { OPTIONS.dump_disasm = Some(DumpDisasm::File(path)) } + } }, ("dump-iseq-disasm", _) => unsafe { |