Remove the finished_functions field in Instance
Turns out we don't actually need it anywhere any more! This removes an allocation when instantiating.
This commit is contained in:
@@ -14,7 +14,7 @@ use std::collections::HashMap;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use wasmtime_debug::create_gdbjit_image;
|
use wasmtime_debug::create_gdbjit_image;
|
||||||
use wasmtime_environ::entity::{BoxedSlice, PrimaryMap};
|
use wasmtime_environ::entity::PrimaryMap;
|
||||||
use wasmtime_environ::isa::TargetIsa;
|
use wasmtime_environ::isa::TargetIsa;
|
||||||
use wasmtime_environ::wasm::{DefinedFuncIndex, SignatureIndex};
|
use wasmtime_environ::wasm::{DefinedFuncIndex, SignatureIndex};
|
||||||
use wasmtime_environ::{
|
use wasmtime_environ::{
|
||||||
@@ -134,7 +134,7 @@ impl CompilationArtifacts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FinishedFunctions(BoxedSlice<DefinedFuncIndex, *mut [VMFunctionBody]>);
|
struct FinishedFunctions(PrimaryMap<DefinedFuncIndex, *mut [VMFunctionBody]>);
|
||||||
|
|
||||||
unsafe impl Send for FinishedFunctions {}
|
unsafe impl Send for FinishedFunctions {}
|
||||||
unsafe impl Sync for FinishedFunctions {}
|
unsafe impl Sync for FinishedFunctions {}
|
||||||
@@ -207,7 +207,7 @@ impl CompiledModule {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let finished_functions = FinishedFunctions(finished_functions.into_boxed_slice());
|
let finished_functions = FinishedFunctions(finished_functions);
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
module: Arc::new(module),
|
module: Arc::new(module),
|
||||||
@@ -271,12 +271,10 @@ impl CompiledModule {
|
|||||||
trampolines.insert(signatures[i], trampoline.clone());
|
trampolines.insert(signatures[i], trampoline.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let finished_functions = self.finished_functions.0.clone();
|
|
||||||
|
|
||||||
InstanceHandle::new(
|
InstanceHandle::new(
|
||||||
self.module.clone(),
|
self.module.clone(),
|
||||||
self.code.clone(),
|
self.code.clone(),
|
||||||
finished_functions,
|
&self.finished_functions.0,
|
||||||
trampolines,
|
trampolines,
|
||||||
imports,
|
imports,
|
||||||
mem_creator,
|
mem_creator,
|
||||||
@@ -310,7 +308,7 @@ impl CompiledModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the map of all finished JIT functions compiled for this module
|
/// Returns the map of all finished JIT functions compiled for this module
|
||||||
pub fn finished_functions(&self) -> &BoxedSlice<DefinedFuncIndex, *mut [VMFunctionBody]> {
|
pub fn finished_functions(&self) -> &PrimaryMap<DefinedFuncIndex, *mut [VMFunctionBody]> {
|
||||||
&self.finished_functions.0
|
&self.finished_functions.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,9 +62,6 @@ pub(crate) struct Instance {
|
|||||||
/// get removed. A missing entry is considered equivalent to an empty slice.
|
/// get removed. A missing entry is considered equivalent to an empty slice.
|
||||||
passive_data: RefCell<HashMap<DataIndex, Arc<[u8]>>>,
|
passive_data: RefCell<HashMap<DataIndex, Arc<[u8]>>>,
|
||||||
|
|
||||||
/// Pointers to functions in executable memory.
|
|
||||||
finished_functions: BoxedSlice<DefinedFuncIndex, *mut [VMFunctionBody]>,
|
|
||||||
|
|
||||||
/// Pointers to trampoline functions used to enter particular signatures
|
/// Pointers to trampoline functions used to enter particular signatures
|
||||||
trampolines: HashMap<VMSharedSignatureIndex, VMTrampoline>,
|
trampolines: HashMap<VMSharedSignatureIndex, VMTrampoline>,
|
||||||
|
|
||||||
@@ -821,7 +818,7 @@ impl InstanceHandle {
|
|||||||
pub unsafe fn new(
|
pub unsafe fn new(
|
||||||
module: Arc<Module>,
|
module: Arc<Module>,
|
||||||
code: Arc<dyn Any>,
|
code: Arc<dyn Any>,
|
||||||
finished_functions: BoxedSlice<DefinedFuncIndex, *mut [VMFunctionBody]>,
|
finished_functions: &PrimaryMap<DefinedFuncIndex, *mut [VMFunctionBody]>,
|
||||||
trampolines: HashMap<VMSharedSignatureIndex, VMTrampoline>,
|
trampolines: HashMap<VMSharedSignatureIndex, VMTrampoline>,
|
||||||
imports: Imports,
|
imports: Imports,
|
||||||
mem_creator: Option<&dyn RuntimeMemoryCreator>,
|
mem_creator: Option<&dyn RuntimeMemoryCreator>,
|
||||||
@@ -864,7 +861,6 @@ impl InstanceHandle {
|
|||||||
tables,
|
tables,
|
||||||
passive_elements: Default::default(),
|
passive_elements: Default::default(),
|
||||||
passive_data,
|
passive_data,
|
||||||
finished_functions,
|
|
||||||
trampolines,
|
trampolines,
|
||||||
host_state,
|
host_state,
|
||||||
interrupts,
|
interrupts,
|
||||||
@@ -944,7 +940,7 @@ impl InstanceHandle {
|
|||||||
let (func_ptr, vmctx) =
|
let (func_ptr, vmctx) =
|
||||||
if let Some(def_index) = instance.module.defined_func_index(index) {
|
if let Some(def_index) = instance.module.defined_func_index(index) {
|
||||||
(
|
(
|
||||||
NonNull::new(instance.finished_functions[def_index] as *mut _).unwrap(),
|
NonNull::new(finished_functions[def_index] as *mut _).unwrap(),
|
||||||
instance.vmctx_ptr(),
|
instance.vmctx_ptr(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ pub(crate) fn create_handle(
|
|||||||
let handle = InstanceHandle::new(
|
let handle = InstanceHandle::new(
|
||||||
Arc::new(module),
|
Arc::new(module),
|
||||||
Arc::new(()),
|
Arc::new(()),
|
||||||
finished_functions.into_boxed_slice(),
|
&finished_functions,
|
||||||
trampolines,
|
trampolines,
|
||||||
imports,
|
imports,
|
||||||
store.memory_creator(),
|
store.memory_creator(),
|
||||||
|
|||||||
Reference in New Issue
Block a user