Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/win32/lib/win32/resolv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def read_s(key)
end
end
using SZ
rescue LoadError
rescue LoadError, Gem::LoadError
require "open3"
end

Expand Down
24 changes: 22 additions & 2 deletions zjit/src/backend/lir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2255,7 +2255,12 @@ impl Assembler {
/// when not dumping disassembly.
macro_rules! asm_comment {
($asm:expr, $($fmt:tt)*) => {
if $crate::options::get_option!(dump_disasm) || $crate::options::get_option!(dump_lir).is_some() {
// If --zjit-dump-disasm or --zjit-dump-lir is given, enrich them with comments.
// Also allow --zjit-debug on dev builds to enable comments since dev builds dump LIR on panic.
let enable_comment = $crate::options::get_option!(dump_disasm) ||
$crate::options::get_option!(dump_lir).is_some() ||
(cfg!(debug_assertions) && $crate::options::get_option!(debug));
if enable_comment {
$asm.push_insn(crate::backend::lir::Insn::Comment(format!($($fmt)*)));
}
};
Expand Down Expand Up @@ -2283,6 +2288,10 @@ pub struct AssemblerPanicHook {
}

impl AssemblerPanicHook {
/// Maximum number of lines [`Self::dump_asm`] is allowed to dump by default.
/// When --zjit-dump-lir is given, this limit is ignored.
const MAX_DUMP_LINES: usize = 40;

/// Install a panic hook to dump Assembler with insn_idx on dev builds.
/// This returns shared references to the previous hook and insn_idx.
/// It takes insn_idx as an argument so that you can manually use it
Expand Down Expand Up @@ -2320,8 +2329,19 @@ impl AssemblerPanicHook {

/// Dump Assembler, highlighting the insn_idx line
fn dump_asm(asm: &Assembler, insn_idx: usize) {
let lir_string = lir_string(asm);
let lines: Vec<&str> = lir_string.split('\n').collect();

// By default, dump only MAX_DUMP_LINES lines.
// Ignore it if --zjit-dump-lir is given.
let (min_idx, max_idx) = if get_option!(dump_lir).is_some() {
(0, lines.len())
} else {
(insn_idx.saturating_sub(Self::MAX_DUMP_LINES / 2), insn_idx.saturating_add(Self::MAX_DUMP_LINES / 2))
};

println!("Failed to compile LIR at insn_idx={insn_idx}:");
for (idx, line) in lir_string(asm).split('\n').enumerate() {
for (idx, line) in lines.iter().enumerate().filter(|(idx, _)| (min_idx..=max_idx).contains(idx)) {
if idx == insn_idx && line.starts_with(" ") {
println!("{BOLD_BEGIN}=>{}{BOLD_END}", &line[" ".len()..]);
} else {
Expand Down