Expand description
Performs translation from a wasm module in binary format to the in-memory form
of Cranelift IR. More particularly, it translates the code of all the functions bodies and
interacts with an environment implementing the
ModuleEnvironment
trait to deal with tables, globals and linear memory.
The crate provides a DummyEnvironment struct that will allow to translate the code of the
functions but will fail at execution.
The main function of this module is translate_module.
Re-exports§
pub use wasmparser;
Modules§
- wasmparser
- A simple event-driven library for parsing WebAssembly binary files (or streams).
Macros§
- wasm_
unsupported - Return an
Err(WasmError::Unsupported(msg))wheremsgthe string built by callingformat!on the arguments to this macro.
Structs§
- Data
Index - Index type of a passive data segment inside the WebAssembly module.
- Defined
Func Index - Index type of a defined function inside the WebAssembly module.
- Defined
Global Index - Index type of a defined global inside the WebAssembly module.
- Defined
Memory Index - Index type of a defined memory inside the WebAssembly module.
- Defined
Table Index - Index type of a defined table inside the WebAssembly module.
- Dummy
Environment - This
ModuleEnvironmentimplementation is a “naïve” one, doing essentially nothing and emitting placeholders when forced to. Don’t try to execute code translated for this environment, essentially here for translation debug purposes. - Dummy
Func Environment - The
FuncEnvironmentimplementation for use by theDummyEnvironment. - Dummy
Module Info - The main state belonging to a
DummyEnvironment. This is split out fromDummyEnvironmentto allow it to be borrowed separately from theFuncTranslatorfield. - Elem
Index - Index type of a passive element segment inside the WebAssembly module.
- Expected
Reachability - State for tracking and checking reachability at each operator. Used for unit testing with the
DummyEnvironment. - Func
Index - Index type of a function (imported or defined) inside the WebAssembly module.
- Func
Translation State - Contains information passed along during a function’s translation and that records:
- Func
Translator - WebAssembly to Cranelift IR function translator.
- Function
Builder - Temporary object used to build a single Cranelift IR
Function. - Global
- A WebAssembly global.
- Global
Index - Index type of a global variable (imported or defined) inside the WebAssembly module.
- Heap
- An opaque reference to a
HeapData. - Heap
Data - A heap implementing a WebAssembly linear memory.
- Memory
- WebAssembly linear memory.
- Memory
Index - Index type of a linear memory (imported or defined) inside the WebAssembly module.
- Owned
Memory Index - Index type of a defined memory inside the WebAssembly module.
- Signature
Index - Index type of a signature (imported or defined) inside the WebAssembly module.
- Table
- WebAssembly table.
- Table
Index - Index type of a table (imported or defined) inside the WebAssembly module.
- Tag
- WebAssembly event.
- TagIndex
- Index type of an event inside the WebAssembly module.
- Type
Index - Index type of a type inside the WebAssembly module.
- Wasm
Func Type - WebAssembly function type – equivalent of
wasmparser’s FuncType.
Enums§
- Entity
Index - An index of an entity.
- Entity
Type - A type of an item in a wasm module where an item is typically something that can be exported.
- Global
Init - Globals are initialized via the
constoperators or by referring to another import. - Global
Variable - The value of a WebAssembly global variable.
- Heap
Style - Style of heap including style-specific information.
- Wasm
Error - A WebAssembly translation error.
- Wasm
Type - WebAssembly value type – equivalent of
wasmparser’s Type.
Constants§
- VERSION
- Version number of this crate.
Traits§
- Func
Environment - Environment affecting the translation of a single WebAssembly function.
- Module
Environment - An object satisfying the
ModuleEnvironmenttrait can be passed as argument to thetranslate_modulefunction. These methods should not be called by the user, they are only forcranelift-wasminternal use. - Target
Environment - Environment affecting the translation of a WebAssembly.
Functions§
- block_
with_ params - Create a
Blockwith the given Wasm parameters. - blocktype_
params_ results - Get the parameter and result types for the given Wasm blocktype.
- f32_
translation - Turns a
wasmparserf32into aCraneliftone. - f64_
translation - Turns a
wasmparserf64into aCraneliftone. - get_
vmctx_ value_ label - Special VMContext value label. It is tracked as 0xffff_fffe label.
- translate_
module - Translate a sequence of bytes forming a valid Wasm binary into a list of valid Cranelift IR
Function.
Type Aliases§
- Wasm
Result - A convenient alias for a
Resultthat usesWasmErroras the error type.