Move the Store::signature_cache field (#847)
This commit removes the `signature_cache` field from the `Store` type and performs a few internal changes which are aimed to be a bit forward looking towards #777, making `Store` threadsafe. The changes made here are: * The `SignatureRegistry` internal type now contains the reverse map that `signature_cache` was serving to do. This is populated on calls to `register` automatically and is accompanied by a `lookup` method as well. * The `register_wasmtime_signature` and `lookup_wasmtime_signature` methods were removed from `Store` and now instead work by using the `Compiler::signatures` field. * The `SignatureRegistry` type was updated to have interior mutability. The global `Compiler` type is highly likely to get shared across many threads through `Store`, so it needs some form of lock somewhere for mutation of the registry of signatures and this commit opts to put it inside `SignatureRegistry` which will eventually allow for the removal of most `&mut self` method on `Compiler`.
This commit is contained in:
@@ -12,7 +12,7 @@ use wasmtime_runtime::{Imports, InstanceHandle, VMFunctionBody};
|
||||
|
||||
pub(crate) fn create_handle(
|
||||
module: Module,
|
||||
signature_registry: Option<&Store>,
|
||||
store: Option<&Store>,
|
||||
finished_functions: PrimaryMap<DefinedFuncIndex, *const VMFunctionBody>,
|
||||
state: Box<dyn Any>,
|
||||
) -> Result<InstanceHandle> {
|
||||
@@ -26,12 +26,12 @@ pub(crate) fn create_handle(
|
||||
let data_initializers = Vec::new();
|
||||
|
||||
// Compute indices into the shared signature table.
|
||||
let signatures = signature_registry
|
||||
.map(|signature_registry| {
|
||||
let signatures = store
|
||||
.map(|store| {
|
||||
module
|
||||
.signatures
|
||||
.values()
|
||||
.map(|sig| signature_registry.register_wasmtime_signature(sig))
|
||||
.map(|sig| store.compiler().signatures().register(sig))
|
||||
.collect::<PrimaryMap<_, _>>()
|
||||
})
|
||||
.unwrap_or_else(PrimaryMap::new);
|
||||
|
||||
Reference in New Issue
Block a user