diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2022-09-01 11:55:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-01 11:55:39 -0700 |
commit | 4144abee42f4ebd73c98d772e3b2530598e584c8 (patch) | |
tree | 1a5428b21b77804fbe0e4e13d5125528f7dc9a3e /yjit/src/options.rs | |
parent | 462a8be5112f8c4e621d106304ac617ebcf39eb0 (diff) | |
download | ruby-4144abee42f4ebd73c98d772e3b2530598e584c8.tar.gz |
Let --yjit-dump-disasm=all dump ocb code as well (#6309)
* Let --yjit-dump-disasm=all dump ocb code as well
* Use an enum instead
* Add a None Option to DumpDisasm (#444)
* Add a None Option to DumpDisasm
* Update yjit/src/asm/mod.rs
Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
* Fix a build failure
* Use only a single name
* Only None will be a disabled case
* Fix cargo test
* Fix --yjit-dump-disasm=all to print outlined cb
Co-authored-by: Jimmy Miller <jimmyhmiller@gmail.com>
Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
Diffstat (limited to 'yjit/src/options.rs')
-rw-r--r-- | yjit/src/options.rs | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/yjit/src/options.rs b/yjit/src/options.rs index 2e141445f1..f73dca67de 100644 --- a/yjit/src/options.rs +++ b/yjit/src/options.rs @@ -30,8 +30,8 @@ pub struct Options { /// Dump compiled and executed instructions for debugging pub dump_insns: bool, - /// Dump all compiled instructions in inlined CodeBlock - pub dump_disasm: bool, + /// Dump all compiled instructions of target cbs. + pub dump_disasm: DumpDisasm, /// Print when specific ISEQ items are compiled or invalidated pub dump_iseq_disasm: Option<String>, @@ -56,12 +56,28 @@ pub static mut OPTIONS: Options = Options { gen_stats: false, gen_trace_exits: false, dump_insns: false, - dump_disasm: false, + dump_disasm: DumpDisasm::None, verify_ctx: false, global_constant_state: false, dump_iseq_disasm: None, }; +#[derive(Copy, 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 + } +} + /// Macro to get an option value by name macro_rules! get_option { // Unsafe is ok here because options are initialized @@ -123,6 +139,12 @@ 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, + }, + ("dump-iseq-disasm", _) => unsafe { OPTIONS.dump_iseq_disasm = Some(opt_val.to_string()); }, @@ -132,7 +154,6 @@ pub fn parse_option(str_ptr: *const std::os::raw::c_char) -> Option<()> { ("stats", "") => unsafe { OPTIONS.gen_stats = true }, ("trace-exits", "") => unsafe { OPTIONS.gen_trace_exits = true; OPTIONS.gen_stats = true }, ("dump-insns", "") => unsafe { OPTIONS.dump_insns = true }, - ("dump-disasm", "") => unsafe { OPTIONS.dump_disasm = true }, ("verify-ctx", "") => unsafe { OPTIONS.verify_ctx = true }, ("global-constant-state", "") => unsafe { OPTIONS.global_constant_state = true }, |