Move the signature registry into Engine.
This commit moves the shared signature registry out of `Store` and into `Engine`. This helps eliminate work that was performed whenever a `Module` was instantiated into a `Store`. Now a `Module` is registered with the shared signature registry upon creation, storing the mapping from the module's signature index space to the shared index space. This also refactors the "frame info" registry into a general purpose "module registry" that is used to look up trap information, signature information, and (soon) stack map information.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
//! Support for a calling of an imported function.
|
||||
|
||||
use crate::{sig_registry::SignatureRegistry, Config, FuncType, Trap};
|
||||
use crate::{Config, FuncType, Store, Trap};
|
||||
use anyhow::Result;
|
||||
use std::any::Any;
|
||||
use std::cmp;
|
||||
@@ -262,15 +262,15 @@ pub fn create_function(
|
||||
ft: &FuncType,
|
||||
func: Box<dyn Fn(*mut VMContext, *mut u128) -> Result<(), Trap>>,
|
||||
config: &Config,
|
||||
registry: Option<&mut SignatureRegistry>,
|
||||
store: Option<&Store>,
|
||||
) -> Result<(InstanceHandle, VMTrampoline)> {
|
||||
let (module, finished_functions, trampoline, trampoline_state) =
|
||||
create_function_trampoline(config, ft, func)?;
|
||||
|
||||
// If there is no signature registry, use the default signature index which is
|
||||
// If there is no store, use the default signature index which is
|
||||
// guaranteed to trap if there is ever an indirect call on the function (should not happen)
|
||||
let shared_signature_id = registry
|
||||
.map(|r| r.register(ft.as_wasm_func_type(), trampoline))
|
||||
let shared_signature_id = store
|
||||
.map(|s| s.register_signature(ft.as_wasm_func_type(), trampoline))
|
||||
.unwrap_or(VMSharedSignatureIndex::default());
|
||||
|
||||
unsafe {
|
||||
|
||||
Reference in New Issue
Block a user