- Tiny: Keeps the runtime small and focused while still being practical for real workloads.
- Portable: Runs anywhere Rust runs, supports
no_std, and keeps external dependencies to a minimum. - Secure: Written entirely safe Rust (
#[deny(unsafe_code)]) and designed to prevent untrusted code from crashing the runtime
tinywasm passes 100% of WebAssembly MVP and WebAssembly 2.0 tests from the WebAssembly core testsuite and is able to run most WebAssembly programs. Additionally, support for WebAssembly 3.0 is on the way. See the Supported Proposals section for more information.
See the examples directory and documentation for more information on how to use tinywasm.
For testing purposes, you can also use the tinywasm-cli tool:
$ cargo install tinywasm-cli
$ tinywasm-cli --helpstd
Enables the use ofstdandstd::iofor parsing from files and streams. This is enabled by default.log
Enables logging using thelogcrate. This is enabled by default.parser
Enables thetinywasm-parsercrate. This is enabled by default.archive
Enables pre-parsing of archives. This is enabled by default.
With all these features disabled, tinywasm only depends on core, alloc, and libm and can be used in no_std environments. Since libm is not as performant as the compiler's math intrinsics, it is recommended to use the std feature if possible (at least for now), especially on wasm32 targets.
Untrusted WebAssembly code should not be able to crash the runtime or access memory outside of its sandbox. Unvalidated Wasm and untrusted, precompiled twasm bytecode is safe to run as well, but can lead to panics if the bytecode is malformed. In general, it is recommended to validate Wasm bytecode before running it, and to only run trusted twasm bytecode.
| Proposal | Status | tinywasm Version |
|---|---|---|
| Multi-value | 🟢 | 0.2.0 |
| Mutable Globals | 🟢 | 0.2.0 |
| Non-trapping float-to-int Conversion | 🟢 | 0.2.0 |
| Sign-extension operators | 🟢 | 0.2.0 |
| Bulk Memory Operations | 🟢 | 0.4.0 |
| Reference Types | 🟢 | 0.7.0 |
| Multi-memory | 🟢 | 0.8.0 |
| Annotations | 🟢 | next |
| Custom Page Sizes | 🟢 | next |
| Extended Const | 🟢 | next |
| Fixed-Width SIMD | 🟢 | next |
| Memory64 | 🟢 | next |
| Tail Call | 🟢 | next |
| Relaxed SIMD | 🟢 | next |
| Wide Arithmetic | 🟢 | next |
| Custom Descriptors | 🌑 | - |
| Exception Handling | 🌑 | - |
| Function References | 🌑 | - |
| Garbage Collection | 🌑 | - |
| Threads | 🌑 | - |
Legend
🌑 -- not available
🚧 -- in development/partially supported
🟢 -- fully supported
I encourage you to check these projects out if you're looking for more mature and feature-complete WebAssembly runtimes:
- wasmi - efficient and versatile WebAssembly interpreter for embedded systems
- wasm3 - a fast WebAssembly interpreter written in C
- wazero - a zero-dependency WebAssembly interpreter written in Go
- wain - a zero-dependency WebAssembly interpreter written in Rust
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in tinywasm by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.