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§

Modules§

  • A simple event-driven library for parsing WebAssembly binary files (or streams).

Macros§

  • Return an Err(WasmError::Unsupported(msg)) where msg the string built by calling format! on the arguments to this macro.

Structs§

  • Index type of a passive data segment inside the WebAssembly module.
  • Index type of a defined function inside the WebAssembly module.
  • Index type of a defined global inside the WebAssembly module.
  • Index type of a defined memory inside the WebAssembly module.
  • Index type of a defined table inside the WebAssembly module.
  • 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.
  • The FuncEnvironment implementation for use by the DummyEnvironment.
  • The main state belonging to a DummyEnvironment. This is split out from DummyEnvironment to allow it to be borrowed separately from the FuncTranslator field.
  • Index type of a passive element segment inside the WebAssembly module.
  • State for tracking and checking reachability at each operator. Used for unit testing with the DummyEnvironment.
  • Index type of a function (imported or defined) inside the WebAssembly module.
  • Contains information passed along during a function’s translation and that records:
  • WebAssembly to Cranelift IR function translator.
  • Temporary object used to build a single Cranelift IR Function.
  • A WebAssembly global.
  • Index type of a global variable (imported or defined) inside the WebAssembly module.
  • An opaque reference to a HeapData.
  • A heap implementing a WebAssembly linear memory.
  • WebAssembly linear memory.
  • Index type of a linear memory (imported or defined) inside the WebAssembly module.
  • Index type of a deduplicated type (imported or defined) inside a WebAssembly module.
  • Index type of a defined memory inside the WebAssembly module.
  • Index into the global list of modules found within an entire component.
  • WebAssembly table.
  • Index type of a table (imported or defined) inside the WebAssembly module.
  • WebAssembly event.
  • Index type of an event inside the WebAssembly module.
  • Index type of a type (imported or defined) inside the WebAssembly module.
  • WebAssembly function type – equivalent of wasmparser’s FuncType.
  • WebAssembly reference type – equivalent of wasmparser’s RefType

Enums§

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

Constants§

  • Version number of this crate.

Traits§

  • Environment affecting the translation of a single WebAssembly function.
  • 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.
  • Environment affecting the translation of a WebAssembly.
  • Helpers used to convert a wasmparser type to a type in this crate.

Functions§

Type Aliases§

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