pub struct Artifact {
id: ArtifactId,
artifact: ArtifactBuildVariant,
allocated: Option<AllocatedArtifact>,
}
Expand description
A compiled wasm module, ready to be instantiated.
Fields§
§id: ArtifactId
§artifact: ArtifactBuildVariant
§allocated: Option<AllocatedArtifact>
Implementations§
§impl Artifact
impl Artifact
pub fn new(
engine: &Engine,
data: &[u8],
tunables: &dyn Tunables,
hash_algorithm: Option<HashAlgorithm>
) -> Result<Artifact, CompileError>
pub fn new( engine: &Engine, data: &[u8], tunables: &dyn Tunables, hash_algorithm: Option<HashAlgorithm> ) -> Result<Artifact, CompileError>
Compile a data buffer into a ArtifactBuild
, which may then be instantiated.
pub fn allocated(&self) -> bool
pub fn allocated(&self) -> bool
This indicates if the Artifact is allocated and can be run by the current host. In case it can’t be run (for example, if the artifact is cross compiled to other architecture), it will return false.
pub fn id(&self) -> &ArtifactId
pub fn id(&self) -> &ArtifactId
A unique identifier for this object.
This exists to allow us to compare two Artifacts for equality. Otherwise, comparing two trait objects unsafely relies on implementation details of trait representation.
pub unsafe fn deserialize(
engine: &Engine,
bytes: OwnedBuffer
) -> Result<Artifact, DeserializeError>
pub unsafe fn deserialize( engine: &Engine, bytes: OwnedBuffer ) -> Result<Artifact, DeserializeError>
Deserialize a serialized artifact.
Safety
This function loads executable code into memory.
You must trust the loaded bytes to be valid for the chosen engine and
for the host CPU architecture.
In contrast to Self::deserialize_unchecked
the artifact layout is
validated, which increases safety.
pub unsafe fn deserialize_unchecked(
engine: &Engine,
bytes: OwnedBuffer
) -> Result<Artifact, DeserializeError>
pub unsafe fn deserialize_unchecked( engine: &Engine, bytes: OwnedBuffer ) -> Result<Artifact, DeserializeError>
Deserialize a serialized artifact.
NOTE: You should prefer Self::deserialize
.
Safety
See Self::deserialize
.
In contrast to the above, this function skips artifact layout validation,
which increases the risk of loading invalid artifacts.
pub fn from_parts(
engine_inner: &mut EngineInner,
artifact: ArtifactBuildVariant,
target: &Target
) -> Result<Artifact, DeserializeError>
pub fn from_parts( engine_inner: &mut EngineInner, artifact: ArtifactBuildVariant, target: &Target ) -> Result<Artifact, DeserializeError>
Construct a ArtifactBuild
from component parts.
pub fn is_deserializable(bytes: &[u8]) -> bool
pub fn is_deserializable(bytes: &[u8]) -> bool
Check if the provided bytes look like a serialized ArtifactBuild
.
§impl Artifact
impl Artifact
pub fn register_frame_info(&mut self) -> Result<(), DeserializeError>
👎Deprecated since 4.0.0: done automaticaly by Artifact::from_parts, use ‘take_frame_info_registration’ if you use this method
pub fn register_frame_info(&mut self) -> Result<(), DeserializeError>
Register thie Artifact
stack frame information into the global scope.
This is not required anymore as it’s done automaticaly when creating by ‘Artifact::from_parts’
pub fn take_frame_info_registration(
&mut self
) -> Option<GlobalFrameInfoRegistration>
👎Deprecated since 4.0.0: done automaticaly by Artifact::from_parts.
pub fn take_frame_info_registration( &mut self ) -> Option<GlobalFrameInfoRegistration>
The GlobalFrameInfoRegistration needs to be transfered to EngineInner if register_frame_info has been used.
pub 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.
pub 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.
pub 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.
pub fn signatures(&self) -> &BoxedSlice<SignatureIndex, VMSharedSignatureIndex>
pub fn signatures(&self) -> &BoxedSlice<SignatureIndex, VMSharedSignatureIndex>
Returns the associated VM signatures for this Artifact
.
pub fn preinstantiate(&self) -> Result<(), InstantiationError>
pub fn preinstantiate(&self) -> Result<(), InstantiationError>
Do preinstantiation logic that is executed before instantiating
pub unsafe fn instantiate(
&self,
tunables: &dyn Tunables,
imports: &[VMExtern],
context: &mut StoreObjects
) -> Result<VMInstance, InstantiationError>
pub unsafe fn instantiate( &self, tunables: &dyn Tunables, imports: &[VMExtern], context: &mut StoreObjects ) -> Result<VMInstance, InstantiationError>
pub unsafe fn finish_instantiation(
&self,
config: &VMConfig,
trap_handler: Option<*const dyn Fn(i32, *const siginfo_t, *const c_void) -> bool + Sync + Send>,
handle: &mut VMInstance
) -> Result<(), InstantiationError>
pub unsafe fn finish_instantiation( &self, config: &VMConfig, trap_handler: Option<*const dyn Fn(i32, *const siginfo_t, *const c_void) -> bool + Sync + Send>, handle: &mut VMInstance ) -> Result<(), InstantiationError>
Finishes the instantiation of a just created VMInstance
.
Safety
pub fn generate_metadata<'data>(
data: &'data [u8],
compiler: &dyn Compiler,
tunables: &dyn Tunables,
features: &Features
) -> Result<(CompileModuleInfo, PrimaryMap<LocalFunctionIndex, FunctionBodyData<'data>>, Vec<DataInitializer<'data>, Global>, Option<ModuleTranslationState>), CompileError>
pub fn generate_metadata<'data>( data: &'data [u8], compiler: &dyn Compiler, tunables: &dyn Tunables, features: &Features ) -> Result<(CompileModuleInfo, PrimaryMap<LocalFunctionIndex, FunctionBodyData<'data>>, Vec<DataInitializer<'data>, Global>, Option<ModuleTranslationState>), CompileError>
Generate a compilation
pub fn metadata<'a>(
compiler: &dyn Compiler,
data: &'a [u8],
metadata_prefix: Option<&str>,
target: &Target,
tunables: &dyn Tunables,
features: &Features
) -> Result<(ModuleMetadata, Option<ModuleTranslationState>, PrimaryMap<LocalFunctionIndex, FunctionBodyData<'a>>), CompileError>
pub fn metadata<'a>( compiler: &dyn Compiler, data: &'a [u8], metadata_prefix: Option<&str>, target: &Target, tunables: &dyn Tunables, features: &Features ) -> Result<(ModuleMetadata, Option<ModuleTranslationState>, PrimaryMap<LocalFunctionIndex, FunctionBodyData<'a>>), CompileError>
Generate the metadata object for the module
pub fn generate_object<'data>(
compiler: &dyn Compiler,
data: &[u8],
metadata_prefix: Option<&str>,
target: &'data Target,
tunables: &dyn Tunables,
features: &Features
) -> Result<(ModuleInfo, Object<'data>, usize, Box<dyn SymbolRegistry, Global>), CompileError>
pub fn generate_object<'data>( compiler: &dyn Compiler, data: &[u8], metadata_prefix: Option<&str>, target: &'data Target, tunables: &dyn Tunables, features: &Features ) -> Result<(ModuleInfo, Object<'data>, usize, Box<dyn SymbolRegistry, Global>), CompileError>
Compile a module into an object file, which can be statically linked against.
The metadata_prefix
is an optional prefix for the object name to make the
function names in the object file unique. When set, the function names will
be wasmer_function_{prefix}_{id}
and the object metadata will be addressable
using WASMER_METADATA_{prefix}_LENGTH
and WASMER_METADATA_{prefix}_DATA
.
pub unsafe fn deserialize_object(
engine: &Engine,
bytes: OwnedBuffer
) -> Result<Artifact, DeserializeError>
pub unsafe fn deserialize_object( engine: &Engine, bytes: OwnedBuffer ) -> Result<Artifact, DeserializeError>
Deserialize a ArtifactBuild from an object file
Safety
The object must be a valid static object generated by wasmer.
Trait Implementations§
§impl<'a> ArtifactCreate<'a> for Artifact
impl<'a> ArtifactCreate<'a> for Artifact
§type OwnedDataInitializer = <ArtifactBuildVariant as ArtifactCreate<'a>>::OwnedDataInitializer
type OwnedDataInitializer = <ArtifactBuildVariant as ArtifactCreate<'a>>::OwnedDataInitializer
OwnedDataInitializer
returned by the data_initializers
method§type OwnedDataInitializerIterator = <ArtifactBuildVariant as ArtifactCreate<'a>>::OwnedDataInitializerIterator
type OwnedDataInitializerIterator = <ArtifactBuildVariant as ArtifactCreate<'a>>::OwnedDataInitializerIterator
data_initializers
method§fn set_module_info_name(&mut self, name: String) -> bool
fn set_module_info_name(&mut self, name: String) -> bool
ModuleInfo
name§fn create_module_info(&self) -> Arc<ModuleInfo, Global>
fn create_module_info(&self) -> Arc<ModuleInfo, Global>
ModuleInfo
for instantiation§fn module_info(&self) -> &ModuleInfo
fn module_info(&self) -> &ModuleInfo
ModuleInfo
for instantiation§fn cpu_features(&self) -> EnumSet<CpuFeature>
fn cpu_features(&self) -> EnumSet<CpuFeature>
§fn data_initializers(
&'a self
) -> <Artifact as ArtifactCreate<'a>>::OwnedDataInitializerIterator
fn data_initializers( &'a self ) -> <Artifact as ArtifactCreate<'a>>::OwnedDataInitializerIterator
VMInstance::initialize
§fn memory_styles(&self) -> &PrimaryMap<MemoryIndex, MemoryStyle>
fn memory_styles(&self) -> &PrimaryMap<MemoryIndex, MemoryStyle>
Artifact
.§fn table_styles(&self) -> &PrimaryMap<TableIndex, TableStyle>
fn table_styles(&self) -> &PrimaryMap<TableIndex, TableStyle>
Artifact
.impl Eq for Artifact
Auto Trait Implementations§
impl RefUnwindSafe for Artifact
impl Send for Artifact
impl Sync for Artifact
impl Unpin for Artifact
impl UnwindSafe for Artifact
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where F: FnOnce(&Self) -> bool,
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more