diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2025-10-29 14:58:27 -0700 |
|---|---|---|
| committer | Takashi Kokubun <takashikkbn@gmail.com> | 2025-10-29 16:27:48 -0700 |
| commit | 534aeaef09ecd0101230065ecbfb59c2146f7954 (patch) | |
| tree | 76b541dc45bd81f3e9e2e4d8305f9874b60b613f | |
| parent | 16a7a22c5a3eee13a91239da42e64417aa08457e (diff) | |
ZJIT: Dump Assembler on panic by default for dev builds
| -rw-r--r-- | zjit/src/backend/lir.rs | 4 | ||||
| -rw-r--r-- | zjit/src/options.rs | 25 |
2 files changed, 8 insertions, 21 deletions
diff --git a/zjit/src/backend/lir.rs b/zjit/src/backend/lir.rs index 3d2cfb6786..5980e9e022 100644 --- a/zjit/src/backend/lir.rs +++ b/zjit/src/backend/lir.rs @@ -7,7 +7,7 @@ use std::sync::{Arc, Mutex}; use crate::codegen::local_size_and_idx_to_ep_offset; use crate::cruby::{Qundef, RUBY_OFFSET_CFP_PC, RUBY_OFFSET_CFP_SP, SIZEOF_VALUE_I32, vm_stack_canary}; use crate::hir::SideExitReason; -use crate::options::{TraceExits, debug, dump_lir_option, get_option}; +use crate::options::{TraceExits, debug, get_option}; use crate::cruby::VALUE; use crate::stats::{exit_counter_ptr, exit_counter_ptr_for_opcode, side_exit_counter, CompileError}; use crate::virtualmem::CodePtr; @@ -2288,7 +2288,7 @@ impl AssemblerPanicHook { /// It takes insn_idx as an argument so that you can manually use it /// on non-emit passes that keep mutating the Assembler to be dumped. pub fn new(asm: &Assembler, insn_idx: usize) -> (Option<Arc<Self>>, Option<Arc<Mutex<usize>>>) { - if dump_lir_option!(panic) { + if cfg!(debug_assertions) { // Wrap prev_hook with Arc to share it among the new hook and Self to be dropped. let prev_hook = panic::take_hook(); let panic_hook_ref = Arc::new(Self { prev_hook }); diff --git a/zjit/src/options.rs b/zjit/src/options.rs index 44f4dbc7a4..34a9afce06 100644 --- a/zjit/src/options.rs +++ b/zjit/src/options.rs @@ -164,11 +164,9 @@ pub enum DumpLIR { compile_side_exits, /// Dump LIR after {arch}_scratch_split scratch_split, - /// Dump LIR at panic on {arch}_emit - panic, } -/// All compiler stages for --zjit-dump-lir=all. This does NOT include DumpLIR::panic. +/// All compiler stages for --zjit-dump-lir=all. const DUMP_LIR_ALL: &[DumpLIR] = &[ DumpLIR::init, DumpLIR::split, @@ -180,24 +178,14 @@ const DUMP_LIR_ALL: &[DumpLIR] = &[ /// Macro to dump LIR if --zjit-dump-lir is specified macro_rules! asm_dump { ($asm:expr, $target:ident) => { - if crate::options::dump_lir_option!($target) { - println!("LIR {}:\n{}", stringify!($target), $asm); - } - }; -} -pub(crate) use asm_dump; - -/// Macro to check if a particular dump_lir option is enabled -macro_rules! dump_lir_option { - ($target:ident) => { if let Some(crate::options::Options { dump_lir: Some(dump_lirs), .. }) = unsafe { crate::options::OPTIONS.as_ref() } { - dump_lirs.contains(&crate::options::DumpLIR::$target) - } else { - false + if dump_lirs.contains(&crate::options::DumpLIR::$target) { + println!("LIR {}:\n{}", stringify!($target), $asm); + } } }; } -pub(crate) use dump_lir_option; +pub(crate) use asm_dump; /// Macro to get an option value by name macro_rules! get_option { @@ -366,11 +354,10 @@ fn parse_option(str_ptr: *const std::os::raw::c_char) -> Option<()> { "alloc_regs" => DumpLIR::alloc_regs, "compile_side_exits" => DumpLIR::compile_side_exits, "scratch_split" => DumpLIR::scratch_split, - "panic" => DumpLIR::panic, _ => { let valid_options = DUMP_LIR_ALL.iter().map(|opt| format!("{opt:?}")).collect::<Vec<_>>().join(", "); eprintln!("invalid --zjit-dump-lir option: '{filter}'"); - eprintln!("valid --zjit-dump-lir options: all, {}, panic", valid_options); + eprintln!("valid --zjit-dump-lir options: all, {}", valid_options); return None; } }; |
