Skip to content

Commit 94ec574

Browse files
committed
ZJIT: Drop PartialEq from FrameState
No one was actually doing equality comparison on `FrameState`s and it was only derived because `FrameState` was in `ParseError::StackUnderflow`. No one was reading the `FrameState` out of `StackUnderflow` either. Save some binary size.
1 parent 0ea980a commit 94ec574

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

zjit/src/hir.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8058,7 +8058,7 @@ impl<'a> std::fmt::Display for FunctionPrinter<'a> {
80588058
}
80598059
}
80608060

8061-
#[derive(Debug, Clone, PartialEq)]
8061+
#[derive(Debug, Clone)]
80628062
pub struct FrameState {
80638063
pub iseq: IseqPtr,
80648064
insn_idx: YarvInsnIdx,
@@ -8177,22 +8177,22 @@ impl FrameState {
81778177

81788178
/// Pop a stack operand
81798179
fn stack_pop(&mut self) -> Result<InsnId, ParseError> {
8180-
self.stack.pop().ok_or_else(|| ParseError::StackUnderflow(self.clone()))
8180+
self.stack.pop().ok_or_else(|| ParseError::StackUnderflow(self.insn_idx))
81818181
}
81828182

81838183
fn stack_pop_n(&mut self, count: usize) -> Result<Vec<InsnId>, ParseError> {
81848184
// Check if we have enough values on the stack
81858185
let stack_len = self.stack.len();
81868186
if stack_len < count {
8187-
return Err(ParseError::StackUnderflow(self.clone()));
8187+
return Err(ParseError::StackUnderflow(self.insn_idx));
81888188
}
81898189

81908190
Ok(self.stack.split_off(stack_len - count))
81918191
}
81928192

81938193
/// Get a stack-top operand
81948194
fn stack_top(&self) -> Result<InsnId, ParseError> {
8195-
self.stack.last().ok_or_else(|| ParseError::StackUnderflow(self.clone())).copied()
8195+
self.stack.last().ok_or_else(|| ParseError::StackUnderflow(self.insn_idx)).copied()
81968196
}
81978197

81988198
/// Set a stack operand at idx
@@ -8204,9 +8204,9 @@ impl FrameState {
82048204
/// Get a stack operand at idx
82058205
fn stack_topn(&self, idx: usize) -> Result<InsnId, ParseError> {
82068206
let Some(idx) = self.stack.len().checked_sub(idx + 1) else {
8207-
return Err(ParseError::StackUnderflow(self.clone()));
8207+
return Err(ParseError::StackUnderflow(self.insn_idx));
82088208
};
8209-
self.stack.get(idx).ok_or_else(|| ParseError::StackUnderflow(self.clone())).copied()
8209+
self.stack.get(idx).ok_or_else(|| ParseError::StackUnderflow(self.insn_idx)).copied()
82108210
}
82118211

82128212
fn setlocal(&mut self, ep_offset: u32, opnd: InsnId) {
@@ -8327,7 +8327,8 @@ pub enum CallType {
83278327

83288328
#[derive(Clone, Debug, PartialEq)]
83298329
pub enum ParseError {
8330-
StackUnderflow(FrameState),
8330+
/// Instruction index of the YARV instruction that underflowed the stack.
8331+
StackUnderflow(YarvInsnIdx),
83318332
MalformedIseq(u32), // insn_idx into iseq_encoded
83328333
Validation(ValidationError),
83338334
NotAllowed,

0 commit comments

Comments
 (0)