summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2026-01-08 23:12:24 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2026-01-20 16:37:51 -0500
commit631a5076dabcb846157a4410bcccf202fce76127 (patch)
treeb9f5f45be434a365046dedfa6c84e95e615121d0
parent1bc51114114aae12f533e60e02a0dc606fb5d793 (diff)
ZJIT: Delete Insn::CPushAll and Insn::CPopAll
Since we automatically preserve registers across calls, it's never necessary to manually and imprecisely do it with `C{Push,Pop}All`. Delete them to remove the maintenance burden and reduce confusion.
-rw-r--r--zjit/src/backend/arm64/mod.rs66
-rw-r--r--zjit/src/backend/lir.rs23
-rw-r--r--zjit/src/backend/x86_64/mod.rs19
3 files changed, 0 insertions, 108 deletions
diff --git a/zjit/src/backend/arm64/mod.rs b/zjit/src/backend/arm64/mod.rs
index ea5d86659f..a019e2037d 100644
--- a/zjit/src/backend/arm64/mod.rs
+++ b/zjit/src/backend/arm64/mod.rs
@@ -1426,28 +1426,6 @@ impl Assembler {
Insn::CPopInto(opnd) => {
emit_pop(cb, opnd.into());
},
- Insn::CPushAll => {
- let regs = Assembler::get_caller_save_regs();
-
- for reg in regs {
- emit_push(cb, A64Opnd::Reg(reg));
- }
-
- // Push the flags/state register
- mrs(cb, Self::EMIT_OPND, SystemRegister::NZCV);
- emit_push(cb, Self::EMIT_OPND);
- },
- Insn::CPopAll => {
- let regs = Assembler::get_caller_save_regs();
-
- // Pop the state/flags register
- msr(cb, SystemRegister::NZCV, Self::EMIT_OPND);
- emit_pop(cb, Self::EMIT_OPND);
-
- for reg in regs.into_iter().rev() {
- emit_pop(cb, A64Opnd::Reg(reg));
- }
- },
Insn::CCall { fptr, .. } => {
match fptr {
Opnd::UImm(fptr) => {
@@ -1882,50 +1860,6 @@ mod tests {
}
#[test]
- fn test_emit_cpush_all() {
- let (mut asm, mut cb) = setup_asm();
-
- asm.cpush_all();
- asm.compile_with_num_regs(&mut cb, 0);
-
- assert_disasm_snapshot!(cb.disasm(), @r"
- 0x0: str x1, [sp, #-0x10]!
- 0x4: str x9, [sp, #-0x10]!
- 0x8: str x10, [sp, #-0x10]!
- 0xc: str x11, [sp, #-0x10]!
- 0x10: str x12, [sp, #-0x10]!
- 0x14: str x13, [sp, #-0x10]!
- 0x18: str x14, [sp, #-0x10]!
- 0x1c: str x15, [sp, #-0x10]!
- 0x20: mrs x16, nzcv
- 0x24: str x16, [sp, #-0x10]!
- ");
- assert_snapshot!(cb.hexdump(), @"e10f1ff8e90f1ff8ea0f1ff8eb0f1ff8ec0f1ff8ed0f1ff8ee0f1ff8ef0f1ff810423bd5f00f1ff8");
- }
-
- #[test]
- fn test_emit_cpop_all() {
- let (mut asm, mut cb) = setup_asm();
-
- asm.cpop_all();
- asm.compile_with_num_regs(&mut cb, 0);
-
- assert_disasm_snapshot!(cb.disasm(), @r"
- 0x0: msr nzcv, x16
- 0x4: ldr x16, [sp], #0x10
- 0x8: ldr x15, [sp], #0x10
- 0xc: ldr x14, [sp], #0x10
- 0x10: ldr x13, [sp], #0x10
- 0x14: ldr x12, [sp], #0x10
- 0x18: ldr x11, [sp], #0x10
- 0x1c: ldr x10, [sp], #0x10
- 0x20: ldr x9, [sp], #0x10
- 0x24: ldr x1, [sp], #0x10
- ");
- assert_snapshot!(cb.hexdump(), @"10421bd5f00741f8ef0741f8ee0741f8ed0741f8ec0741f8eb0741f8ea0741f8e90741f8e10741f8");
- }
-
- #[test]
fn test_emit_frame() {
let (mut asm, mut cb) = setup_asm();
diff --git a/zjit/src/backend/lir.rs b/zjit/src/backend/lir.rs
index d8d82a09ca..69ddbf2471 100644
--- a/zjit/src/backend/lir.rs
+++ b/zjit/src/backend/lir.rs
@@ -377,18 +377,12 @@ pub enum Insn {
/// Pop a register from the C stack
CPop { out: Opnd },
- /// Pop all of the caller-save registers and the flags from the C stack
- CPopAll,
-
/// Pop a register from the C stack and store it into another register
CPopInto(Opnd),
/// Push a register onto the C stack
CPush(Opnd),
- /// Push all of the caller-save registers and the flags to the C stack
- CPushAll,
-
// C function call with N arguments (variadic)
CCall {
opnds: Vec<Opnd>,
@@ -614,10 +608,8 @@ impl Insn {
Insn::Comment(_) => "Comment",
Insn::Cmp { .. } => "Cmp",
Insn::CPop { .. } => "CPop",
- Insn::CPopAll => "CPopAll",
Insn::CPopInto(_) => "CPopInto",
Insn::CPush(_) => "CPush",
- Insn::CPushAll => "CPushAll",
Insn::CCall { .. } => "CCall",
Insn::CRet(_) => "CRet",
Insn::CSelE { .. } => "CSelE",
@@ -851,8 +843,6 @@ impl<'a> Iterator for InsnOpndIterator<'a> {
Insn::Breakpoint |
Insn::Comment(_) |
Insn::CPop { .. } |
- Insn::CPopAll |
- Insn::CPushAll |
Insn::PadPatchPoint |
Insn::PosMarker(_) => None,
@@ -1020,8 +1010,6 @@ impl<'a> InsnOpndMutIterator<'a> {
Insn::Breakpoint |
Insn::Comment(_) |
Insn::CPop { .. } |
- Insn::CPopAll |
- Insn::CPushAll |
Insn::FrameSetup { .. } |
Insn::FrameTeardown { .. } |
Insn::PadPatchPoint |
@@ -1867,10 +1855,7 @@ impl Assembler
}
if should_record_exit {
- // Preserve caller-saved registers that may be used in the shared exit.
- self.cpush_all();
asm_ccall!(self, rb_zjit_record_exit_stack, pc);
- self.cpop_all();
}
// If the side exit has already been compiled, jump to it.
@@ -2135,10 +2120,6 @@ impl Assembler {
out
}
- pub fn cpop_all(&mut self) {
- self.push_insn(Insn::CPopAll);
- }
-
pub fn cpop_into(&mut self, opnd: Opnd) {
assert!(matches!(opnd, Opnd::Reg(_)), "Destination of cpop_into must be a register, got: {opnd:?}");
self.push_insn(Insn::CPopInto(opnd));
@@ -2148,10 +2129,6 @@ impl Assembler {
self.push_insn(Insn::CPush(opnd));
}
- pub fn cpush_all(&mut self) {
- self.push_insn(Insn::CPushAll);
- }
-
pub fn cret(&mut self, opnd: Opnd) {
self.push_insn(Insn::CRet(opnd));
}
diff --git a/zjit/src/backend/x86_64/mod.rs b/zjit/src/backend/x86_64/mod.rs
index b493a99929..c1b9b2da13 100644
--- a/zjit/src/backend/x86_64/mod.rs
+++ b/zjit/src/backend/x86_64/mod.rs
@@ -858,25 +858,6 @@ impl Assembler {
pop(cb, opnd.into());
},
- // Push and pop to the C stack all caller-save registers and the
- // flags
- Insn::CPushAll => {
- let regs = Assembler::get_caller_save_regs();
-
- for reg in regs {
- push(cb, X86Opnd::Reg(reg));
- }
- pushfq(cb);
- },
- Insn::CPopAll => {
- let regs = Assembler::get_caller_save_regs();
-
- popfq(cb);
- for reg in regs.into_iter().rev() {
- pop(cb, X86Opnd::Reg(reg));
- }
- },
-
// C function call
Insn::CCall { fptr, .. } => {
match fptr {