Support --zjit-dump-disasm

This commit is contained in:
Takashi Kokubun 2025-02-10 14:53:31 -08:00
parent 0252ce1cd4
commit a6e1a562e4
Notes: git 2025-04-18 13:49:12 +00:00
2 changed files with 15 additions and 1 deletions

View File

@ -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);
}
}

View File

@ -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.