Wasmer Runtime Features
Wasmer is powered by WebAssembly .
The native CLI and Python SDK use Wasmer’s native compiler backends. The JavaScript SDK targets the host JavaScript engine: Node.js and browsers compile and execute WebAssembly while Wasmer supplies the package, sandbox, filesystem, process, and WASIX layers. See the Python SDK guide for native embedding from Python.
Wasmer runs WebAssembly through a backend, and ships several depending on your needs. They fall into two groups by how they execute your code:
-
Compiler backends: Wasmer compiles your WebAssembly to native machine code itself, then runs it directly on the CPU:
- Singlepass: very fast compilation, ideal for blockchain smart contracts
- Cranelift: moderate compilation speed, good runtime performance
- LLVM: slow compilation, excellent runtime performance
-
Engine backends: Wasmer doesn’t compile anything itself; it hands your WebAssembly to an existing engine to run. This is what lets Wasmer work where generating native machine code isn’t allowed, such as on iOS or inside a web page:
- V8: delegates to Google’s V8 engine. ideal for iOS, Android, and development
- Browser: delegates to the browser’s own WebAssembly engine, so Wasmer can run client-side inside a web page
Why run Wasmer in a browser when browsers already run WebAssembly? Because the
browser’s built-in WebAssembly API only runs bare modules. It provides no
files, stdin/stdout, arguments, or environment. The Browser backend lets Wasmer
supply that missing operating-system layer (WASIX) in the page,
so a full program (for example, a CLI tool, an interpreter like Python) can run entirely
client-side.
Each of these backends supports different features and has varying support for operating systems and chipsets.
WebAssembly Features
- Bulk-memory operations: e.g. instructions with behavior similar to C’s
memmoveandmemsetin WebAssembly; - Multi-value return: return multiple values from functions making data transfer between host and guest simpler;
- Import & export of mutable globals: adds ability to import and export mutable globals;
- Non-trapping float-to-int conversions: adds a convention for saturating operations, to avoid introducing trapping;
- Sign-extension operations: adds five new integer instructions for sign-extending 8-bit, 16-bit, and 32-bit values;
- Reference types: easier and more efficient interop with host environment;
- SIMD: Single Instruction, Multiple data: do heavy number crunching more quickly and/or with lower power usage.
- Threads: adds a new shared linear memory type and some new operations for atomic memory access;
Wasmer features
- Caching: compiled WebAssembly modules can be reused so subsequent runs of a Wasm file will have very little start up time;
- Metering: computation time and other resources can be monitored and limits set to control how the Wasm code runs. This is also known as “gas metering”;
- Profiling: generate profiling data for WebAssembly code to analyze performance using tools like Linux perf;
Support of features by backend
WebAssembly features:
- ✅ Supported
- 🔄 In the works
- ❌ Not yet supported (please ping us if you need this feature!)
| Singlepass | Cranelift | LLVM | |
|---|---|---|---|
| Bulk memory operations | ✅ | ✅ | ✅ |
| Multi-value return | ✅1 | ✅ | ✅ |
| Import & export of mutable globals | ✅ | ✅ | ✅ |
| Non-trapping float-to-int conversions | ✅ | ✅ | ✅ |
| Sign-extension operations | ✅ | ✅ | ✅ |
| Wide Arithmetic | ❌ | ✅ | ✅ |
| Reference types | ✅ | ✅ | ✅ |
| SIMD | ❌ | ✅ | ✅ |
| Relaxed SIMD | ❌ | ✅ | ✅ |
| Threads | ✅ | ✅ | ✅ |
| Exceptions | 🔄 | ✅ | ✅ |
| Async Functions | ✅ | ✅ | ✅ |
| Extended Constant Expressions | ✅ | ✅ | ✅ |
| Tail Call | ❌ | ❌ | ✅ |
Wasmer features:
| Features | Singlepass | Cranelift | LLVM |
|---|---|---|---|
| Caching | ✅ | ✅ | ✅ |
| Metering | ✅ | ✅ | ✅ |
| Profiling | ✅ | ✅ | ✅ |
Backend support by Operating System
| Linux | macOS | Windows | iOS | Android | Browser | |
|---|---|---|---|---|---|---|
| Cranelift | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ |
| LLVM | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ |
| Singlepass | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ |
| V8 | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| Browser | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Backend support by Instruction Set Architecture (ISA)
| x86_64 | arm64 | riscv64gc | loongarch64 | |
|---|---|---|---|---|
| Cranelift | ✅ | ✅ | ✅ | ❌ |
| LLVM | ✅ | ✅ | ✅ | ✅ |
| Singlepass | ✅ | ✅ | ✅ | ❌ |
| V8 | ✅ | ✅ | ✅ | ✅ |
| Browser | ✅ | ✅ | ✅ | ✅ |