summaryrefslogtreecommitdiff
path: root/crates/parser/src/visit.rs
diff options
context:
space:
mode:
authorHenry <mail@henrygressmann.de>2026-04-01 20:39:33 +0200
committerHenry <mail@henrygressmann.de>2026-04-01 20:39:33 +0200
commitc3b1f582f44747cb4343b51ffb208334c973c67c (patch)
tree5a390555e495849110520a463e992dd2a390d7b5 /crates/parser/src/visit.rs
parent0ed3e1d29dca7d27e0d3aa1780f7cacc9481aa46 (diff)
chore: cleanup + add wasm intrinsics
Signed-off-by: Henry <mail@henrygressmann.de>
Diffstat (limited to 'crates/parser/src/visit.rs')
-rw-r--r--crates/parser/src/visit.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/parser/src/visit.rs b/crates/parser/src/visit.rs
index b71185e..7eefa1c 100644
--- a/crates/parser/src/visit.rs
+++ b/crates/parser/src/visit.rs
@@ -657,6 +657,9 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
}
fn visit_loop(&mut self, _ty: wasmparser::BlockType) -> Self::Output {
+ if !matches!(self.instructions.last(), Some(Instruction::Nop)) {
+ self.instructions.push(Instruction::Nop); // add nop to ensure that no superinstruction can be merged across block boundaries
+ }
let start_ip = self.instructions.len();
self.ctx_stack.push(LoweringCtx { kind: BlockKind::Loop, has_else: false, start_ip, branch_jumps: Vec::new() });
}
@@ -683,7 +686,7 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
ctx.branch_jumps.push(jump_ip);
self.patch_jump_if_zero(cond_jump_ip, self.instructions.len());
if !matches!(self.instructions.last(), Some(Instruction::Nop)) {
- self.instructions.push(Instruction::Nop);
+ self.instructions.push(Instruction::Nop); // add nop to ensure that no superinstruction can be merged across block boundaries
}
};
};
@@ -693,7 +696,7 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
if let Some(ctx) = self.ctx_stack.pop() {
self.patch_end_jumps(ctx, self.instructions.len());
if !matches!(self.instructions.last(), Some(Instruction::Nop)) {
- self.instructions.push(Instruction::Nop);
+ self.instructions.push(Instruction::Nop); // add nop to ensure that no superinstruction can be merged across block boundaries
}
} else {
self.instructions.push(Instruction::Return);