Skip to content

Commit

Permalink
Fix val_cnt for if (#706)
Browse files Browse the repository at this point in the history
#46

---------

Co-authored-by: Zhou Fang <33002388+zhou-w-fang@users.noreply.github.com>
Co-authored-by: Julien Cretin <cretin@google.com>
  • Loading branch information
3 people authored Dec 23, 2024
1 parent de94f8c commit 18bedde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 0 additions & 2 deletions crates/interpreter/src/side_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use crate::bit_field::*;
use crate::error::*;

#[allow(dead_code)] // TODO(dev/fast-interp)
#[derive(Default, Copy, Clone, Debug)]
#[repr(transparent)]
pub struct SideTableEntry(u64);
Expand All @@ -31,7 +30,6 @@ pub struct SideTableEntryView {
pub pop_cnt: u32,
}

#[allow(dead_code)] // TODO(dev/fast-interp)
impl SideTableEntry {
const DELTA_IP_MASK: u64 = 0xffff;
const DELTA_STP_MASK: u64 = 0xffff << 16;
Expand Down
7 changes: 4 additions & 3 deletions crates/interpreter/src/valid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ impl SideTable {
let delta_stp = Self::delta(source, target, |x| x.side_table as isize)?;
let val_cnt = u32::try_from(target.result).map_err(|_| {
#[cfg(feature = "debug")]
eprintln!("side-table val_cnt overflow {0}", source.result);
eprintln!("side-table val_cnt overflow {0}", target.result);
unsupported(if_debug!(Unsupported::SideTable))
})?;
let pop_cnt = Self::pop_cnt(source, target)?;
Expand Down Expand Up @@ -487,7 +487,7 @@ struct SideTableBranch<'m> {
parser: &'m [u8],
side_table: usize,
stack: usize,
result: usize, // unused (zero) for target branches
result: usize, // unused (zero) for source branches
}

#[derive(Debug, Default)]
Expand Down Expand Up @@ -600,7 +600,8 @@ impl<'a, 'm> Expr<'a, 'm> {
Else => {
match core::mem::replace(&mut self.label().kind, LabelKind::Block) {
LabelKind::If(source) => {
let mut target = self.branch_target(source.result);
let result = self.label().type_.results.len();
let mut target = self.branch_target(result);
target.side_table += 1;
self.side_table.stitch(source, target)?
}
Expand Down

0 comments on commit 18bedde

Please sign in to comment.