Skip to main content

WasmModule

Struct WasmModule 

Source
pub struct WasmModule<'a> {
Show 20 fields pub functions: Vec<FunctionBody<'a>>, pub func_types: Vec<FuncType>, pub function_type_indices: Vec<u32>, pub globals: Vec<GlobalType>, pub global_init_values: Vec<i32>, pub data_segments: Vec<DataSegment>, pub memory_limits: MemoryLimits, pub num_imported_funcs: u32, pub imported_func_type_indices: Vec<u32>, pub imported_func_names: Vec<String>, pub main_func_local_idx: usize, pub has_secondary_entry: bool, pub secondary_entry_local_idx: Option<usize>, pub start_func_local_idx: Option<usize>, pub function_signatures: Vec<(usize, bool)>, pub type_signatures: Vec<(usize, usize)>, pub function_table: Vec<u32>, pub exported_wasm_func_indices: Vec<u32>, pub wasm_memory_base: i32, pub max_memory_pages: u32,
}
Expand description

Parsed and pre-processed WASM module, usable by both legacy and LLVM pipelines.

Fields§

§functions: Vec<FunctionBody<'a>>

Function bodies from the code section.

§func_types: Vec<FuncType>

All function types declared in the type section.

§function_type_indices: Vec<u32>

Type index for each local function (parallels functions).

§globals: Vec<GlobalType>

Global variable types.

§global_init_values: Vec<i32>

Initial values of global variables.

§data_segments: Vec<DataSegment>

Active data segments from the data section.

§memory_limits: MemoryLimits

Memory limits parsed from the memory section.

§num_imported_funcs: u32

Number of imported functions (precede local functions in global index space).

§imported_func_type_indices: Vec<u32>

Type indices for imported functions.

§imported_func_names: Vec<String>

Names of imported functions.

§main_func_local_idx: usize

Local function index of the main entry point.

§has_secondary_entry: bool

Whether the WASM module exports a “main2” secondary entry point.

§secondary_entry_local_idx: Option<usize>

Local function index of the secondary entry point (None if import or absent).

§start_func_local_idx: Option<usize>

Local function index of the start function (None if import or absent).

§function_signatures: Vec<(usize, bool)>

(num_params, has_return) for each function (imports first, then locals).

§type_signatures: Vec<(usize, usize)>

(num_params, num_results) for each type.

§function_table: Vec<u32>

Function table for indirect calls (u32::MAX = invalid entry).

§exported_wasm_func_indices: Vec<u32>

WASM global indices of all exported functions.

§wasm_memory_base: i32

Base address of WASM linear memory in PVM address space.

§max_memory_pages: u32

Maximum WASM memory pages available for memory.grow.

Implementations§

Source§

impl<'a> WasmModule<'a>

Source

pub fn parse(wasm: &'a [u8]) -> Result<Self>

Parse and validate a WASM binary, producing a WasmModule with all derived data.

Auto Trait Implementations§

§

impl<'a> Freeze for WasmModule<'a>

§

impl<'a> RefUnwindSafe for WasmModule<'a>

§

impl<'a> Send for WasmModule<'a>

§

impl<'a> Sync for WasmModule<'a>

§

impl<'a> Unpin for WasmModule<'a>

§

impl<'a> UnsafeUnpin for WasmModule<'a>

§

impl<'a> UnwindSafe for WasmModule<'a>

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> Instrument for T

Source§

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

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

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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