@@ -240,8 +240,8 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
240240 }
241241
242242 fn visit_loop ( & mut self , _ty : wasmparser:: BlockType ) -> Self :: Output {
243- if !matches ! ( self . instructions. last( ) , Some ( Instruction :: Nop ) ) {
244- self . instructions . push ( Instruction :: Nop ) ; // add nop to ensure that no superinstruction can be merged across block boundaries
243+ if !matches ! ( self . instructions. last( ) , Some ( Instruction :: Nop | Instruction :: MergeBarrier ) ) {
244+ self . instructions . push ( Instruction :: MergeBarrier ) ; // prevent superinstructions from merging across block boundaries
245245 }
246246 let start_ip = self . instructions . len ( ) ;
247247 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
266266 ctx. has_else = true ;
267267 ctx. branch_jumps . push ( jump_ip) ;
268268 self . patch_jump_if_zero ( cond_jump_ip, self . instructions . len ( ) ) ;
269- if !matches ! ( self . instructions. last( ) , Some ( Instruction :: Nop ) ) {
270- self . instructions . push ( Instruction :: Nop ) ; // add nop to ensure that no superinstruction can be merged across block boundaries
269+ if !matches ! ( self . instructions. last( ) , Some ( Instruction :: Nop | Instruction :: MergeBarrier ) ) {
270+ self . instructions . push ( Instruction :: MergeBarrier ) ; // prevent superinstructions from merging across block boundaries
271271 }
272272 } ;
273273 } ;
@@ -276,8 +276,8 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
276276 fn visit_end ( & mut self ) -> Self :: Output {
277277 if let Some ( ctx) = self . ctx_stack . pop ( ) {
278278 self . patch_end_jumps ( ctx, self . instructions . len ( ) ) ;
279- if !matches ! ( self . instructions. last( ) , Some ( Instruction :: Nop ) ) {
280- self . instructions . push ( Instruction :: Nop ) ; // add nop to ensure that no superinstruction can be merged across block boundaries
279+ if !matches ! ( self . instructions. last( ) , Some ( Instruction :: Nop | Instruction :: MergeBarrier ) ) {
280+ self . instructions . push ( Instruction :: MergeBarrier ) ; // prevent superinstructions from merging across block boundaries
281281 }
282282 } else {
283283 self . instructions . push ( Instruction :: Return ) ;
0 commit comments