Option for host managed memory (#1400)
* Option for host managed memory * Rename Allocator to MemoryCreator * Create LinearMemory and MemoryCreator traits in api * Leave only one as_ptr function in LinearMemory trait * Memory creator test * Update comments/docs for LinearMemory and MemoryCreator traits * Add guard page to the custom memory example * Remove mut from LinearMemory trait as_ptr * Host_memory_grow test
This commit is contained in:
@@ -20,8 +20,8 @@ use wasmtime_environ::{
|
||||
};
|
||||
use wasmtime_profiling::ProfilingAgent;
|
||||
use wasmtime_runtime::{
|
||||
GdbJitImageRegistration, InstanceHandle, InstantiationError, SignatureRegistry,
|
||||
TrapRegistration, VMFunctionBody, VMSharedSignatureIndex, VMTrampoline,
|
||||
GdbJitImageRegistration, InstanceHandle, InstantiationError, RuntimeMemoryCreator,
|
||||
SignatureRegistry, TrapRegistration, VMFunctionBody, VMSharedSignatureIndex, VMTrampoline,
|
||||
};
|
||||
|
||||
/// An error condition while setting up a wasm instance, be it validation,
|
||||
@@ -203,6 +203,7 @@ impl CompiledModule {
|
||||
is_bulk_memory: bool,
|
||||
resolver: &mut dyn Resolver,
|
||||
sig_registry: &SignatureRegistry,
|
||||
mem_creator: Option<&dyn RuntimeMemoryCreator>,
|
||||
) -> Result<InstanceHandle, InstantiationError> {
|
||||
let data_initializers = self
|
||||
.data_initializers
|
||||
@@ -219,6 +220,7 @@ impl CompiledModule {
|
||||
self.finished_functions.clone(),
|
||||
self.trampolines.clone(),
|
||||
imports,
|
||||
mem_creator,
|
||||
&data_initializers,
|
||||
self.signatures.clone(),
|
||||
self.dbg_jit_registration.as_ref().map(|r| Rc::clone(&r)),
|
||||
@@ -283,11 +285,13 @@ pub unsafe fn instantiate(
|
||||
debug_info: bool,
|
||||
is_bulk_memory: bool,
|
||||
profiler: &dyn ProfilingAgent,
|
||||
mem_creator: Option<&dyn RuntimeMemoryCreator>,
|
||||
) -> Result<InstanceHandle, SetupError> {
|
||||
let instance = CompiledModule::new(compiler, data, debug_info, profiler)?.instantiate(
|
||||
is_bulk_memory,
|
||||
resolver,
|
||||
compiler.signatures(),
|
||||
mem_creator,
|
||||
)?;
|
||||
Ok(instance)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user