The first release of wasm3 is available, a very fast interpreter of WebAssembly intermediate code. It is mainly designed to run WebAssembly applications on microcontrollers and platforms for which there is no JIT implementation for WebAssembly, not enough memory for JIT to work, or the creation of executable memory pages necessary for JIT implementation. The project code is written in C and distributed under the MIT license.
Wasm3 passes tests for compatibility with the WebAssembly 1.0 specification and can be used to run many WASI applications, providing performance only 4-5 times lower than JIT engines (liftoff, cranelift) and 11.5 times lower than native code execution. When compared with other WebAssembly interpreters (wac, life, wasm-micro-runtime), wasm3 was 15.8 times faster.
Wasm3 requires 64Kb of memory for code and 10Kb of RAM, which allows you to use the project to run applications compiled in WebAssembly on microcontrollers such as Arduino MKR *, Arduino Due, Particle Photon, ESP8266, ESP32, Air602 (W600), nRF52, nRF51 Blue Pill (STM32F103C8T6), MXChip AZ3166 (EMW3166), Maix (K210), HiFive1 (E310), Fomu (ICE40UP5K) and ATmega1284, as well as on boards and computers based on x86, x64, ARM, MIPS, RISC-V and Xtens architectures . Of the operating systems, Linux (including routers based on OpenWRT), Windows, macOS, Android, and iOS are supported. It was also possible to compile wasm3 into WebAssembly intermediate code to execute the interpreter in a browser or for self-hosting.
High performance is achieved through the use of the Massey Meta Machine (M3) technique in the interpreter, in which, to reduce the overhead of decoding the bytecode, the bytecode is proactively translated into more efficient operations generating pseudo-machine code, and the execution model of the stacked virtual machine is converted to a more efficient register an approach. Operations in M3 are C functions, the arguments of which are the registers of the virtual machine, which can be reflected on the registers of the CPU. Frequently encountered workflows for optimization are converted to summary operations.
Learn more at GitHub.