Expose some more internals publicly (#340)
This commit is contained in:
committed by
Sergei Pepyakin
parent
f27e0ad53c
commit
71dd73d672
@@ -8,7 +8,7 @@ use region;
|
||||
use wasmtime_runtime::{Mmap, VMFunctionBody};
|
||||
|
||||
/// Memory manager for executable code.
|
||||
pub(crate) struct CodeMemory {
|
||||
pub struct CodeMemory {
|
||||
current: Mmap,
|
||||
mmaps: Vec<Mmap>,
|
||||
position: usize,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::action::{get, inspect_memory, invoke};
|
||||
use crate::HashMap;
|
||||
use crate::{
|
||||
instantiate, ActionError, ActionOutcome, CompilationStrategy, Compiler, InstanceHandle,
|
||||
Namespace, RuntimeValue, SetupError,
|
||||
instantiate, ActionError, ActionOutcome, CompilationStrategy, CompiledModule, Compiler,
|
||||
InstanceHandle, Namespace, RuntimeValue, SetupError,
|
||||
};
|
||||
use alloc::boxed::Box;
|
||||
use alloc::rc::Rc;
|
||||
@@ -160,6 +160,20 @@ impl Context {
|
||||
Ok(instance)
|
||||
}
|
||||
|
||||
/// Compile a module.
|
||||
pub fn compile_module(&mut self, data: &[u8]) -> Result<CompiledModule, SetupError> {
|
||||
self.validate(&data).map_err(SetupError::Validate)?;
|
||||
let debug_info = self.debug_info();
|
||||
|
||||
CompiledModule::new(
|
||||
&mut *self.compiler,
|
||||
data,
|
||||
&mut self.namespace,
|
||||
Rc::clone(&self.global_exports),
|
||||
debug_info,
|
||||
)
|
||||
}
|
||||
|
||||
/// If `name` isn't None, register it for the given instance.
|
||||
pub fn optionally_name_instance(&mut self, name: Option<String>, instance: InstanceHandle) {
|
||||
if let Some(name) = name {
|
||||
|
||||
@@ -223,6 +223,16 @@ impl CompiledModule {
|
||||
Box::new(()),
|
||||
)
|
||||
}
|
||||
|
||||
/// Return a reference-counting pointer to a module.
|
||||
pub fn module(&self) -> Rc<Module> {
|
||||
self.module.clone()
|
||||
}
|
||||
|
||||
/// Return a reference to a module.
|
||||
pub fn module_ref(&self) -> &Module {
|
||||
&self.module
|
||||
}
|
||||
}
|
||||
|
||||
/// Similar to `DataInitializer`, but owns its own copy of the data rather
|
||||
|
||||
@@ -44,6 +44,7 @@ mod resolver;
|
||||
mod target_tunables;
|
||||
|
||||
pub use crate::action::{ActionError, ActionOutcome, RuntimeValue};
|
||||
pub use crate::code_memory::CodeMemory;
|
||||
pub use crate::compiler::{CompilationStrategy, Compiler};
|
||||
pub use crate::context::{Context, ContextError, Features, UnknownInstance};
|
||||
pub use crate::instantiate::{instantiate, CompiledModule, SetupError};
|
||||
|
||||
Reference in New Issue
Block a user