Crate cranelift_wasm

Crate cranelift_wasm 

Source
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)) where msg the string built by calling format! on the arguments to this macro.

Structs§

DataIndex
Index type of a passive data segment inside the WebAssembly module.
DefinedFuncIndex
Index type of a defined function inside the WebAssembly module.
DefinedGlobalIndex
Index type of a defined global inside the WebAssembly module.
DefinedMemoryIndex
Index type of a defined memory inside the WebAssembly module.
DefinedTableIndex
Index type of a defined table inside the WebAssembly module.
DummyEnvironment
This ModuleEnvironment implementation 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.
DummyFuncEnvironment
The FuncEnvironment implementation for use by the DummyEnvironment.
DummyModuleInfo
The main state belonging to a DummyEnvironment. This is split out from DummyEnvironment to allow it to be borrowed separately from the FuncTranslator field.
ElemIndex
Index type of a passive element segment inside the WebAssembly module.
ExpectedReachability
State for tracking and checking reachability at each operator. Used for unit testing with the DummyEnvironment.
FuncIndex
Index type of a function (imported or defined) inside the WebAssembly module.
FuncTranslationState
Contains information passed along during a function’s translation and that records:
FuncTranslator
WebAssembly to Cranelift IR function translator.
FunctionBuilder
Temporary object used to build a single Cranelift IR Function.
Global
A WebAssembly global.
GlobalIndex
Index type of a global variable (imported or defined) inside the WebAssembly module.
Heap
An opaque reference to a HeapData.
HeapData
A heap implementing a WebAssembly linear memory.
Memory
WebAssembly linear memory.
MemoryIndex
Index type of a linear memory (imported or defined) inside the WebAssembly module.
OwnedMemoryIndex
Index type of a defined memory inside the WebAssembly module.
SignatureIndex
Index type of a signature (imported or defined) inside the WebAssembly module.
Table
WebAssembly table.
TableIndex
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.
TypeIndex
Index type of a type inside the WebAssembly module.
WasmFuncType
WebAssembly function type – equivalent of wasmparser’s FuncType.

Enums§

EntityIndex
An index of an entity.
EntityType
A type of an item in a wasm module where an item is typically something that can be exported.
GlobalInit
Globals are initialized via the const operators or by referring to another import.
GlobalVariable
The value of a WebAssembly global variable.
HeapStyle
Style of heap including style-specific information.
WasmError
A WebAssembly translation error.
WasmType
WebAssembly value type – equivalent of wasmparser’s Type.

Constants§

VERSION
Version number of this crate.

Traits§

FuncEnvironment
Environment affecting the translation of a single WebAssembly function.
ModuleEnvironment
An object satisfying the ModuleEnvironment trait can be passed as argument to the translate_module function. These methods should not be called by the user, they are only for cranelift-wasm internal use.
TargetEnvironment
Environment affecting the translation of a WebAssembly.

Functions§

block_with_params
Create a Block with the given Wasm parameters.
blocktype_params_results
Get the parameter and result types for the given Wasm blocktype.
f32_translation
Turns a wasmparser f32 into a Cranelift one.
f64_translation
Turns a wasmparser f64 into a Cranelift one.
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§

WasmResult
A convenient alias for a Result that uses WasmError as the error type.