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 thiserror::Error;
|
||||
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::wasm::{DefinedFuncIndex, SignatureIndex};
|
||||
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 Sync for FinishedFunctions {}
|
||||
@@ -207,7 +207,7 @@ impl CompiledModule {
|
||||
None
|
||||
};
|
||||
|
||||
let finished_functions = FinishedFunctions(finished_functions.into_boxed_slice());
|
||||
let finished_functions = FinishedFunctions(finished_functions);
|
||||
|
||||
Ok(Self {
|
||||
module: Arc::new(module),
|
||||
@@ -271,12 +271,10 @@ impl CompiledModule {
|
||||
trampolines.insert(signatures[i], trampoline.clone());
|
||||
}
|
||||
|
||||
let finished_functions = self.finished_functions.0.clone();
|
||||
|
||||
InstanceHandle::new(
|
||||
self.module.clone(),
|
||||
self.code.clone(),
|
||||
finished_functions,
|
||||
&self.finished_functions.0,
|
||||
trampolines,
|
||||
imports,
|
||||
mem_creator,
|
||||
@@ -310,7 +308,7 @@ impl CompiledModule {
|
||||
}
|
||||
|
||||
/// 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
|
||||
}
|
||||
|
||||
|
||||
@@ -62,9 +62,6 @@ pub(crate) struct Instance {
|
||||
/// get removed. A missing entry is considered equivalent to an empty slice.
|
||||
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
|
||||
trampolines: HashMap<VMSharedSignatureIndex, VMTrampoline>,
|
||||
|
||||
@@ -821,7 +818,7 @@ impl InstanceHandle {
|
||||
pub unsafe fn new(
|
||||
module: Arc<Module>,
|
||||
code: Arc<dyn Any>,
|
||||
finished_functions: BoxedSlice<DefinedFuncIndex, *mut [VMFunctionBody]>,
|
||||
finished_functions: &PrimaryMap<DefinedFuncIndex, *mut [VMFunctionBody]>,
|
||||
trampolines: HashMap<VMSharedSignatureIndex, VMTrampoline>,
|
||||
imports: Imports,
|
||||
mem_creator: Option<&dyn RuntimeMemoryCreator>,
|
||||
@@ -864,7 +861,6 @@ impl InstanceHandle {
|
||||
tables,
|
||||
passive_elements: Default::default(),
|
||||
passive_data,
|
||||
finished_functions,
|
||||
trampolines,
|
||||
host_state,
|
||||
interrupts,
|
||||
@@ -944,7 +940,7 @@ impl InstanceHandle {
|
||||
let (func_ptr, vmctx) =
|
||||
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(),
|
||||
)
|
||||
} else {
|
||||
|
||||
@@ -36,7 +36,7 @@ pub(crate) fn create_handle(
|
||||
let handle = InstanceHandle::new(
|
||||
Arc::new(module),
|
||||
Arc::new(()),
|
||||
finished_functions.into_boxed_slice(),
|
||||
&finished_functions,
|
||||
trampolines,
|
||||
imports,
|
||||
store.memory_creator(),
|
||||
|
||||
Reference in New Issue
Block a user