diff --git a/lib/api/src/sys/externals/function.rs b/lib/api/src/sys/externals/function.rs index 773faacd4ef..10272b884c8 100644 --- a/lib/api/src/sys/externals/function.rs +++ b/lib/api/src/sys/externals/function.rs @@ -16,8 +16,8 @@ use std::sync::Arc; use wasmer_engine::{Export, ExportFunction, ExportFunctionMetadata}; use wasmer_vm::{ raise_user_trap, resume_panic, wasmer_call_trampoline, ImportInitializerFuncPtr, - VMCallerCheckedAnyfunc, VMDynamicFunctionContext, VMFuncRef, VMFunction, VMFunctionBody, - VMFunctionEnvironment, VMFunctionKind, VMTrampoline, + VMDynamicFunctionContext, VMFuncRef, VMFunction, VMFunctionBody, VMFunctionEnvironment, + VMFunctionKind, VMTrampoline, }; /// A WebAssembly `function` instance. @@ -551,15 +551,12 @@ impl Function { } } - pub(crate) fn vm_funcref(&self) -> VMFuncRef { + /*pub(crate) fn vm_funcref(&self) -> VMFuncRef { let engine = self.store.engine(); let vmsignature = engine.register_signature(&self.exported.vm_function.signature); - engine.register_function_metadata(VMCallerCheckedAnyfunc { - func_ptr: self.exported.vm_function.address, - type_index: vmsignature, - vmctx: self.exported.vm_function.vmctx, - }) - } + // with the new changes this method is no longer possible... it should be though + // so TODO: figure out how to make this work + }*/ /// Transform this WebAssembly function into a function with the /// native ABI. See [`NativeFunc`] to learn more. diff --git a/lib/api/src/sys/types.rs b/lib/api/src/sys/types.rs index ef291e9889b..07e4f503f89 100644 --- a/lib/api/src/sys/types.rs +++ b/lib/api/src/sys/types.rs @@ -53,7 +53,7 @@ impl ValFuncRef for Val { } Ok(match self { Self::FuncRef(None) => VMFuncRef::null(), - Self::FuncRef(Some(f)) => f.vm_funcref(), + Self::FuncRef(Some(_)) => VMFuncRef::null(), //f.vm_funcref(), _ => return Err(RuntimeError::new("val is not func ref")), }) } @@ -100,7 +100,7 @@ impl ValFuncRef for Val { wasmer_vm::TableElement::ExternRef(extern_ref.clone().into()) } Self::FuncRef(None) => wasmer_vm::TableElement::FuncRef(VMFuncRef::null()), - Self::FuncRef(Some(f)) => wasmer_vm::TableElement::FuncRef(f.vm_funcref()), + Self::FuncRef(Some(f)) => wasmer_vm::TableElement::FuncRef(VMFuncRef::null()), //wasmer_vm::TableElement::FuncRef(f.vm_funcref()), _ => return Err(RuntimeError::new("val is not reference")), }) } diff --git a/lib/engine-dylib/src/artifact.rs b/lib/engine-dylib/src/artifact.rs index 1469a373363..bd61877c077 100644 --- a/lib/engine-dylib/src/artifact.rs +++ b/lib/engine-dylib/src/artifact.rs @@ -41,8 +41,7 @@ use wasmer_types::{ SignatureIndex, TableIndex, }; use wasmer_vm::{ - FuncDataRegistry, FunctionBodyPtr, MemoryStyle, TableStyle, VMFunctionBody, - VMSharedSignatureIndex, VMTrampoline, + FunctionBodyPtr, MemoryStyle, TableStyle, VMFunctionBody, VMSharedSignatureIndex, VMTrampoline, }; /// A compiled Wasm module, ready to be instantiated. @@ -55,7 +54,6 @@ pub struct DylibArtifact { #[loupe(skip)] finished_function_call_trampolines: BoxedSlice, finished_dynamic_function_trampolines: BoxedSlice, - func_data_registry: Arc, signatures: BoxedSlice, frame_info_registration: Mutex>, } @@ -440,7 +438,6 @@ impl DylibArtifact { .into_boxed_slice(), finished_dynamic_function_trampolines: finished_dynamic_function_trampolines .into_boxed_slice(), - func_data_registry: Arc::new(FuncDataRegistry::new()), signatures: signatures.into_boxed_slice(), frame_info_registration: Mutex::new(None), }) @@ -546,7 +543,6 @@ impl DylibArtifact { .into_boxed_slice(), finished_dynamic_function_trampolines: finished_dynamic_function_trampolines .into_boxed_slice(), - func_data_registry: engine_inner.func_data().clone(), signatures: signatures.into_boxed_slice(), frame_info_registration: Mutex::new(None), }) @@ -828,10 +824,6 @@ impl Artifact for DylibArtifact { &self.signatures } - fn func_data_registry(&self) -> &FuncDataRegistry { - &self.func_data_registry - } - fn preinstantiate(&self) -> Result<(), InstantiationError> { Ok(()) } diff --git a/lib/engine-dylib/src/engine.rs b/lib/engine-dylib/src/engine.rs index 7825ae18987..a3238f38d40 100644 --- a/lib/engine-dylib/src/engine.rs +++ b/lib/engine-dylib/src/engine.rs @@ -13,9 +13,7 @@ use wasmer_engine::{Artifact, DeserializeError, Engine, EngineId, Tunables}; #[cfg(feature = "compiler")] use wasmer_types::Features; use wasmer_types::FunctionType; -use wasmer_vm::{ - FuncDataRegistry, SignatureRegistry, VMCallerCheckedAnyfunc, VMFuncRef, VMSharedSignatureIndex, -}; +use wasmer_vm::{SignatureRegistry, VMSharedSignatureIndex}; /// A WebAssembly `Dylib` Engine. #[derive(Clone, MemoryUsage)] @@ -37,7 +35,6 @@ impl DylibEngine { inner: Arc::new(Mutex::new(DylibEngineInner { compiler: Some(compiler), signatures: SignatureRegistry::new(), - func_data: Arc::new(FuncDataRegistry::new()), prefixer: None, features, is_cross_compiling, @@ -70,7 +67,6 @@ impl DylibEngine { #[cfg(feature = "compiler")] features: Features::default(), signatures: SignatureRegistry::new(), - func_data: Arc::new(FuncDataRegistry::new()), prefixer: None, is_cross_compiling: false, linker: Linker::None, @@ -120,11 +116,6 @@ impl Engine for DylibEngine { compiler.signatures().register(func_type) } - fn register_function_metadata(&self, func_data: VMCallerCheckedAnyfunc) -> VMFuncRef { - let compiler = self.inner(); - compiler.func_data().register(func_data) - } - /// Lookup a signature fn lookup_signature(&self, sig: VMSharedSignatureIndex) -> Option { let compiler = self.inner(); @@ -243,11 +234,6 @@ pub struct DylibEngineInner { /// performantly. signatures: SignatureRegistry, - /// The backing storage of `VMFuncRef`s. This centralized store ensures that 2 - /// functions with the same `VMCallerCheckedAnyfunc` will have the same `VMFuncRef`. - /// It also guarantees that the `VMFuncRef`s stay valid until the engine is dropped. - func_data: Arc, - /// The prefixer returns the a String to prefix each of /// the functions in the shared object generated by the `DylibEngine`, /// so we can assure no collisions. @@ -311,11 +297,6 @@ impl DylibEngineInner { &self.signatures } - /// Shared func metadata registry. - pub(crate) fn func_data(&self) -> &Arc { - &self.func_data - } - pub(crate) fn is_cross_compiling(&self) -> bool { self.is_cross_compiling } diff --git a/lib/engine-staticlib/src/artifact.rs b/lib/engine-staticlib/src/artifact.rs index 3615dac7952..045276e40c7 100644 --- a/lib/engine-staticlib/src/artifact.rs +++ b/lib/engine-staticlib/src/artifact.rs @@ -27,10 +27,7 @@ use wasmer_types::{ FunctionIndex, LocalFunctionIndex, MemoryIndex, ModuleInfo, OwnedDataInitializer, SignatureIndex, TableIndex, }; -use wasmer_vm::{ - FuncDataRegistry, FunctionBodyPtr, MemoryStyle, TableStyle, VMSharedSignatureIndex, - VMTrampoline, -}; +use wasmer_vm::{FunctionBodyPtr, MemoryStyle, TableStyle, VMSharedSignatureIndex, VMTrampoline}; /// A compiled wasm module, ready to be instantiated. #[derive(MemoryUsage)] @@ -42,7 +39,6 @@ pub struct StaticlibArtifact { finished_function_call_trampolines: BoxedSlice, finished_dynamic_function_trampolines: BoxedSlice, signatures: BoxedSlice, - func_data_registry: Arc, /// Length of the serialized metadata metadata_length: usize, symbol_registry: ModuleMetadataSymbolRegistry, @@ -292,7 +288,6 @@ impl StaticlibArtifact { finished_dynamic_function_trampolines: finished_dynamic_function_trampolines .into_boxed_slice(), signatures: signatures.into_boxed_slice(), - func_data_registry: engine_inner.func_data().clone(), metadata_length, symbol_registry, }) @@ -332,7 +327,6 @@ impl StaticlibArtifact { let engine_inner = engine.inner(); let signature_registry = engine_inner.signatures(); - let func_data_registry = engine_inner.func_data().clone(); let mut sig_map: BTreeMap = BTreeMap::new(); let num_imported_functions = metadata.compile_info.module.num_imported_functions; @@ -412,7 +406,6 @@ impl StaticlibArtifact { finished_dynamic_function_trampolines: finished_dynamic_function_trampolines .into_boxed_slice(), signatures: signatures.into_boxed_slice(), - func_data_registry, metadata_length: 0, symbol_registry, }) @@ -478,10 +471,6 @@ impl Artifact for StaticlibArtifact { &self.signatures } - fn func_data_registry(&self) -> &FuncDataRegistry { - &self.func_data_registry - } - fn preinstantiate(&self) -> Result<(), InstantiationError> { Ok(()) } diff --git a/lib/engine-staticlib/src/engine.rs b/lib/engine-staticlib/src/engine.rs index a0ee4c4d65a..4abd532ac65 100644 --- a/lib/engine-staticlib/src/engine.rs +++ b/lib/engine-staticlib/src/engine.rs @@ -10,9 +10,7 @@ use wasmer_engine::{Artifact, DeserializeError, Engine, EngineId, Tunables}; #[cfg(feature = "compiler")] use wasmer_types::Features; use wasmer_types::FunctionType; -use wasmer_vm::{ - FuncDataRegistry, SignatureRegistry, VMCallerCheckedAnyfunc, VMFuncRef, VMSharedSignatureIndex, -}; +use wasmer_vm::{SignatureRegistry, VMSharedSignatureIndex}; /// A WebAssembly `Staticlib` Engine. #[derive(Clone, MemoryUsage)] @@ -31,7 +29,6 @@ impl StaticlibEngine { inner: Arc::new(Mutex::new(StaticlibEngineInner { compiler: Some(compiler), signatures: SignatureRegistry::new(), - func_data: Arc::new(FuncDataRegistry::new()), prefixer: None, features, })), @@ -61,7 +58,6 @@ impl StaticlibEngine { #[cfg(feature = "compiler")] features: Features::default(), signatures: SignatureRegistry::new(), - func_data: Arc::new(FuncDataRegistry::new()), prefixer: None, })), target: Arc::new(Target::default()), @@ -109,11 +105,6 @@ impl Engine for StaticlibEngine { compiler.signatures().register(func_type) } - fn register_function_metadata(&self, func_data: VMCallerCheckedAnyfunc) -> VMFuncRef { - let compiler = self.inner(); - compiler.func_data().register(func_data) - } - /// Lookup a signature fn lookup_signature(&self, sig: VMSharedSignatureIndex) -> Option { let compiler = self.inner(); @@ -192,11 +183,6 @@ pub struct StaticlibEngineInner { /// performantly. signatures: SignatureRegistry, - /// The backing storage of `VMFuncRef`s. This centralized store ensures that 2 - /// functions with the same `VMCallerCheckedAnyfunc` will have the same `VMFuncRef`. - /// It also guarantees that the `VMFuncRef`s stay valid until the engine is dropped. - func_data: Arc, - /// The prefixer returns the a String to prefix each of the /// functions in the static object generated by the /// `StaticlibEngine`, so we can assure no collisions. @@ -249,9 +235,4 @@ impl StaticlibEngineInner { pub fn signatures(&self) -> &SignatureRegistry { &self.signatures } - - /// Shared func metadata registry. - pub(crate) fn func_data(&self) -> &Arc { - &self.func_data - } } diff --git a/lib/engine-universal/src/artifact.rs b/lib/engine-universal/src/artifact.rs index 6e0d4bac908..5ce5ab758bc 100644 --- a/lib/engine-universal/src/artifact.rs +++ b/lib/engine-universal/src/artifact.rs @@ -22,10 +22,7 @@ use wasmer_types::{ FunctionIndex, LocalFunctionIndex, MemoryIndex, ModuleInfo, OwnedDataInitializer, SignatureIndex, TableIndex, }; -use wasmer_vm::{ - FuncDataRegistry, FunctionBodyPtr, MemoryStyle, TableStyle, VMSharedSignatureIndex, - VMTrampoline, -}; +use wasmer_vm::{FunctionBodyPtr, MemoryStyle, TableStyle, VMSharedSignatureIndex, VMTrampoline}; const SERIALIZED_METADATA_LENGTH_OFFSET: usize = 22; const SERIALIZED_METADATA_CONTENT_OFFSET: usize = 32; @@ -39,7 +36,6 @@ pub struct UniversalArtifact { finished_function_call_trampolines: BoxedSlice, finished_dynamic_function_trampolines: BoxedSlice, signatures: BoxedSlice, - func_data_registry: Arc, frame_info_registration: Mutex>, finished_function_lengths: BoxedSlice, } @@ -244,7 +240,6 @@ impl UniversalArtifact { let finished_dynamic_function_trampolines = finished_dynamic_function_trampolines.into_boxed_slice(); let signatures = signatures.into_boxed_slice(); - let func_data_registry = inner_engine.func_data().clone(); Ok(Self { serializable, @@ -254,7 +249,6 @@ impl UniversalArtifact { signatures, frame_info_registration: Mutex::new(None), finished_function_lengths, - func_data_registry, }) } @@ -335,9 +329,6 @@ impl Artifact for UniversalArtifact { &self.signatures } - fn func_data_registry(&self) -> &FuncDataRegistry { - &self.func_data_registry - } fn serialize(&self) -> Result, SerializeError> { // Prepend the header. let mut serialized = Self::MAGIC_HEADER.to_vec(); diff --git a/lib/engine-universal/src/engine.rs b/lib/engine-universal/src/engine.rs index ecc34931212..450228f7978 100644 --- a/lib/engine-universal/src/engine.rs +++ b/lib/engine-universal/src/engine.rs @@ -14,8 +14,8 @@ use wasmer_types::{ Features, FunctionIndex, FunctionType, LocalFunctionIndex, ModuleInfo, SignatureIndex, }; use wasmer_vm::{ - FuncDataRegistry, FunctionBodyPtr, SectionBodyPtr, SignatureRegistry, VMCallerCheckedAnyfunc, - VMFuncRef, VMFunctionBody, VMSharedSignatureIndex, VMTrampoline, + FunctionBodyPtr, SectionBodyPtr, SignatureRegistry, VMFunctionBody, VMSharedSignatureIndex, + VMTrampoline, }; /// A WebAssembly `Universal` Engine. @@ -36,7 +36,6 @@ impl UniversalEngine { compiler: Some(compiler), code_memory: vec![], signatures: SignatureRegistry::new(), - func_data: Arc::new(FuncDataRegistry::new()), features, })), target: Arc::new(target), @@ -64,7 +63,6 @@ impl UniversalEngine { compiler: None, code_memory: vec![], signatures: SignatureRegistry::new(), - func_data: Arc::new(FuncDataRegistry::new()), features: Features::default(), })), target: Arc::new(Target::default()), @@ -93,11 +91,6 @@ impl Engine for UniversalEngine { compiler.signatures().register(func_type) } - fn register_function_metadata(&self, func_data: VMCallerCheckedAnyfunc) -> VMFuncRef { - let compiler = self.inner(); - compiler.func_data().register(func_data) - } - /// Lookup a signature fn lookup_signature(&self, sig: VMSharedSignatureIndex) -> Option { let compiler = self.inner(); @@ -160,10 +153,6 @@ pub struct UniversalEngineInner { /// The signature registry is used mainly to operate with trampolines /// performantly. signatures: SignatureRegistry, - /// The backing storage of `VMFuncRef`s. This centralized store ensures that 2 - /// functions with the same `VMCallerCheckedAnyfunc` will have the same `VMFuncRef`. - /// It also guarantees that the `VMFuncRef`s stay valid until the engine is dropped. - func_data: Arc, } impl UniversalEngineInner { @@ -311,9 +300,4 @@ impl UniversalEngineInner { pub fn signatures(&self) -> &SignatureRegistry { &self.signatures } - - /// Shared func metadata registry. - pub(crate) fn func_data(&self) -> &Arc { - &self.func_data - } } diff --git a/lib/engine/src/artifact.rs b/lib/engine/src/artifact.rs index e8185d14a7f..91be23e0840 100644 --- a/lib/engine/src/artifact.rs +++ b/lib/engine/src/artifact.rs @@ -13,8 +13,8 @@ use wasmer_types::{ OwnedDataInitializer, SignatureIndex, TableIndex, }; use wasmer_vm::{ - FuncDataRegistry, FunctionBodyPtr, InstanceAllocator, InstanceHandle, MemoryStyle, TableStyle, - TrapHandler, VMSharedSignatureIndex, VMTrampoline, + FunctionBodyPtr, InstanceAllocator, InstanceHandle, MemoryStyle, TableStyle, TrapHandler, + VMSharedSignatureIndex, VMTrampoline, }; /// An `Artifact` is the product that the `Engine` @@ -67,9 +67,6 @@ pub trait Artifact: Send + Sync + Upcastable + MemoryUsage { /// Returns the associated VM signatures for this `Artifact`. fn signatures(&self) -> &BoxedSlice; - /// Get the func data registry - fn func_data_registry(&self) -> &FuncDataRegistry; - /// Serializes an artifact into bytes fn serialize(&self) -> Result, SerializeError>; @@ -146,7 +143,6 @@ pub trait Artifact: Send + Sync + Upcastable + MemoryUsage { finished_globals, imports, self.signatures().clone(), - self.func_data_registry(), host_state, import_function_envs, ) diff --git a/lib/engine/src/engine.rs b/lib/engine/src/engine.rs index fb79e235f57..1210395b2b4 100644 --- a/lib/engine/src/engine.rs +++ b/lib/engine/src/engine.rs @@ -9,7 +9,7 @@ use std::sync::atomic::{AtomicUsize, Ordering::SeqCst}; use std::sync::Arc; use wasmer_compiler::{CompileError, Target}; use wasmer_types::FunctionType; -use wasmer_vm::{VMCallerCheckedAnyfunc, VMFuncRef, VMSharedSignatureIndex}; +use wasmer_vm::VMSharedSignatureIndex; /// A unimplemented Wasmer `Engine`. /// @@ -24,9 +24,6 @@ pub trait Engine: MemoryUsage { /// Register a signature fn register_signature(&self, func_type: &FunctionType) -> VMSharedSignatureIndex; - /// Register a function's data. - fn register_function_metadata(&self, func_data: VMCallerCheckedAnyfunc) -> VMFuncRef; - /// Lookup a signature fn lookup_signature(&self, sig: VMSharedSignatureIndex) -> Option; diff --git a/lib/vm/src/func_data_registry.rs b/lib/vm/src/func_data_registry.rs index 7fc9fc24d09..fa7d4fc269b 100644 --- a/lib/vm/src/func_data_registry.rs +++ b/lib/vm/src/func_data_registry.rs @@ -6,23 +6,6 @@ use crate::vmcontext::VMCallerCheckedAnyfunc; use loupe::MemoryUsage; -use std::collections::HashMap; -use std::sync::Mutex; - -/// The registry that holds the values that `VMFuncRef`s point to. -#[derive(Debug, MemoryUsage)] -pub struct FuncDataRegistry { - // This structure is stored in an `Engine` and is intended to be shared - // across many instances. Ideally instances can themselves be sent across - // threads, and ideally we can compile across many threads. As a result we - // use interior mutability here with a lock to avoid having callers to - // externally synchronize calls to compilation. - inner: Mutex, -} - -// We use raw pointers but the data never moves, so it's not a problem -unsafe impl Send for FuncDataRegistry {} -unsafe impl Sync for FuncDataRegistry {} /// A function reference. A single word that points to metadata about a function. #[repr(transparent)] @@ -86,36 +69,3 @@ impl std::ops::DerefMut for VMFuncRef { // TODO: update docs unsafe impl Send for VMFuncRef {} unsafe impl Sync for VMFuncRef {} - -#[derive(Debug, Default, MemoryUsage)] -struct Inner { - func_data: Vec>, - anyfunc_to_index: HashMap, -} - -impl FuncDataRegistry { - /// Create a new `FuncDataRegistry`. - pub fn new() -> Self { - Self { - inner: Default::default(), - } - } - - /// Register a signature and return its unique index. - pub fn register(&self, anyfunc: VMCallerCheckedAnyfunc) -> VMFuncRef { - let mut inner = self.inner.lock().unwrap(); - if let Some(&idx) = inner.anyfunc_to_index.get(&anyfunc) { - let data: &Box<_> = &inner.func_data[idx]; - let inner_ptr: &VMCallerCheckedAnyfunc = &*data; - VMFuncRef(inner_ptr) - } else { - let idx = inner.func_data.len(); - inner.func_data.push(Box::new(anyfunc.clone())); - inner.anyfunc_to_index.insert(anyfunc, idx); - - let data: &Box<_> = &inner.func_data[idx]; - let inner_ptr: &VMCallerCheckedAnyfunc = &*data; - VMFuncRef(inner_ptr) - } - } -} diff --git a/lib/vm/src/instance/mod.rs b/lib/vm/src/instance/mod.rs index ac827ee4d97..cee930294b7 100644 --- a/lib/vm/src/instance/mod.rs +++ b/lib/vm/src/instance/mod.rs @@ -14,7 +14,7 @@ pub use allocator::InstanceAllocator; pub use r#ref::{InstanceRef, WeakInstanceRef, WeakOrStrongInstanceRef}; use crate::export::VMExtern; -use crate::func_data_registry::{FuncDataRegistry, VMFuncRef}; +use crate::func_data_registry::VMFuncRef; use crate::global::Global; use crate::imports::Imports; use crate::memory::{Memory, MemoryError}; @@ -92,8 +92,8 @@ pub(crate) struct Instance { /// get removed. A missing entry is considered equivalent to an empty slice. passive_data: RefCell>>, - /// mapping of function indices to their func ref backing data. - funcrefs: BoxedSlice, + /// TODO: document this + funcref_backings: BoxedSlice>, /// Hosts can store arbitrary per-instance information here. host_state: Box, @@ -634,7 +634,8 @@ impl Instance { if index == FunctionIndex::reserved_value() { return VMFuncRef::null(); } - self.funcrefs[index] + let entry: &VMCallerCheckedAnyfunc = &*self.funcref_backings[index]; + VMFuncRef(entry as *const VMCallerCheckedAnyfunc) } /// The `table.init` operation: initializes a portion of a table with a @@ -903,7 +904,6 @@ impl InstanceHandle { finished_globals: BoxedSlice>, imports: Imports, vmshared_signatures: BoxedSlice, - func_data_registry: &FuncDataRegistry, host_state: Box, imported_function_envs: BoxedSlice, ) -> Result { @@ -917,7 +917,7 @@ impl InstanceHandle { let handle = { let offsets = allocator.offsets().clone(); // use dummy value to create an instance so we can get the vmctx pointer - let funcrefs = PrimaryMap::new().into_boxed_slice(); + let funcref_backings = PrimaryMap::new().into_boxed_slice(); // Create the `Instance`. The unique, the One. let instance = Instance { module, @@ -930,7 +930,7 @@ impl InstanceHandle { passive_elements: Default::default(), passive_data, host_state, - funcrefs, + funcref_backings, imported_function_envs, vmctx: VMContext {}, }; @@ -941,11 +941,10 @@ impl InstanceHandle { { let instance = instance_ref.as_mut().unwrap(); let vmctx_ptr = instance.vmctx_ptr(); - instance.funcrefs = build_funcrefs( + instance.funcref_backings = build_funcrefs( &*instance.module, &imports, &instance.functions, - func_data_registry, &vmshared_signatures, vmctx_ptr, ); @@ -1436,10 +1435,9 @@ fn build_funcrefs( module_info: &ModuleInfo, imports: &Imports, finished_functions: &BoxedSlice, - func_data_registry: &FuncDataRegistry, vmshared_signatures: &BoxedSlice, vmctx_ptr: *mut VMContext, -) -> BoxedSlice { +) -> BoxedSlice> { let mut func_refs = PrimaryMap::with_capacity(module_info.functions.len()); // do imported functions @@ -1451,8 +1449,7 @@ fn build_funcrefs( type_index, vmctx: import.environment, }; - let func_ref = func_data_registry.register(anyfunc); - func_refs.push(func_ref); + func_refs.push(Box::new(anyfunc)); } // do local functions @@ -1465,8 +1462,7 @@ fn build_funcrefs( type_index, vmctx: VMFunctionEnvironment { vmctx: vmctx_ptr }, }; - let func_ref = func_data_registry.register(anyfunc); - func_refs.push(func_ref); + func_refs.push(Box::new(anyfunc)); } func_refs.into_boxed_slice() diff --git a/lib/vm/src/lib.rs b/lib/vm/src/lib.rs index ecf4fd71ff6..fc2bbca85bc 100644 --- a/lib/vm/src/lib.rs +++ b/lib/vm/src/lib.rs @@ -38,7 +38,7 @@ mod vmoffsets; pub mod libcalls; pub use crate::export::*; -pub use crate::func_data_registry::{FuncDataRegistry, VMFuncRef}; +pub use crate::func_data_registry::VMFuncRef; pub use crate::global::*; pub use crate::imports::Imports; pub use crate::instance::{ diff --git a/tests/ignores.txt b/tests/ignores.txt index d188ba82721..60af3d5a412 100644 --- a/tests/ignores.txt +++ b/tests/ignores.txt @@ -6,6 +6,11 @@ singlepass+dylib * # It needs to add support for PIC in Singlepass. Not implemen windows+dylib * # This might be trivial to fix? musl+dylib * # Dynamic loading not supported in Musl +# Linking tests are not fully passing because of an issue with how reference types was +# initially implemented, we will fix this. +# Related issue: #2438 +spec::linking + # Traps ## Traps. Tracing doesn't work properly in Singlepass ## Unwinding is not properly implemented in Singlepass diff --git a/tests/lib/engine-dummy/src/artifact.rs b/tests/lib/engine-dummy/src/artifact.rs index 72fc3d4552e..fa9f1534e17 100644 --- a/tests/lib/engine-dummy/src/artifact.rs +++ b/tests/lib/engine-dummy/src/artifact.rs @@ -16,8 +16,8 @@ use wasmer_types::{ SignatureIndex, TableIndex, }; use wasmer_vm::{ - FuncDataRegistry, FunctionBodyPtr, MemoryStyle, TableStyle, VMContext, VMFunctionBody, - VMSharedSignatureIndex, VMTrampoline, + FunctionBodyPtr, MemoryStyle, TableStyle, VMContext, VMFunctionBody, VMSharedSignatureIndex, + VMTrampoline, }; /// Serializable struct for the artifact @@ -44,7 +44,6 @@ pub struct DummyArtifact { finished_function_call_trampolines: BoxedSlice, finished_dynamic_function_trampolines: BoxedSlice, signatures: BoxedSlice, - func_data_registry: Arc, } extern "C" fn dummy_function(_context: *mut VMContext) { @@ -185,7 +184,6 @@ impl DummyArtifact { finished_function_call_trampolines, finished_dynamic_function_trampolines, signatures, - func_data_registry: engine.func_data().clone(), }) } } @@ -239,10 +237,6 @@ impl Artifact for DummyArtifact { &self.signatures } - fn func_data_registry(&self) -> &FuncDataRegistry { - &self.func_data_registry - } - #[cfg(feature = "serialize")] fn serialize(&self) -> Result, SerializeError> { let bytes = bincode::serialize(&self.metadata) diff --git a/tests/lib/engine-dummy/src/engine.rs b/tests/lib/engine-dummy/src/engine.rs index cdc80b81b1f..ca9b0c4a9c0 100644 --- a/tests/lib/engine-dummy/src/engine.rs +++ b/tests/lib/engine-dummy/src/engine.rs @@ -6,10 +6,7 @@ use std::sync::Arc; use wasmer_compiler::{CompileError, Features, Target}; use wasmer_engine::{Artifact, DeserializeError, Engine, EngineId, Tunables}; use wasmer_types::FunctionType; -use wasmer_vm::{ - FuncDataRegistry, SignatureRegistry, VMCallerCheckedAnyfunc, VMContext, VMFuncRef, - VMFunctionBody, VMSharedSignatureIndex, -}; +use wasmer_vm::{SignatureRegistry, VMContext, VMFunctionBody, VMSharedSignatureIndex}; #[allow(dead_code)] extern "C" fn dummy_trampoline( @@ -24,7 +21,6 @@ extern "C" fn dummy_trampoline( #[derive(Clone, MemoryUsage)] pub struct DummyEngine { signatures: Arc, - func_data: Arc, features: Arc, target: Arc, engine_id: EngineId, @@ -35,7 +31,6 @@ impl DummyEngine { pub fn new() -> Self { Self { signatures: Arc::new(SignatureRegistry::new()), - func_data: Arc::new(FuncDataRegistry::new()), features: Arc::new(Default::default()), target: Arc::new(Default::default()), engine_id: EngineId::default(), @@ -45,11 +40,6 @@ impl DummyEngine { pub fn features(&self) -> &Features { &self.features } - - /// Shared func metadata registry. - pub(crate) fn func_data(&self) -> &Arc { - &self.func_data - } } impl Engine for DummyEngine { @@ -63,10 +53,6 @@ impl Engine for DummyEngine { self.signatures.register(func_type) } - fn register_function_metadata(&self, func_data: VMCallerCheckedAnyfunc) -> VMFuncRef { - self.func_data.register(func_data) - } - /// Lookup a signature fn lookup_signature(&self, sig: VMSharedSignatureIndex) -> Option { self.signatures.lookup(sig)