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.
Macros§
- wasm_
unsupported - Return an
Err(WasmError::Unsupported(msg))wheremsgthe string built by callingformat!on the arguments to this macro.
Structs§
- 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. - 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.
- Global
- WebAssembly global.
- Global
Index - Index type of a global variable (imported or defined) inside the WebAssembly module.
- Memory
- WebAssembly linear memory.
- Memory
Index - Index type of a linear memory (imported or defined) inside the WebAssembly module.
- Module
Translation State - Contains information decoded from the Wasm module that must be referenced during each Wasm function’s translation.
- Passive
Data Index - Index type of a passive data segment inside the WebAssembly module.
- Passive
Elem Index - Index type of a passive element segment 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.
Enums§
- Global
Init - Globals are initialized via the
constoperators or by referring to another import. - Global
Variable - The value of a WebAssembly global variable.
- Return
Mode - How to return from functions.
- Table
Element Type - WebAssembly table element. Can be a function or a scalar type.
- Wasm
Error - A WebAssembly translation error.
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§
- declare_
locals - Declare
countlocal variables of the same type, starting fromnext_local. - 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. - translate_
operator - Translates wasm operators into Cranelift IR instructions. Returns
trueif it inserted a return.
Type Aliases§
- Wasm
Result - A convenient alias for a
Resultthat usesWasmErroras the error type.