@@ -22,7 +22,6 @@ struct StackBase {
2222 s32 : u16 ,
2323 s64 : u16 ,
2424 s128 : u16 ,
25- sref : u16 ,
2625}
2726
2827struct LoweringCtx {
@@ -214,7 +213,7 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
214213 wasmparser:: ValType :: I64 => Instruction :: GlobalSet64 ( global_index) ,
215214 wasmparser:: ValType :: F64 => Instruction :: GlobalSet64 ( global_index) ,
216215 wasmparser:: ValType :: V128 => Instruction :: GlobalSet128 ( global_index) ,
217- wasmparser:: ValType :: Ref ( _) => Instruction :: GlobalSetRef ( global_index) ,
216+ wasmparser:: ValType :: Ref ( _) => Instruction :: GlobalSet32 ( global_index) ,
218217 } )
219218 }
220219 }
@@ -227,7 +226,7 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
227226 wasmparser:: ValType :: I64 => Instruction :: Drop64 ,
228227 wasmparser:: ValType :: F64 => Instruction :: Drop64 ,
229228 wasmparser:: ValType :: V128 => Instruction :: Drop128 ,
230- wasmparser:: ValType :: Ref ( _) => Instruction :: DropRef ,
229+ wasmparser:: ValType :: Ref ( _) => Instruction :: Drop32 ,
231230 } )
232231 }
233232 }
@@ -257,7 +256,7 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
257256 self . instructions . push ( Instruction :: LocalGet128 ( resolved_idx) ) ;
258257 }
259258 wasmparser:: ValType :: Ref ( _) => {
260- self . instructions . push ( Instruction :: LocalGetRef ( resolved_idx) ) ;
259+ self . instructions . push ( Instruction :: LocalGet32 ( resolved_idx) ) ;
261260 }
262261 }
263262 }
@@ -272,7 +271,7 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
272271 wasmparser:: ValType :: I64 => Instruction :: LocalSet64 ( resolved_idx) ,
273272 wasmparser:: ValType :: F64 => Instruction :: LocalSet64 ( resolved_idx) ,
274273 wasmparser:: ValType :: V128 => Instruction :: LocalSet128 ( resolved_idx) ,
275- wasmparser:: ValType :: Ref ( _) => Instruction :: LocalSetRef ( resolved_idx) ,
274+ wasmparser:: ValType :: Ref ( _) => Instruction :: LocalSet32 ( resolved_idx) ,
276275 } )
277276 }
278277 }
@@ -286,7 +285,7 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
286285 wasmparser:: ValType :: I64 => Instruction :: LocalTee64 ( resolved_idx) ,
287286 wasmparser:: ValType :: F64 => Instruction :: LocalTee64 ( resolved_idx) ,
288287 wasmparser:: ValType :: V128 => Instruction :: LocalTee128 ( resolved_idx) ,
289- wasmparser:: ValType :: Ref ( _) => Instruction :: LocalTeeRef ( resolved_idx) ,
288+ wasmparser:: ValType :: Ref ( _) => Instruction :: LocalTee32 ( resolved_idx) ,
290289 } )
291290 }
292291 }
@@ -457,8 +456,8 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
457456 }
458457
459458 fn visit_typed_select_multi ( & mut self , tys : Vec < wasmparser:: ValType > ) -> Self :: Output {
460- let ( c32, c64, c128, cref ) = Self :: label_keep_counts ( & tys) ;
461- self . instructions . push ( Instruction :: SelectMulti ( tinywasm_types:: ValueCounts { c32, c64, c128, cref } ) ) ;
459+ let ( c32, c64, c128) = Self :: label_keep_counts ( & tys) ;
460+ self . instructions . push ( Instruction :: SelectMulti ( tinywasm_types:: ValueCounts { c32, c64, c128 } ) ) ;
462461 }
463462
464463 fn visit_typed_select ( & mut self , ty : wasmparser:: ValType ) -> Self :: Output {
@@ -468,7 +467,7 @@ impl<'a, R: WasmModuleResources> wasmparser::VisitOperator<'a> for FunctionBuild
468467 wasmparser:: ValType :: I64 => Instruction :: Select64 ,
469468 wasmparser:: ValType :: F64 => Instruction :: Select64 ,
470469 wasmparser:: ValType :: V128 => Instruction :: Select128 ,
471- wasmparser:: ValType :: Ref ( _) => Instruction :: SelectRef ,
470+ wasmparser:: ValType :: Ref ( _) => Instruction :: Select32 ,
472471 } ) ;
473472 }
474473
@@ -595,7 +594,7 @@ impl<R: WasmModuleResources> FunctionBuilder<R> {
595594 wasmparser:: ValType :: I32 | wasmparser:: ValType :: F32 => base. s32 += 1 ,
596595 wasmparser:: ValType :: I64 | wasmparser:: ValType :: F64 => base. s64 += 1 ,
597596 wasmparser:: ValType :: V128 => base. s128 += 1 ,
598- wasmparser:: ValType :: Ref ( _) => base. sref += 1 ,
597+ wasmparser:: ValType :: Ref ( _) => base. s32 += 1 ,
599598 }
600599 }
601600 }
@@ -617,16 +616,8 @@ impl<R: WasmModuleResources> FunctionBuilder<R> {
617616 Some ( idx)
618617 }
619618
620- fn emit_dropkeep ( & mut self , base : StackBase , c32 : u16 , c64 : u16 , c128 : u16 , cref : u16 ) {
621- if base. s32 == 0
622- && c32 == 0
623- && base. s64 == 0
624- && c64 == 0
625- && base. s128 == 0
626- && c128 == 0
627- && base. sref == 0
628- && cref == 0
629- {
619+ fn emit_dropkeep ( & mut self , base : StackBase , c32 : u16 , c64 : u16 , c128 : u16 ) {
620+ if base. s32 == 0 && c32 == 0 && base. s64 == 0 && c64 == 0 && base. s128 == 0 && c128 == 0 {
630621 return ;
631622 }
632623
@@ -635,26 +626,21 @@ impl<R: WasmModuleResources> FunctionBuilder<R> {
635626 && base. s64 <= u8:: MAX as u16
636627 && c64 <= u8:: MAX as u16
637628 && base. s128 <= u8:: MAX as u16
638- && c128 <= u8:: MAX as u16
639- && base. sref <= u8:: MAX as u16
640- && cref <= u8:: MAX as u16 ;
629+ && c128 <= u8:: MAX as u16 ;
641630
642631 if fits_u8 {
643- self . instructions . push ( Instruction :: DropKeepSmall {
644- base32 : base. s32 as u8 ,
632+ self . instructions . push ( Instruction :: DropKeep {
633+ base32 : base. s32 ,
645634 keep32 : c32 as u8 ,
646- base64 : base. s64 as u8 ,
635+ base64 : base. s64 ,
647636 keep64 : c64 as u8 ,
648- base128 : base. s128 as u8 ,
637+ base128 : base. s128 ,
649638 keep128 : c128 as u8 ,
650- base_ref : base. sref as u8 ,
651- keep_ref : cref as u8 ,
652639 } ) ;
653640 } else {
654641 self . instructions . push ( Instruction :: DropKeep32 ( base. s32 , c32) ) ;
655642 self . instructions . push ( Instruction :: DropKeep64 ( base. s64 , c64) ) ;
656643 self . instructions . push ( Instruction :: DropKeep128 ( base. s128 , c128) ) ;
657- self . instructions . push ( Instruction :: DropKeepRef ( base. sref , cref) ) ;
658644 }
659645 }
660646
@@ -673,18 +659,18 @@ impl<R: WasmModuleResources> FunctionBuilder<R> {
673659 }
674660 }
675661
676- fn label_keep_counts ( label_types : & [ wasmparser:: ValType ] ) -> ( u16 , u16 , u16 , u16 ) {
677- let ( mut c32, mut c64, mut c128, mut cref ) = ( 0 , 0 , 0 , 0 ) ;
662+ fn label_keep_counts ( label_types : & [ wasmparser:: ValType ] ) -> ( u16 , u16 , u16 ) {
663+ let ( mut c32, mut c64, mut c128) = ( 0 , 0 , 0 ) ;
678664 for ty in label_types {
679665 match ty {
680666 wasmparser:: ValType :: I32 | wasmparser:: ValType :: F32 => c32 += 1 ,
681667 wasmparser:: ValType :: I64 | wasmparser:: ValType :: F64 => c64 += 1 ,
682668 wasmparser:: ValType :: V128 => c128 += 1 ,
683- wasmparser:: ValType :: Ref ( _) => cref += 1 ,
669+ wasmparser:: ValType :: Ref ( _) => c32 += 1 ,
684670 }
685671 }
686672
687- ( c32, c64, c128, cref )
673+ ( c32, c64, c128)
688674 }
689675
690676 fn emit_dropkeep_to_label ( & mut self , label_depth : u32 ) {
@@ -698,9 +684,9 @@ impl<R: WasmModuleResources> FunctionBuilder<R> {
698684
699685 let base = self . stack_base_at_frame ( label_depth as usize ) ;
700686 let label_types: Vec < _ > = self . label_types_for_frame ( frame) ;
701- let ( c32, c64, c128, cref ) = Self :: label_keep_counts ( & label_types) ;
687+ let ( c32, c64, c128) = Self :: label_keep_counts ( & label_types) ;
702688
703- self . emit_dropkeep ( base, c32, c64, c128, cref ) ;
689+ self . emit_dropkeep ( base, c32, c64, c128) ;
704690 }
705691
706692 fn label_types_for_frame ( & self , frame : & wasmparser:: Frame ) -> Vec < wasmparser:: ValType > {
@@ -746,8 +732,8 @@ impl<R: WasmModuleResources> FunctionBuilder<R> {
746732
747733 let base = self . stack_base_at_frame ( depth as usize ) ;
748734 let label_types: Vec < _ > = self . label_types_for_frame ( frame) ;
749- let ( c32, c64, c128, cref ) = Self :: label_keep_counts ( & label_types) ;
750- self . emit_dropkeep ( base, c32, c64, c128, cref ) ;
735+ let ( c32, c64, c128) = Self :: label_keep_counts ( & label_types) ;
736+ self . emit_dropkeep ( base, c32, c64, c128) ;
751737
752738 let jump_ip = self . instructions . len ( ) ;
753739 self . instructions . push ( Instruction :: Jump ( 0 ) ) ;
0 commit comments