wasmtime

Struct CompiledModule

Source
pub struct CompiledModule { /* private fields */ }
Available on crate feature runtime only.
Expand description

A compiled wasm module, ready to be instantiated.

Implementations§

Source§

impl CompiledModule

Source

pub fn from_artifacts( code_memory: Arc<CodeMemory>, info: CompiledModuleInfo, profiler: &dyn ProfilingAgent, ) -> Result<Self>

Creates CompiledModule directly from a precompiled artifact.

The code_memory argument is expected to be the result of a previous call to ObjectBuilder::finish above. This is an ELF image, at this time, which contains all necessary information to create a CompiledModule from a compilation.

This method also takes info, an optionally-provided deserialization of the artifacts’ compilation metadata section. If this information is not provided then the information will be deserialized from the image of the compilation artifacts. Otherwise it will be assumed to be what would otherwise happen if the section were to be deserialized.

The profiler argument here is used to inform JIT profiling runtimes about new code that is loaded.

Source

pub fn unique_id(&self) -> CompiledModuleId

Get this module’s unique ID. It is unique with respect to a single allocator (which is ordinarily held on a Wasm engine).

Source

pub fn mmap(&self) -> &MmapVec

Returns the underlying memory which contains the compiled module’s image.

Source

pub fn code_memory(&self) -> &Arc<CodeMemory>

Returns the underlying owned mmap of this compiled image.

Source

pub fn text(&self) -> &[u8]

Returns the text section of the ELF image for this compiled module.

This memory should have the read/execute permissions.

Source

pub fn module(&self) -> &Arc<Module>

Return a reference-counting pointer to a module.

Source

pub fn func_name(&self, idx: FuncIndex) -> Option<&str>

Looks up the name section name for the function index idx, if one was specified in the original wasm module.

Source

pub fn module_mut(&mut self) -> Option<&mut Module>

Return a reference to a mutable module (if possible).

Source

pub fn finished_functions( &self, ) -> impl ExactSizeIterator<Item = (DefinedFuncIndex, &[u8])> + '_

Returns an iterator over all functions defined within this module with their index and their body in memory.

Source

pub fn finished_function(&self, index: DefinedFuncIndex) -> &[u8]

Returns the body of the function that index points to.

Source

pub fn array_to_wasm_trampoline(&self, index: DefinedFuncIndex) -> Option<&[u8]>

Get the array-to-Wasm trampoline for the function index points to.

If the function index points to does not escape, then None is returned.

These trampolines are used for array callers (e.g. Func::new) calling Wasm callees.

Source

pub fn wasm_to_array_trampoline( &self, signature: ModuleInternedTypeIndex, ) -> &[u8]

Get the Wasm-to-array trampoline for the given signature.

These trampolines are used for filling in VMFuncRef::wasm_call for Func::wrap-style host funcrefs that don’t have access to a compiler when created.

Source

pub fn stack_maps( &self, ) -> impl Iterator<Item = (&[u8], &[StackMapInformation])>

Returns the stack map information for all functions defined in this module.

The iterator returned iterates over the span of the compiled function in memory with the stack maps associated with those bytes.

Source

pub fn func_by_text_offset( &self, text_offset: usize, ) -> Option<(DefinedFuncIndex, u32)>

Lookups a defined function by a program counter value.

Returns the defined function index and the relative address of text_offset within the function itself.

Source

pub fn func_loc(&self, index: DefinedFuncIndex) -> &FunctionLoc

Gets the function location information for a given function index.

Source

pub fn wasm_func_info(&self, index: DefinedFuncIndex) -> &WasmFunctionInfo

Gets the function information for a given function index.

Source

pub fn symbolize_context(&self) -> Result<Option<SymbolizeContext<'_>>>

Available on crate feature addr2line only.

Creates a new symbolication context which can be used to further symbolicate stack traces.

Basically this makes a thing which parses debuginfo and can tell you what filename and line number a wasm pc comes from.

Source

pub fn has_unparsed_debuginfo(&self) -> bool

Returns whether the original wasm module had unparsed debug information based on the tunables configuration.

Source

pub fn has_address_map(&self) -> bool

Indicates whether this module came with n address map such that lookups via wasmtime_environ::lookup_file_pos will succeed.

If this function returns false then lookup_file_pos will always return None.

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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