@@ -17,7 +17,7 @@ use core::ptr::NonNull;
1717use wasmparser:: WasmFeatures ;
1818use wasmtime_environ:: {
1919 EntityIndex , EntityType , FuncIndex , GlobalIndex , MemoryIndex , PrimaryMap , TableIndex , TagIndex ,
20- TypeTrace ,
20+ TypeTrace , collections ,
2121} ;
2222
2323/// An instantiated WebAssembly module.
@@ -787,10 +787,10 @@ pub struct InstancePre<T> {
787787 /// provided, passed to `Instance::new_started` after inserting them into a
788788 /// `Store`.
789789 ///
790- /// Note that this is stored as an `Arc<[T]> ` to quickly move a strong
791- /// reference to everything internally into a `Store<T>` without having to
792- /// clone each individual item.
793- items : Arc < [ Definition ] > ,
790+ /// Note that this is stored as an `Arc` to quickly move a strong reference
791+ /// to everything internally into a `Store<T>` without having to clone each
792+ /// individual item.
793+ items : Arc < collections :: Vec < Definition > > ,
794794
795795 /// A count of `Definition::HostFunc` entries in `items` above to
796796 /// preallocate space in a `Store` up front for all entries to be inserted.
@@ -801,8 +801,8 @@ pub struct InstancePre<T> {
801801 /// `VMFuncRef`s so that we don't have to do it at
802802 /// instantiation time.
803803 ///
804- /// This is an `Arc<[T]> ` for the same reason as `items`.
805- func_refs : Arc < [ VMFuncRef ] > ,
804+ /// This is an `Arc` for the same reason as `items`.
805+ func_refs : Arc < collections :: Vec < VMFuncRef > > ,
806806
807807 /// Whether or not any import in `items` is flagged as needing async.
808808 ///
@@ -836,10 +836,13 @@ impl<T: 'static> InstancePre<T> {
836836 /// This method is unsafe as the `T` of the `InstancePre<T>` is not
837837 /// guaranteed to be the same as the `T` within the `Store`, the caller must
838838 /// verify that.
839- pub ( crate ) unsafe fn new ( module : & Module , items : Vec < Definition > ) -> Result < InstancePre < T > > {
839+ pub ( crate ) unsafe fn new (
840+ module : & Module ,
841+ items : collections:: Vec < Definition > ,
842+ ) -> Result < InstancePre < T > > {
840843 typecheck ( module, & items, |cx, ty, item| cx. definition ( ty, & item. ty ( ) ) ) ?;
841844
842- let mut func_refs = vec ! [ ] ;
845+ let mut func_refs = collections :: Vec :: with_capacity ( items . len ( ) ) ? ;
843846 let mut host_funcs = 0 ;
844847 let mut asyncness = Asyncness :: No ;
845848 for item in & items {
@@ -853,7 +856,7 @@ impl<T: 'static> InstancePre<T> {
853856 . wasm_to_array_trampoline ( f. sig_index ( ) )
854857 . map ( |f| f. into ( ) ) ,
855858 ..* f. func_ref ( )
856- } ) ;
859+ } ) ? ;
857860 }
858861 asyncness = asyncness | f. asyncness ( ) ;
859862 }
@@ -862,9 +865,9 @@ impl<T: 'static> InstancePre<T> {
862865
863866 Ok ( InstancePre {
864867 module : module. clone ( ) ,
865- items : items . into ( ) ,
868+ items : try_new :: < Arc < _ > > ( items ) ? ,
866869 host_funcs,
867- func_refs : func_refs . into ( ) ,
870+ func_refs : try_new :: < Arc < _ > > ( func_refs ) ? ,
868871 asyncness,
869872 _marker : core:: marker:: PhantomData ,
870873 } )
@@ -959,9 +962,9 @@ impl<T: 'static> InstancePre<T> {
959962fn pre_instantiate_raw (
960963 store : & mut StoreOpaque ,
961964 module : & Module ,
962- items : & Arc < [ Definition ] > ,
965+ items : & Arc < collections :: Vec < Definition > > ,
963966 host_funcs : usize ,
964- func_refs : & Arc < [ VMFuncRef ] > ,
967+ func_refs : & Arc < collections :: Vec < VMFuncRef > > ,
965968 asyncness : Asyncness ,
966969) -> Result < OwnedImports > {
967970 // Register this module and use it to fill out any funcref wasm_call holes
0 commit comments