@@ -10,8 +10,8 @@ use cranelift_codegen::isa::{CallConv, TargetIsa};
1010use cranelift_frontend:: FunctionBuilder ;
1111use wasmtime_environ:: error:: { Result , bail} ;
1212use wasmtime_environ:: {
13- Abi , BuiltinFunctionIndex , CompiledFunctionBody , EntityRef , FuncKey , HostCall , PtrSize ,
14- TrapSentinel , Tunables , WasmFuncType , WasmValType , component:: * ,
13+ Abi , BuiltinFunctionIndex , CompiledFunctionBody , EntityRef , FuncKey , HostCall , PanicOnOom as _ ,
14+ PtrSize , TrapSentinel , Tunables , WasmFuncType , WasmValType , component:: * ,
1515 fact:: PREPARE_CALL_FIXED_PARAMS ,
1616} ;
1717
@@ -177,7 +177,7 @@ impl<'a> TrampolineCompiler<'a> {
177177 }
178178 Trampoline :: ResourceRep { instance, ty } => {
179179 // Currently this only supports resources represented by `i32`
180- assert_eq ! ( self . signature. returns ( ) [ 0 ] , WasmValType :: I32 ) ;
180+ assert_eq ! ( self . signature. results ( ) [ 0 ] , WasmValType :: I32 ) ;
181181 self . translate_libcall (
182182 host:: resource_rep32,
183183 TrapSentinel :: NegativeOne ,
@@ -639,10 +639,7 @@ impl<'a> TrampolineCompiler<'a> {
639639 Trampoline :: SyncStartCall { callback } => {
640640 let pointer_type = self . isa . pointer_type ( ) ;
641641 let ( values_vec_ptr, len) = self . compiler . allocate_stack_array_and_spill_args (
642- & WasmFuncType :: new (
643- Box :: new ( [ ] ) ,
644- self . signature . returns ( ) . iter ( ) . copied ( ) . collect ( ) ,
645- ) ,
642+ & WasmFuncType :: new ( [ ] , self . signature . results ( ) . iter ( ) . copied ( ) ) . panic_on_oom ( ) ,
646643 & mut self . builder ,
647644 & [ ] ,
648645 ) ;
@@ -972,10 +969,8 @@ impl<'a> TrampolineCompiler<'a> {
972969 // A mixture of the above two.
973970 WasmArgs :: InRegistersUpTo ( n) => {
974971 let ( values_vec_ptr, len) = self . compiler . allocate_stack_array_and_spill_args (
975- & WasmFuncType :: new (
976- self . signature . params ( ) . iter ( ) . skip ( n) . copied ( ) . collect ( ) ,
977- Box :: new ( [ ] ) ,
978- ) ,
972+ & WasmFuncType :: new ( self . signature . params ( ) . iter ( ) . skip ( n) . copied ( ) , [ ] )
973+ . panic_on_oom ( ) ,
979974 & mut self . builder ,
980975 & wasm_params[ n..] ,
981976 ) ;
@@ -1026,7 +1021,7 @@ impl<'a> TrampolineCompiler<'a> {
10261021 // accounts for the ABI of this function when storing results.
10271022 let result = self . builder . func . dfg . inst_results ( call) . get ( 0 ) . copied ( ) ;
10281023 let result_ty = result. map ( |v| self . builder . func . dfg . value_type ( v) ) ;
1029- let expected = self . signature . returns ( ) ;
1024+ let expected = self . signature . results ( ) ;
10301025 match host_result. into ( ) {
10311026 HostResult :: Sentinel ( TrapSentinel :: NegativeOne ) => {
10321027 assert_eq ! ( expected. len( ) , 1 ) ;
@@ -1054,7 +1049,7 @@ impl<'a> TrampolineCompiler<'a> {
10541049 let len = len. or ( val_raw_len) . unwrap ( ) ;
10551050 self . raise_if_host_trapped ( result. unwrap ( ) ) ;
10561051 let results = self . compiler . load_values_from_array (
1057- self . signature . returns ( ) ,
1052+ self . signature . results ( ) ,
10581053 & mut self . builder ,
10591054 ptr,
10601055 len,
@@ -1671,9 +1666,10 @@ impl ComponentCompiler for Compiler {
16711666 symbol : & str ,
16721667 ) -> Result < CompiledFunctionBody > {
16731668 let wasm_func_ty = WasmFuncType :: new (
1674- intrinsic. core_params ( ) . into ( ) ,
1675- intrinsic. core_results ( ) . into ( ) ,
1676- ) ;
1669+ intrinsic. core_params ( ) . iter ( ) . copied ( ) ,
1670+ intrinsic. core_results ( ) . iter ( ) . copied ( ) ,
1671+ )
1672+ . panic_on_oom ( ) ;
16771673
16781674 match abi {
16791675 // Fall through to the trampoline compiler.
0 commit comments