diff --git a/zjit/src/lib.rs b/zjit/src/lib.rs index 56422a37f7..03e6003e2c 100644 --- a/zjit/src/lib.rs +++ b/zjit/src/lib.rs @@ -14,6 +14,7 @@ mod options; use backend::x86_emit; use codegen::ZJITState; +use options::get_option; use crate::cruby::*; #[allow(non_upper_case_globals)] @@ -87,7 +88,7 @@ pub extern "C" fn rb_zjit_iseq_gen_entry_point(iseq: IseqPtr, _ec: EcPtr) -> *co use disasm::disasm_addr_range; let disasm = disasm_addr_range(start_ptr.raw_ptr(cb) as usize, end_ptr.raw_ptr(cb) as usize); - if false { // TODO: implement the option + if get_option!(dump_disasm) { println!("{}", disasm); } } diff --git a/zjit/src/options.rs b/zjit/src/options.rs index e0af04d4c9..7c8a1a479c 100644 --- a/zjit/src/options.rs +++ b/zjit/src/options.rs @@ -6,6 +6,19 @@ pub struct Options { pub dump_disasm: bool, } +/// Macro to get an option value by name +macro_rules! get_option { + // Unsafe is ok here because options are initialized + // once before any Ruby code executes + ($option_name:ident) => { + { + use crate::codegen::ZJITState; + ZJITState::get_options().$option_name + } + }; +} +pub(crate) use get_option; + /// Allocate Options on the heap, initialize it, and return the address of it. /// The return value will be modified by rb_zjit_parse_option() and then /// passed to rb_zjit_init() for initialization.