Skip to content

Commit 606b3a8

Browse files
committed
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.
1 parent d8f5ff4 commit 606b3a8

File tree

3 files changed

+0
-108
lines changed

3 files changed

+0
-108
lines changed

zjit/src/backend/arm64/mod.rs

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,28 +1426,6 @@ impl Assembler {
14261426
Insn::CPopInto(opnd) => {
14271427
emit_pop(cb, opnd.into());
14281428
},
1429-
Insn::CPushAll => {
1430-
let regs = Assembler::get_caller_save_regs();
1431-
1432-
for reg in regs {
1433-
emit_push(cb, A64Opnd::Reg(reg));
1434-
}
1435-
1436-
// Push the flags/state register
1437-
mrs(cb, Self::EMIT_OPND, SystemRegister::NZCV);
1438-
emit_push(cb, Self::EMIT_OPND);
1439-
},
1440-
Insn::CPopAll => {
1441-
let regs = Assembler::get_caller_save_regs();
1442-
1443-
// Pop the state/flags register
1444-
msr(cb, SystemRegister::NZCV, Self::EMIT_OPND);
1445-
emit_pop(cb, Self::EMIT_OPND);
1446-
1447-
for reg in regs.into_iter().rev() {
1448-
emit_pop(cb, A64Opnd::Reg(reg));
1449-
}
1450-
},
14511429
Insn::CCall { fptr, .. } => {
14521430
match fptr {
14531431
Opnd::UImm(fptr) => {
@@ -1881,50 +1859,6 @@ mod tests {
18811859
assert_snapshot!(cb.hexdump(), @"48656c6c6f2c20776f726c6421000000");
18821860
}
18831861

1884-
#[test]
1885-
fn test_emit_cpush_all() {
1886-
let (mut asm, mut cb) = setup_asm();
1887-
1888-
asm.cpush_all();
1889-
asm.compile_with_num_regs(&mut cb, 0);
1890-
1891-
assert_disasm_snapshot!(cb.disasm(), @r"
1892-
0x0: str x1, [sp, #-0x10]!
1893-
0x4: str x9, [sp, #-0x10]!
1894-
0x8: str x10, [sp, #-0x10]!
1895-
0xc: str x11, [sp, #-0x10]!
1896-
0x10: str x12, [sp, #-0x10]!
1897-
0x14: str x13, [sp, #-0x10]!
1898-
0x18: str x14, [sp, #-0x10]!
1899-
0x1c: str x15, [sp, #-0x10]!
1900-
0x20: mrs x16, nzcv
1901-
0x24: str x16, [sp, #-0x10]!
1902-
");
1903-
assert_snapshot!(cb.hexdump(), @"e10f1ff8e90f1ff8ea0f1ff8eb0f1ff8ec0f1ff8ed0f1ff8ee0f1ff8ef0f1ff810423bd5f00f1ff8");
1904-
}
1905-
1906-
#[test]
1907-
fn test_emit_cpop_all() {
1908-
let (mut asm, mut cb) = setup_asm();
1909-
1910-
asm.cpop_all();
1911-
asm.compile_with_num_regs(&mut cb, 0);
1912-
1913-
assert_disasm_snapshot!(cb.disasm(), @r"
1914-
0x0: msr nzcv, x16
1915-
0x4: ldr x16, [sp], #0x10
1916-
0x8: ldr x15, [sp], #0x10
1917-
0xc: ldr x14, [sp], #0x10
1918-
0x10: ldr x13, [sp], #0x10
1919-
0x14: ldr x12, [sp], #0x10
1920-
0x18: ldr x11, [sp], #0x10
1921-
0x1c: ldr x10, [sp], #0x10
1922-
0x20: ldr x9, [sp], #0x10
1923-
0x24: ldr x1, [sp], #0x10
1924-
");
1925-
assert_snapshot!(cb.hexdump(), @"10421bd5f00741f8ef0741f8ee0741f8ed0741f8ec0741f8eb0741f8ea0741f8e90741f8e10741f8");
1926-
}
1927-
19281862
#[test]
19291863
fn test_emit_frame() {
19301864
let (mut asm, mut cb) = setup_asm();

zjit/src/backend/lir.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -377,18 +377,12 @@ pub enum Insn {
377377
/// Pop a register from the C stack
378378
CPop { out: Opnd },
379379

380-
/// Pop all of the caller-save registers and the flags from the C stack
381-
CPopAll,
382-
383380
/// Pop a register from the C stack and store it into another register
384381
CPopInto(Opnd),
385382

386383
/// Push a register onto the C stack
387384
CPush(Opnd),
388385

389-
/// Push all of the caller-save registers and the flags to the C stack
390-
CPushAll,
391-
392386
// C function call with N arguments (variadic)
393387
CCall {
394388
opnds: Vec<Opnd>,
@@ -614,10 +608,8 @@ impl Insn {
614608
Insn::Comment(_) => "Comment",
615609
Insn::Cmp { .. } => "Cmp",
616610
Insn::CPop { .. } => "CPop",
617-
Insn::CPopAll => "CPopAll",
618611
Insn::CPopInto(_) => "CPopInto",
619612
Insn::CPush(_) => "CPush",
620-
Insn::CPushAll => "CPushAll",
621613
Insn::CCall { .. } => "CCall",
622614
Insn::CRet(_) => "CRet",
623615
Insn::CSelE { .. } => "CSelE",
@@ -851,8 +843,6 @@ impl<'a> Iterator for InsnOpndIterator<'a> {
851843
Insn::Breakpoint |
852844
Insn::Comment(_) |
853845
Insn::CPop { .. } |
854-
Insn::CPopAll |
855-
Insn::CPushAll |
856846
Insn::PadPatchPoint |
857847
Insn::PosMarker(_) => None,
858848

@@ -1020,8 +1010,6 @@ impl<'a> InsnOpndMutIterator<'a> {
10201010
Insn::Breakpoint |
10211011
Insn::Comment(_) |
10221012
Insn::CPop { .. } |
1023-
Insn::CPopAll |
1024-
Insn::CPushAll |
10251013
Insn::FrameSetup { .. } |
10261014
Insn::FrameTeardown { .. } |
10271015
Insn::PadPatchPoint |
@@ -1867,10 +1855,7 @@ impl Assembler
18671855
}
18681856

18691857
if should_record_exit {
1870-
// Preserve caller-saved registers that may be used in the shared exit.
1871-
self.cpush_all();
18721858
asm_ccall!(self, rb_zjit_record_exit_stack, pc);
1873-
self.cpop_all();
18741859
}
18751860

18761861
// If the side exit has already been compiled, jump to it.
@@ -2135,10 +2120,6 @@ impl Assembler {
21352120
out
21362121
}
21372122

2138-
pub fn cpop_all(&mut self) {
2139-
self.push_insn(Insn::CPopAll);
2140-
}
2141-
21422123
pub fn cpop_into(&mut self, opnd: Opnd) {
21432124
assert!(matches!(opnd, Opnd::Reg(_)), "Destination of cpop_into must be a register, got: {opnd:?}");
21442125
self.push_insn(Insn::CPopInto(opnd));
@@ -2148,10 +2129,6 @@ impl Assembler {
21482129
self.push_insn(Insn::CPush(opnd));
21492130
}
21502131

2151-
pub fn cpush_all(&mut self) {
2152-
self.push_insn(Insn::CPushAll);
2153-
}
2154-
21552132
pub fn cret(&mut self, opnd: Opnd) {
21562133
self.push_insn(Insn::CRet(opnd));
21572134
}

zjit/src/backend/x86_64/mod.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -858,25 +858,6 @@ impl Assembler {
858858
pop(cb, opnd.into());
859859
},
860860

861-
// Push and pop to the C stack all caller-save registers and the
862-
// flags
863-
Insn::CPushAll => {
864-
let regs = Assembler::get_caller_save_regs();
865-
866-
for reg in regs {
867-
push(cb, X86Opnd::Reg(reg));
868-
}
869-
pushfq(cb);
870-
},
871-
Insn::CPopAll => {
872-
let regs = Assembler::get_caller_save_regs();
873-
874-
popfq(cb);
875-
for reg in regs.into_iter().rev() {
876-
pop(cb, X86Opnd::Reg(reg));
877-
}
878-
},
879-
880861
// C function call
881862
Insn::CCall { fptr, .. } => {
882863
match fptr {

0 commit comments

Comments
 (0)