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 main function of this module is translate_module
.
Re-exports§
pub use wasmparser;
Modules§
- prelude
- Rust module prelude for Wasmtime crates.
- wasmparser
- A simple event-driven library for parsing WebAssembly binary files (or streams).
Macros§
- __
format - Creates a
String
using interpolation of runtime expressions. - wasm_
unsupported - Return an
Err(WasmError::Unsupported(msg))
wheremsg
the string built by callingformat!
on the arguments to this macro.
Structs§
- Const
Expr - A constant expression.
- 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.
- Elem
Index - Index type of a passive element segment inside the WebAssembly module.
- Engine
Interned RecGroup Index - Index type of a canonicalized recursive type group inside the whole engine (as opposed to canonicalized within just a single Wasm module).
- 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.
- Module
Interned RecGroup Index - Index type of a canonicalized recursive type group inside a WebAssembly module (as opposed to canonicalized within the whole engine).
- Module
Interned Type Index - A canonicalized type index for a type within a single WebAssembly module.
- Owned
Memory Index - Index type of a defined memory inside the WebAssembly module.
- RecGroup
Relative Type Index - A canonicalized type index referencing a type within a single recursion group from another type within that same recursion group.
- Size
Overflow - Static
Module Index - Index into the global list of modules found within an entire component.
- Table
- WebAssembly table.
- Table
Data - An implementation of a 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 (imported or defined) inside the WebAssembly module.
- VMShared
Type Index - A canonicalized type index into an engine’s shared type registry.
- Wasm
Array Type - A concrete array type.
- Wasm
Field Type - The type of a struct field or array element.
- Wasm
Func Type - WebAssembly function type – equivalent of
wasmparser
’s FuncType. - Wasm
RecGroup - A recursive type group.
- Wasm
RefType - WebAssembly reference type – equivalent of
wasmparser
’s RefType - Wasm
Struct Type - A concrete struct type.
- Wasm
SubType - A concrete, user-defined (or host-defined) Wasm type.
Enums§
- ConstOp
- The subset of Wasm opcodes that are constant.
- Engine
OrModule Type Index - An interned type index, either at the module or engine level.
- 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
Variable - The value of a WebAssembly global variable.
- Heap
Style - Style of heap including style-specific information.
- Table
Size - Size of a WebAssembly table, in elements.
- Wasm
Composite Type - A function, array, or struct type.
- Wasm
Error - A WebAssembly translation error.
- Wasm
Heap TopType - A top heap type.
- Wasm
Heap Type - WebAssembly heap type – equivalent of
wasmparser
’s HeapType - Wasm
Storage Type - Represents storage types introduced in the GC spec for array and struct fields.
- Wasm
ValType - WebAssembly value type – equivalent of
wasmparser::ValType
.
Constants§
- VERSION
- Version number of this crate.
- WASM32_
MAX_ SIZE - Maximum size, in bytes, of 32-bit memories (4G)
Traits§
- Func
Environment - Environment affecting the translation of a single WebAssembly function.
- Module
Environment - An object satisfying the
ModuleEnvironment
trait can be passed as argument to thetranslate_module
function. These methods should not be called by the user, they are only forcranelift-wasm
internal use. - Target
Environment - Environment affecting the translation of a WebAssembly.
- Type
Convert - Helpers used to convert a
wasmparser
type to a type in this crate. - Type
Trace - A trait for things that can trace all type-to-type edges, aka all type indices within this thing.
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 aCranelift
one. - f64_
translation - Turns a
wasmparser
f64
into aCranelift
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§
- Wasm
Result - A convenient alias for a
Result
that usesWasmError
as the error type.