@@ -9,8 +9,7 @@ use wirm::ir::module::module_globals::GlobalKind;
99use wirm:: ir:: types:: { BlockType , ElementItems , InitInstr , InstrumentationMode , Value } ;
1010use wirm:: module_builder:: AddLocal ;
1111use wirm:: opcode:: { Inject , InjectAt } ;
12- use wirm:: wasmparser:: MemArg ;
13- use wirm:: wasmparser:: Operator ;
12+ use wirm:: wasmparser:: { ExternalKind , MemArg , Operator } ;
1413use wirm:: { DataType , Opcode } ;
1514use wit_component:: StringEncoding ;
1615use wit_component:: metadata:: { Bindgen , decode} ;
@@ -356,6 +355,15 @@ pub fn splice(
356355 ) ;
357356 }
358357
358+ // we reencode the WASI world component data, so strip it out from the
359+ // custom section
360+ let maybe_component_section_id = module
361+ . custom_sections
362+ . get_id ( "component-type:bindings" . to_string ( ) ) ;
363+ if let Some ( component_section_id) = maybe_component_section_id {
364+ module. delete_custom_section ( component_section_id) ;
365+ }
366+
359367 // Extract the native instructions from sample functions
360368 // then inline the imported functions and main import gating function
361369 // (erasing sample functions in the process)
@@ -403,7 +411,7 @@ fn get_export_fid(module: &Module, expt_id: &ExportsID) -> FunctionID {
403411 let expt = module. exports . get_by_id ( * expt_id) . unwrap ( ) ;
404412
405413 match expt. kind {
406- wirm :: wasmparser :: ExternalKind :: Func => FunctionID :: from ( expt. index ) ,
414+ ExternalKind :: Func => FunctionID :: from ( expt. index ) ,
407415 _ => panic ! ( "Missing coreabi_get_import" ) ,
408416 }
409417}
@@ -472,7 +480,7 @@ fn synthesize_import_functions(
472480 . unwrap ( ) ;
473481
474482 // Sets the return value on args from the stack
475- let args_ret_i32: Vec < wirm :: wasmparser :: Operator > = vec ! [
483+ let args_ret_i32: Vec < Operator > = vec ! [
476484 Operator :: I64ExtendI32U ,
477485 Operator :: I64Const {
478486 value: -545460846592 ,
@@ -585,7 +593,7 @@ fn synthesize_import_functions(
585593 func. i32_add ( ) ;
586594 match arg {
587595 CoreTy :: I32 => {
588- func. i64_load ( wirm :: wasmparser :: MemArg {
596+ func. i64_load ( MemArg {
589597 align : 3 ,
590598 max_align : 0 ,
591599 offset : 0 ,
@@ -598,7 +606,7 @@ fn synthesize_import_functions(
598606 }
599607 CoreTy :: F32 => {
600608 // isInt: (r.asRawBits() >> 32) == 0xFFFFFF81
601- func. i64_load ( wirm :: wasmparser :: MemArg {
609+ func. i64_load ( MemArg {
602610 align : 3 ,
603611 max_align : 0 ,
604612 offset : 0 ,
@@ -621,7 +629,7 @@ fn synthesize_import_functions(
621629 }
622630 CoreTy :: F64 => {
623631 // isInt: (r.asRawBits() >> 32) == 0xFFFFFF81
624- func. i64_load ( wirm :: wasmparser :: MemArg {
632+ func. i64_load ( MemArg {
625633 align : 3 ,
626634 max_align : 0 ,
627635 offset : 0 ,
@@ -687,7 +695,7 @@ fn synthesize_import_functions(
687695 func. i64_extend_i32_u ( ) ;
688696 func. i64_const ( -511101108224 ) ;
689697 func. i64_or ( ) ;
690- func. i64_store ( wirm :: wasmparser :: MemArg {
698+ func. i64_store ( MemArg {
691699 align : 3 ,
692700 max_align : 0 ,
693701 offset : 0 ,
@@ -696,15 +704,15 @@ fn synthesize_import_functions(
696704 }
697705 Some ( CoreTy :: F32 ) => {
698706 func. f64_promote_f32 ( ) ;
699- func. f64_store ( wirm :: wasmparser :: MemArg {
707+ func. f64_store ( MemArg {
700708 align : 3 ,
701709 max_align : 0 ,
702710 offset : 0 ,
703711 memory,
704712 } ) ;
705713 }
706714 Some ( CoreTy :: F64 ) => {
707- func. f64_store ( wirm :: wasmparser :: MemArg {
715+ func. f64_store ( MemArg {
708716 align : 3 ,
709717 max_align : 0 ,
710718 offset : 0 ,
@@ -776,7 +784,7 @@ fn synthesize_import_functions(
776784 builder. inject_at (
777785 0 ,
778786 InstrumentationMode :: Before ,
779- wirm :: wasmparser :: Operator :: LocalSet {
787+ Operator :: LocalSet {
780788 local_index : * idx_local,
781789 } ,
782790 ) ;
@@ -789,7 +797,7 @@ fn synthesize_import_functions(
789797 {
790798 let ops_ro = builder. body . instructions . get_ops ( ) ;
791799 for ( idx, op) in ops_ro. iter ( ) . enumerate ( ) {
792- if let wirm :: wasmparser :: Operator :: I32Const { value } = op {
800+ if let Operator :: I32Const { value } = op {
793801 // we specifically need the const "around" 3393
794802 // which is the coreabi_sample_i32 table offset
795803 if * value < 1000 || * value > 5000 {
@@ -800,8 +808,7 @@ fn synthesize_import_functions(
800808 // in the base computation.
801809 let mut base = * value;
802810 if idx > 0
803- && let wirm:: wasmparser:: Operator :: GlobalGet { global_index } =
804- & ops_ro[ idx - 1 ]
811+ && let Operator :: GlobalGet { global_index } = & ops_ro[ idx - 1 ]
805812 && let GlobalKind :: Local ( local_global) =
806813 module. globals . get_kind ( GlobalID ( * global_index) )
807814 && let [ InitInstr :: Value ( Value :: I32 ( v) ) ] =
@@ -819,25 +826,25 @@ fn synthesize_import_functions(
819826 builder. inject_at (
820827 table_instr_idx,
821828 InstrumentationMode :: Before ,
822- wirm :: wasmparser :: Operator :: LocalGet {
829+ Operator :: LocalGet {
823830 local_index : * idx_local,
824831 } ,
825832 ) ;
826833 builder. inject_at (
827834 table_instr_idx + 1 ,
828835 InstrumentationMode :: Before ,
829- wirm :: wasmparser :: Operator :: I32Add ,
836+ Operator :: I32Add ,
830837 ) ;
831838
832839 if delta != 0 {
833- builder. body . instructions . add_instr (
834- table_instr_idx,
835- wirm:: wasmparser:: Operator :: I32Const { value : delta } ,
836- ) ;
837840 builder
838841 . body
839842 . instructions
840- . add_instr ( table_instr_idx, wirm:: wasmparser:: Operator :: I32Add ) ;
843+ . add_instr ( table_instr_idx, Operator :: I32Const { value : delta } ) ;
844+ builder
845+ . body
846+ . instructions
847+ . add_instr ( table_instr_idx, Operator :: I32Add ) ;
841848 }
842849 }
843850
@@ -948,7 +955,7 @@ fn synthesize_export_functions(module: &mut Module, exports: &[(String, CoreFn)]
948955 func. local_get ( args[ idx] ) ;
949956 match param {
950957 CoreTy :: I32 => {
951- func. i32_store ( wirm :: wasmparser :: MemArg {
958+ func. i32_store ( MemArg {
952959 align : 2 ,
953960 max_align : 0 ,
954961 offset,
@@ -957,7 +964,7 @@ fn synthesize_export_functions(module: &mut Module, exports: &[(String, CoreFn)]
957964 offset += 4 ;
958965 }
959966 CoreTy :: I64 => {
960- func. i64_store ( wirm :: wasmparser :: MemArg {
967+ func. i64_store ( MemArg {
961968 align : 3 ,
962969 offset,
963970 memory,
@@ -966,7 +973,7 @@ fn synthesize_export_functions(module: &mut Module, exports: &[(String, CoreFn)]
966973 offset += 8 ;
967974 }
968975 CoreTy :: F32 => {
969- func. f32_store ( wirm :: wasmparser :: MemArg {
976+ func. f32_store ( MemArg {
970977 align : 2 ,
971978 max_align : 0 ,
972979 offset,
@@ -975,7 +982,7 @@ fn synthesize_export_functions(module: &mut Module, exports: &[(String, CoreFn)]
975982 offset += 4 ;
976983 }
977984 CoreTy :: F64 => {
978- func. f64_store ( wirm :: wasmparser :: MemArg {
985+ func. f64_store ( MemArg {
979986 align : 3 ,
980987 offset,
981988 memory,
@@ -1003,31 +1010,31 @@ fn synthesize_export_functions(module: &mut Module, exports: &[(String, CoreFn)]
10031010 // value type from the retptr
10041011 match expt_sig. ret . unwrap ( ) {
10051012 CoreTy :: I32 => {
1006- func. i32_load ( wirm :: wasmparser :: MemArg {
1013+ func. i32_load ( MemArg {
10071014 align : 2 ,
10081015 max_align : 0 ,
10091016 offset : 0 ,
10101017 memory,
10111018 } ) ;
10121019 }
10131020 CoreTy :: I64 => {
1014- func. i64_load ( wirm :: wasmparser :: MemArg {
1021+ func. i64_load ( MemArg {
10151022 align : 3 ,
10161023 max_align : 0 ,
10171024 offset : 0 ,
10181025 memory,
10191026 } ) ;
10201027 }
10211028 CoreTy :: F32 => {
1022- func. f32_load ( wirm :: wasmparser :: MemArg {
1029+ func. f32_load ( MemArg {
10231030 align : 2 ,
10241031 max_align : 0 ,
10251032 offset : 0 ,
10261033 memory,
10271034 } ) ;
10281035 }
10291036 CoreTy :: F64 => {
1030- func. f64_load ( wirm :: wasmparser :: MemArg {
1037+ func. f64_load ( MemArg {
10311038 align : 3 ,
10321039 offset : 0 ,
10331040 memory,
0 commit comments