From f2192cfde1bee833691a9f8768b3cad60de5e874 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Wed, 29 Oct 2025 15:26:15 -0700 Subject: ZJIT: Rename compile_side_exits to compile_exits so that it can be easily specified with `--zjit-dump-lir=`. --- zjit/src/backend/arm64/mod.rs | 18 +++++++++--------- zjit/src/backend/lir.rs | 2 +- zjit/src/backend/x86_64/mod.rs | 38 +++++++++++++++++++------------------- zjit/src/options.rs | 8 ++++---- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/zjit/src/backend/arm64/mod.rs b/zjit/src/backend/arm64/mod.rs index 9e94fd0e49..d762b14c91 100644 --- a/zjit/src/backend/arm64/mod.rs +++ b/zjit/src/backend/arm64/mod.rs @@ -687,7 +687,7 @@ impl Assembler { /// Split instructions using scratch registers. To maximize the use of the register pool for /// VRegs, most splits should happen in [`Self::arm64_split`]. However, some instructions - /// need to be split with registers after `alloc_regs`, e.g. for `compile_side_exits`, so this + /// need to be split with registers after `alloc_regs`, e.g. for `compile_exits`, so this /// splits them and uses scratch registers for it. fn arm64_scratch_split(self) -> Assembler { let mut asm = Assembler::new_with_asm(&self); @@ -706,7 +706,7 @@ impl Assembler { asm.push_insn(Insn::RShift { out: SCRATCH0_OPND, opnd: out, shift: Opnd::UImm(63) }); } } - // For compile_side_exits, support splitting simple C arguments here + // For compile_exits, support splitting simple C arguments here Insn::CCall { opnds, .. } if !opnds.is_empty() => { for (i, opnd) in opnds.iter().enumerate() { asm.load_into(C_ARG_OPNDS[i], *opnd); @@ -716,7 +716,7 @@ impl Assembler { } &mut Insn::Lea { opnd, out } => { match (opnd, out) { - // Split here for compile_side_exits + // Split here for compile_exits (Opnd::Mem(_), Opnd::Mem(_)) => { asm.lea_into(SCRATCH0_OPND, opnd); asm.store(out, SCRATCH0_OPND); @@ -728,7 +728,7 @@ impl Assembler { } &mut Insn::IncrCounter { mem, value } => { // Convert Opnd::const_ptr into Opnd::Mem. - // It's split here to support IncrCounter in compile_side_exits. + // It's split here to support IncrCounter in compile_exits. assert!(matches!(mem, Opnd::UImm(_))); asm.load_into(SCRATCH0_OPND, mem); asm.lea_into(SCRATCH0_OPND, Opnd::mem(64, SCRATCH0_OPND, 0)); @@ -872,7 +872,7 @@ impl Assembler { }); }, Target::SideExit { .. } => { - unreachable!("Target::SideExit should have been compiled by compile_side_exits") + unreachable!("Target::SideExit should have been compiled by compile_exits") }, }; } @@ -1349,7 +1349,7 @@ impl Assembler { }); }, Target::SideExit { .. } => { - unreachable!("Target::SideExit should have been compiled by compile_side_exits") + unreachable!("Target::SideExit should have been compiled by compile_exits") }, }; }, @@ -1471,9 +1471,9 @@ impl Assembler { let mut asm = asm.alloc_regs(regs)?; asm_dump!(asm, alloc_regs); - // We put compile_side_exits after alloc_regs to avoid extending live ranges for VRegs spilled on side exits. - asm.compile_side_exits(); - asm_dump!(asm, compile_side_exits); + // We put compile_exits after alloc_regs to avoid extending live ranges for VRegs spilled on side exits. + asm.compile_exits(); + asm_dump!(asm, compile_exits); if use_scratch_reg { asm = asm.arm64_scratch_split(); diff --git a/zjit/src/backend/lir.rs b/zjit/src/backend/lir.rs index 5980e9e022..005df140b8 100644 --- a/zjit/src/backend/lir.rs +++ b/zjit/src/backend/lir.rs @@ -1701,7 +1701,7 @@ impl Assembler } /// Compile Target::SideExit and convert it into Target::CodePtr for all instructions - pub fn compile_side_exits(&mut self) { + pub fn compile_exits(&mut self) { fn join_opnds(opnds: &Vec, delimiter: &str) -> String { opnds.iter().map(|opnd| format!("{opnd}")).collect::>().join(delimiter) } diff --git a/zjit/src/backend/x86_64/mod.rs b/zjit/src/backend/x86_64/mod.rs index eb0e703302..14c0df8dd0 100644 --- a/zjit/src/backend/x86_64/mod.rs +++ b/zjit/src/backend/x86_64/mod.rs @@ -388,7 +388,7 @@ impl Assembler { /// Split instructions using scratch registers. To maximize the use of the register pool /// for VRegs, most splits should happen in [`Self::x86_split`]. However, some instructions - /// need to be split with registers after `alloc_regs`, e.g. for `compile_side_exits`, so + /// need to be split with registers after `alloc_regs`, e.g. for `compile_exits`, so /// this splits them and uses scratch registers for it. pub fn x86_scratch_split(self) -> Assembler { /// For some instructions, we want to be able to lower a 64-bit operand @@ -454,7 +454,7 @@ impl Assembler { } asm.push_insn(insn); } - // For compile_side_exits, support splitting simple C arguments here + // For compile_exits, support splitting simple C arguments here Insn::CCall { opnds, .. } if !opnds.is_empty() => { for (i, opnd) in opnds.iter().enumerate() { asm.load_into(C_ARG_OPNDS[i], *opnd); @@ -464,7 +464,7 @@ impl Assembler { } &mut Insn::Lea { opnd, out } => { match (opnd, out) { - // Split here for compile_side_exits + // Split here for compile_exits (Opnd::Mem(_), Opnd::Mem(_)) => { asm.lea_into(SCRATCH0_OPND, opnd); asm.store(out, SCRATCH0_OPND); @@ -481,7 +481,7 @@ impl Assembler { } } // Convert Opnd::const_ptr into Opnd::Mem. This split is done here to give - // a register for compile_side_exits. + // a register for compile_exits. &mut Insn::IncrCounter { mem, value } => { assert!(matches!(mem, Opnd::UImm(_))); asm.load_into(SCRATCH0_OPND, mem); @@ -493,7 +493,7 @@ impl Assembler { asm.mov(dst, src) } } - // Handle various operand combinations for spills on compile_side_exits. + // Handle various operand combinations for spills on compile_exits. &mut Insn::Store { dest, src } => { let Opnd::Mem(Mem { num_bits, .. }) = dest else { panic!("Unexpected Insn::Store destination in x86_scratch_split: {dest:?}"); @@ -801,7 +801,7 @@ impl Assembler { match *target { Target::CodePtr(code_ptr) => jmp_ptr(cb, code_ptr), Target::Label(label) => jmp_label(cb, label), - Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_side_exits"), + Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_exits"), } } @@ -809,7 +809,7 @@ impl Assembler { match *target { Target::CodePtr(code_ptr) => je_ptr(cb, code_ptr), Target::Label(label) => je_label(cb, label), - Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_side_exits"), + Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_exits"), } } @@ -817,7 +817,7 @@ impl Assembler { match *target { Target::CodePtr(code_ptr) => jne_ptr(cb, code_ptr), Target::Label(label) => jne_label(cb, label), - Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_side_exits"), + Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_exits"), } } @@ -825,7 +825,7 @@ impl Assembler { match *target { Target::CodePtr(code_ptr) => jl_ptr(cb, code_ptr), Target::Label(label) => jl_label(cb, label), - Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_side_exits"), + Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_exits"), } }, @@ -833,7 +833,7 @@ impl Assembler { match *target { Target::CodePtr(code_ptr) => jg_ptr(cb, code_ptr), Target::Label(label) => jg_label(cb, label), - Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_side_exits"), + Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_exits"), } }, @@ -841,7 +841,7 @@ impl Assembler { match *target { Target::CodePtr(code_ptr) => jge_ptr(cb, code_ptr), Target::Label(label) => jge_label(cb, label), - Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_side_exits"), + Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_exits"), } }, @@ -849,7 +849,7 @@ impl Assembler { match *target { Target::CodePtr(code_ptr) => jbe_ptr(cb, code_ptr), Target::Label(label) => jbe_label(cb, label), - Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_side_exits"), + Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_exits"), } }, @@ -857,7 +857,7 @@ impl Assembler { match *target { Target::CodePtr(code_ptr) => jb_ptr(cb, code_ptr), Target::Label(label) => jb_label(cb, label), - Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_side_exits"), + Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_exits"), } }, @@ -865,7 +865,7 @@ impl Assembler { match *target { Target::CodePtr(code_ptr) => jz_ptr(cb, code_ptr), Target::Label(label) => jz_label(cb, label), - Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_side_exits"), + Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_exits"), } } @@ -873,7 +873,7 @@ impl Assembler { match *target { Target::CodePtr(code_ptr) => jnz_ptr(cb, code_ptr), Target::Label(label) => jnz_label(cb, label), - Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_side_exits"), + Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_exits"), } } @@ -882,7 +882,7 @@ impl Assembler { match *target { Target::CodePtr(code_ptr) => jo_ptr(cb, code_ptr), Target::Label(label) => jo_label(cb, label), - Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_side_exits"), + Target::SideExit { .. } => unreachable!("Target::SideExit should have been compiled by compile_exits"), } } @@ -969,9 +969,9 @@ impl Assembler { let mut asm = asm.alloc_regs(regs)?; asm_dump!(asm, alloc_regs); - // We put compile_side_exits after alloc_regs to avoid extending live ranges for VRegs spilled on side exits. - asm.compile_side_exits(); - asm_dump!(asm, compile_side_exits); + // We put compile_exits after alloc_regs to avoid extending live ranges for VRegs spilled on side exits. + asm.compile_exits(); + asm_dump!(asm, compile_exits); if use_scratch_regs { asm = asm.x86_scratch_split(); diff --git a/zjit/src/options.rs b/zjit/src/options.rs index 34a9afce06..f6471b5461 100644 --- a/zjit/src/options.rs +++ b/zjit/src/options.rs @@ -160,8 +160,8 @@ pub enum DumpLIR { split, /// Dump LIR after alloc_regs alloc_regs, - /// Dump LIR after compile_side_exits - compile_side_exits, + /// Dump LIR after compile_exits + compile_exits, /// Dump LIR after {arch}_scratch_split scratch_split, } @@ -171,7 +171,7 @@ const DUMP_LIR_ALL: &[DumpLIR] = &[ DumpLIR::init, DumpLIR::split, DumpLIR::alloc_regs, - DumpLIR::compile_side_exits, + DumpLIR::compile_exits, DumpLIR::scratch_split, ]; @@ -352,7 +352,7 @@ fn parse_option(str_ptr: *const std::os::raw::c_char) -> Option<()> { "init" => DumpLIR::init, "split" => DumpLIR::split, "alloc_regs" => DumpLIR::alloc_regs, - "compile_side_exits" => DumpLIR::compile_side_exits, + "compile_exits" => DumpLIR::compile_exits, "scratch_split" => DumpLIR::scratch_split, _ => { let valid_options = DUMP_LIR_ALL.iter().map(|opt| format!("{opt:?}")).collect::>().join(", "); -- cgit v1.2.3