summaryrefslogtreecommitdiff
path: root/crates/parser/src/visit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/parser/src/visit.rs')
-rw-r--r--crates/parser/src/visit.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/parser/src/visit.rs b/crates/parser/src/visit.rs
index 5c99df2..5e1ca15 100644
--- a/crates/parser/src/visit.rs
+++ b/crates/parser/src/visit.rs
@@ -240,8 +240,8 @@ 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
+ if !matches!(self.instructions.last(), Some(Instruction::Nop | Instruction::MergeBarrier)) {
+ self.instructions.push(Instruction::MergeBarrier); // prevent superinstructions from merging 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() });
@@ -266,8 +266,8 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
ctx.has_else = true;
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); // add nop to ensure that no superinstruction can be merged across block boundaries
+ if !matches!(self.instructions.last(), Some(Instruction::Nop | Instruction::MergeBarrier)) {
+ self.instructions.push(Instruction::MergeBarrier); // prevent superinstructions from merging across block boundaries
}
};
};
@@ -276,8 +276,8 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
fn visit_end(&mut self) -> Self::Output {
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); // add nop to ensure that no superinstruction can be merged across block boundaries
+ if !matches!(self.instructions.last(), Some(Instruction::Nop | Instruction::MergeBarrier)) {
+ self.instructions.push(Instruction::MergeBarrier); // prevent superinstructions from merging across block boundaries
}
} else {
self.instructions.push(Instruction::Return);