Expand description
§wasm-interpreter
Website • Features • Resources
A minimal in-place interpreter for WebAssembly bytecode (almost without) dependencies while being no_std.
§Features
- In-place interpretation: No intermediate representation, directly interprets WebAssembly bytecode. This allows for fast start-up times.
no_stdsupport: The interpreter requires only Rust’scoreandalloclibraries allowing its use in various environments, such as bare-metal systems.- Minimal dependencies: The interpreter requires only two dependencies:
log,libm. - Compliance with specification: The interpreter passes all tests from the official WebAssembly testsuite, except for the unfinished proposal tests. See
GlobalConfigintests/specification/mod.rsfor the default spec-test filter regex. - Returning host functions: The host system can provide functions for Wasm code to call. Contrary to other Wasm runtimes, host functions are not owned by the interpreter. Instead control flow is returned back to the user, when Wasm code calls a host function.
- Fuel & resumable execution: A fuel mechanism is used to halt execution once fuel runs out. Then fuel can be refilled and execution resumed.
For information on other features, visit our requirements page.
§Planned
- C bindings: The interpreter can be used from C code.
- Migratability: Wasm instances can be transferred between systems during their execution.
- Threading: There are multiple threading proposals, but we have not yet chosen a specific one. Some options are shared-everything-threads, threads, wasi-threads.
§Not planned
Multi-memory proposal, GC proposal
§Resources
A fast in-place interpreterby Ben L. Titzer: https://arxiv.org/abs/2205.01183- WebAssembly spec: https://webassembly.github.io/spec/core/index.html
- WebAssembly Opcode Table: https://pengowray.github.io/wasm-ops/
- Compiler/Interpreter Know-How Gist Compilation: https://gist.github.com/o11c/6b08643335388bbab0228db763f99219
- Mozilla Developer Network WebAssembly Homepage: https://developer.mozilla.org/en-US/docs/WebAssembly
§License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
§Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
§Copyright
Copyright © 2024-2026 Deutsches Zentrum für Luft- und Raumfahrt e.V. (DLR) Copyright © 2024-2025 OxidOS Automotive SRL
Modules§
- core 🔒
- execution 🔒
- instructions
- All instructions, in alphanumerical order by their numeric (hex-)value
- rw_
spinlock - Naive implementation of spin based locking mechanisms
- validation 🔒
Macros§
Structs§
- Custom
Section - Data
Addr - An address to a data instance that lives in a specific
Store. - Elem
Addr - An address to an element instance that lives in a specific
Store. - Extern
Addr - The WebAssembly specification defines an externaddr as an address to an
“external” type, i.e. is a type which is managed by the embedder. For this
interpreter the task of managing external objects and relating them to
addresses is handed off to the user, which means that an
ExternAddrcan simply be seen as an integer that is opaque to Wasm code without any meaning assigned to it. - F32
- F64
- Func
Addr - An address to a function instance that lives in a specific
Store. - Func
Type - A function type
- Global
Addr - An address to a global instance that lives in a specific
Store. - Global
Type - A global type
- Host
Call - A
HostCallobject contains information required for executing a specific host function. - Host
Resumable - A
HostResumableis used to resume execution after executing itsHostCall. - Instantiation
Outcome - Represents a successful, possibly fueled instantiation of a module.
- Limits
- A limits object
- MemAddr
- An address to a memory instance that lives in a specific
Store. - MemType
- A memory type
- Module
- Information collected from validating a module.
- Module
Addr - An address to a module instance that lives in a specific
Store. - Result
Type - A result type
- Store
- The store represents all global state that can be manipulated by WebAssembly programs. It consists of the runtime representation of all instances of functions, tables, memories, and globals, element segments, and data segments that have been allocated during the life time of the abstract machine. https://webassembly.github.io/spec/core/exec/runtime.html#store
- Table
Addr - An address to a table instance that lives in a specific
Store. - Table
Type - A table type
- Value
Type Mismatch Error - An error used in all
TryFrom<Value>implementations for Rust types (i32,F32,Ref, …) - Wasm
Resumable - A
WasmResumableis an object used to resume execution of Wasm code.
Enums§
- Decoding
Error - Error
- An opt-in error type useful for merging all error types of this crate into a single type.
- Extern
Type - An external type
- Extern
Val - https://webassembly.github.io/spec/core/exec/runtime.html#external-values
- NumType
- A number type
- Ref
- RefType
- A reference type
- Resumable
- RunState
- Represents the state of a possibly interrupted resumable.
- Runtime
Error - Trap
Error - ValType
- A value type
- Validation
Error - Value
- A value at runtime. This is essentially a duplicate of ValType just with additional values.
Traits§
- Config
- Trait that allows user specified configuration for various items during interpretation. Additionally, the types implementing this trait can act as custom user data within an interpreter instance, passed along to each method of this trait and host functions whenever they are invoked.