diff options
author | Noah Gibbs <the.codefolio.guy@gmail.com> | 2022-07-28 16:45:08 +0100 |
---|---|---|
committer | Takashi Kokubun <takashikkbn@gmail.com> | 2022-08-24 10:42:45 -0700 |
commit | b4be3c00c5737649166db676278fd28f768a5e3c (patch) | |
tree | 73ad75aa40351021832e44943a40a349172568d7 /yjit/src/options.rs | |
parent | 0ad9cc16966c2e56f0fe7e5992edf76033d3a83f (diff) | |
download | ruby-b4be3c00c5737649166db676278fd28f768a5e3c.tar.gz |
add --yjit-dump-iseqs param (https://github.com/Shopify/ruby/pull/332)
Diffstat (limited to 'yjit/src/options.rs')
-rw-r--r-- | yjit/src/options.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/yjit/src/options.rs b/yjit/src/options.rs index 704c709bae..7436b3583b 100644 --- a/yjit/src/options.rs +++ b/yjit/src/options.rs @@ -1,7 +1,7 @@ use std::ffi::CStr; // Command-line options -#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] #[repr(C)] pub struct Options { // Size of the executable memory block to allocate in MiB @@ -30,6 +30,9 @@ pub struct Options { /// Dump compiled and executed instructions for debugging pub dump_insns: bool, + /// Print when specific ISEQ items are compiled or invalidated + pub dump_iseq_disasm: Option<String>, + /// Verify context objects (debug mode only) pub verify_ctx: bool, @@ -52,6 +55,7 @@ pub static mut OPTIONS: Options = Options { dump_insns: false, verify_ctx: false, global_constant_state: false, + dump_iseq_disasm: None, }; /// Macro to get an option value by name @@ -64,6 +68,16 @@ macro_rules! get_option { } pub(crate) use get_option; +/// Macro to reference an option value by name; we assume it's a cloneable type like String or an Option of same. +macro_rules! get_option_ref { + // Unsafe is ok here because options are initialized + // once before any Ruby code executes + ($option_name:ident) => { + unsafe { &(OPTIONS.$option_name) } + }; +} +pub(crate) use get_option_ref; + /// Expected to receive what comes after the third dash in "--yjit-*". /// Empty string means user passed only "--yjit". C code rejects when /// they pass exact "--yjit-". @@ -105,6 +119,10 @@ pub fn parse_option(str_ptr: *const std::os::raw::c_char) -> Option<()> { } }, + ("dump-iseq-disasm", _) => unsafe { + OPTIONS.dump_iseq_disasm = Some(opt_val.to_string()); + }, + ("greedy-versioning", "") => unsafe { OPTIONS.greedy_versioning = true }, ("no-type-prop", "") => unsafe { OPTIONS.no_type_prop = true }, ("stats", "") => unsafe { OPTIONS.gen_stats = true }, |