Struct Artifact

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

pub fn new( engine: &Engine, data: &[u8], tunables: &dyn Tunables, hash_algorithm: Option<HashAlgorithm>, progress_callback: Option<CompilationProgressCallback>, ) -> Result<Artifact, CompileError>

Compile a data buffer into a ArtifactBuild, which may then be instantiated.

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

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>

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>

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>

Construct a ArtifactBuild from component parts.

pub fn is_deserializable(bytes: &[u8]) -> bool

Check if the provided bytes look like a serialized ArtifactBuild.

§

impl Artifact

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)>

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>

Returns the dynamic function trampolines allocated in memory of this Artifact, ready to be run.

pub fn signatures(&self) -> &BoxedSlice<SignatureIndex, VMSharedSignatureIndex>

Returns the associated VM signatures for this Artifact.

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>

Crate an Instance from this Artifact.

§Safety

See VMInstance::new.

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

See VMInstance::finish_instantiation.

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>>, 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>

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>), 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>

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

§

type OwnedDataInitializer = <ArtifactBuildVariant as ArtifactCreate<'a>>::OwnedDataInitializer

Type of OwnedDataInitializer returned by the data_initializers method
§

type OwnedDataInitializerIterator = <ArtifactBuildVariant as ArtifactCreate<'a>>::OwnedDataInitializerIterator

Type of iterator returned by the data_initializers method
§

fn set_module_info_name(&mut self, name: String) -> bool

Sets the ModuleInfo name
§

fn create_module_info(&self) -> Arc<ModuleInfo>

Create a ModuleInfo for instantiation
§

fn module_info(&self) -> &ModuleInfo

Returns the ModuleInfo for instantiation
§

fn features(&self) -> &Features

Returns the features for this Artifact
§

fn cpu_features(&self) -> EnumSet<CpuFeature>

Returns the CPU features for this Artifact
§

fn data_initializers( &'a self, ) -> <Artifact as ArtifactCreate<'a>>::OwnedDataInitializerIterator

Returns data initializers to pass to VMInstance::initialize
§

fn memory_styles(&self) -> &PrimaryMap<MemoryIndex, MemoryStyle>

Returns the memory styles associated with this Artifact.
§

fn table_styles(&self) -> &PrimaryMap<TableIndex, TableStyle>

Returns the table plans associated with this Artifact.
§

fn serialize(&self) -> Result<Vec<u8>, SerializeError>

Serializes an artifact into bytes
§

impl Debug for Artifact

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl PartialEq for Artifact

§

fn eq(&self, other: &Artifact) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Eq for Artifact

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcastable for T
where T: Any + Send + Sync + 'static,

§

fn upcast_any_ref(&self) -> &(dyn Any + 'static)

upcast ref
§

fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)

upcast mut ref
§

fn upcast_any_box(self: Box<T>) -> Box<dyn Any>

upcast boxed dyn
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more