Skip to content

Commit 36809a8

Browse files
committed
ZJIT: Add fail-fast assert for non-register {cpush,cpop}_pair
There is no splitting for these so let's add a assert to try and catch misuse. VRegs are not necessarily registers in the end, so this is best effort. In those situations they'll get a less proximate panic message.
1 parent f7e73ba commit 36809a8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

zjit/src/backend/lir.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,15 +2159,21 @@ impl Assembler {
21592159
self.push_insn(Insn::CPopInto(opnd));
21602160
}
21612161

2162+
#[track_caller]
21622163
pub fn cpop_pair_into(&mut self, opnd0: Opnd, opnd1: Opnd) {
2164+
assert!(matches!(opnd0, Opnd::Reg(_) | Opnd::VReg{ .. }), "Destination of cpop_pair_into must be a register, got: {opnd0:?}");
2165+
assert!(matches!(opnd1, Opnd::Reg(_) | Opnd::VReg{ .. }), "Destination of cpop_pair_into must be a register, got: {opnd1:?}");
21632166
self.push_insn(Insn::CPopPairInto(opnd0, opnd1));
21642167
}
21652168

21662169
pub fn cpush(&mut self, opnd: Opnd) {
21672170
self.push_insn(Insn::CPush(opnd));
21682171
}
21692172

2173+
#[track_caller]
21702174
pub fn cpush_pair(&mut self, opnd0: Opnd, opnd1: Opnd) {
2175+
assert!(matches!(opnd0, Opnd::Reg(_) | Opnd::VReg{ .. }), "Destination of cpush_pair must be a register, got: {opnd0:?}");
2176+
assert!(matches!(opnd1, Opnd::Reg(_) | Opnd::VReg{ .. }), "Destination of cpush_pair must be a register, got: {opnd1:?}");
21712177
self.push_insn(Insn::CPushPair(opnd0, opnd1));
21722178
}
21732179

0 commit comments

Comments
 (0)