pub struct Artifact { /* private fields */ }
Expand description
A compiled wasm module, ready to be instantiated.
Implementations§
source§impl Artifact
impl Artifact
sourcepub fn new(
engine: &Engine,
data: &[u8],
tunables: &dyn Tunables
) -> Result<Artifact, CompileError>
pub fn new(
engine: &Engine,
data: &[u8],
tunables: &dyn Tunables
) -> Result<Artifact, CompileError>
Compile a data buffer into a ArtifactBuild
, which may then be instantiated.
sourcepub unsafe fn deserialize(
engine: &Engine,
bytes: &[u8]
) -> Result<Artifact, DeserializeError>
pub unsafe fn deserialize(
engine: &Engine,
bytes: &[u8]
) -> Result<Artifact, DeserializeError>
Deserialize a ArtifactBuild
Safety
This function is unsafe because rkyv reads directly without validating the data.
sourcepub fn from_parts(
engine_inner: &mut EngineInner,
artifact: ArtifactBuild
) -> Result<Artifact, CompileError>
pub fn from_parts(
engine_inner: &mut EngineInner,
artifact: ArtifactBuild
) -> Result<Artifact, CompileError>
Construct a ArtifactBuild
from component parts.
sourcepub fn is_deserializable(bytes: &[u8]) -> bool
pub fn is_deserializable(bytes: &[u8]) -> bool
Check if the provided bytes look like a serialized ArtifactBuild
.
source§impl Artifact
impl Artifact
sourcepub fn register_frame_info(&self)
pub fn register_frame_info(&self)
Register thie Artifact
stack frame information into the global scope.
This is required to ensure that any traps can be properly symbolicated.
sourcepub fn finished_functions(
&self
) -> &BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>
pub fn finished_functions(
&self
) -> &BoxedSlice<LocalFunctionIndex, FunctionBodyPtr>
Returns the functions allocated in memory or this Artifact
ready to be run.
sourcepub fn finished_function_call_trampolines(
&self
) -> &BoxedSlice<SignatureIndex, unsafe extern "C" fn(_: *mut VMContext, _: *const VMFunctionBody, _: *mut RawValue)>
pub fn finished_function_call_trampolines(
&self
) -> &BoxedSlice<SignatureIndex, unsafe extern "C" fn(_: *mut VMContext, _: *const VMFunctionBody, _: *mut RawValue)>
Returns the function call trampolines allocated in memory of this
Artifact
, ready to be run.
sourcepub fn finished_dynamic_function_trampolines(
&self
) -> &BoxedSlice<FunctionIndex, FunctionBodyPtr>
pub fn finished_dynamic_function_trampolines(
&self
) -> &BoxedSlice<FunctionIndex, FunctionBodyPtr>
Returns the dynamic function trampolines allocated in memory
of this Artifact
, ready to be run.
sourcepub fn signatures(&self) -> &BoxedSlice<SignatureIndex, VMSharedSignatureIndex>
pub fn signatures(&self) -> &BoxedSlice<SignatureIndex, VMSharedSignatureIndex>
Returns the associated VM signatures for this Artifact
.
sourcepub fn preinstantiate(&self) -> Result<(), InstantiationError>
pub fn preinstantiate(&self) -> Result<(), InstantiationError>
Do preinstantiation logic that is executed before instantiating
sourcepub unsafe fn instantiate(
&self,
tunables: &dyn Tunables,
imports: &[VMExtern],
context: &mut StoreObjects
) -> Result<InstanceHandle, InstantiationError>
pub unsafe fn instantiate(
&self,
tunables: &dyn Tunables,
imports: &[VMExtern],
context: &mut StoreObjects
) -> Result<InstanceHandle, InstantiationError>
sourcepub unsafe fn finish_instantiation(
&self,
trap_handler: Option<*const dyn Fn(i32, *const siginfo_t, *const c_void) -> bool + Send + Sync + 'static>,
handle: &mut InstanceHandle
) -> Result<(), InstantiationError>
pub unsafe fn finish_instantiation(
&self,
trap_handler: Option<*const dyn Fn(i32, *const siginfo_t, *const c_void) -> bool + Send + Sync + 'static>,
handle: &mut InstanceHandle
) -> Result<(), InstantiationError>
Finishes the instantiation of a just created InstanceHandle
.
Safety
sourcepub fn generate_object<'data>(
compiler: &dyn Compiler,
data: &[u8],
prefixer: Option<Box<dyn Fn(&[u8]) -> String + Send + 'static, Global>>,
target: &'data Target,
tunables: &dyn Tunables,
features: &Features
) -> Result<(ModuleInfo, Object<'data>, usize, Box<dyn SymbolRegistry + 'static, Global>), CompileError>
pub fn generate_object<'data>(
compiler: &dyn Compiler,
data: &[u8],
prefixer: Option<Box<dyn Fn(&[u8]) -> String + Send + 'static, Global>>,
target: &'data Target,
tunables: &dyn Tunables,
features: &Features
) -> Result<(ModuleInfo, Object<'data>, usize, Box<dyn SymbolRegistry + 'static, Global>), CompileError>
Compile a module into an object file, which can be statically linked against.
The prefixer
returns the a String to prefix each of the
functions in the static object generated by the
so we can assure no collisions.
sourcepub unsafe fn deserialize_object(
engine: &Engine,
bytes: &[u8]
) -> Result<Artifact, DeserializeError>
pub unsafe fn deserialize_object(
engine: &Engine,
bytes: &[u8]
) -> Result<Artifact, DeserializeError>
Deserialize a ArtifactBuild from an object file
Safety
The object must be a valid static object generated by wasmer.
Trait Implementations§
source§impl ArtifactCreate for Artifact
impl ArtifactCreate for Artifact
source§fn create_module_info(&self) -> ModuleInfo
fn create_module_info(&self) -> ModuleInfo
ModuleInfo
for instantiationsource§fn cpu_features(&self) -> EnumSet<CpuFeature>
fn cpu_features(&self) -> EnumSet<CpuFeature>
source§fn data_initializers(&self) -> &[OwnedDataInitializer]
fn data_initializers(&self) -> &[OwnedDataInitializer]
InstanceHandle::initialize
source§fn memory_styles(&self) -> &PrimaryMap<MemoryIndex, MemoryStyle>
fn memory_styles(&self) -> &PrimaryMap<MemoryIndex, MemoryStyle>
Artifact
.source§fn table_styles(&self) -> &PrimaryMap<TableIndex, TableStyle>
fn table_styles(&self) -> &PrimaryMap<TableIndex, TableStyle>
Artifact
.