Selene, a lightweight WebAssembly JIT runtime written in Zig.
Explore the docs »
Report Bug
·
Request Feature
⚠️ Selene is early and incomplete. Currently supports a subset of Wasm - enough to run arithmetic, control flow, and function calls.
Table of Contents
Selene is a lightweight WebAssembly JIT runtime written in Zig. It parses .wasm binaries, translates them into zjit's SSA IR, and compiles them to native machine code at runtime. Built entirely from scratch, no LLVM, no Cranelift, no depedencies.
$ selene inspect add.wasm
functions (1):
add : (i32, i32) -> i32
$ selene run add.wasm --fn add -- 10 20
30This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
selene run <file.wasm> # run default export
selene run <file.wasm> --fn <fn_name> # call a specific exported function
selene run <file.wasm> --fn <fn_name> -- 1 2 3 # pass arguments
selene inspect <file.wasm> # dump sections, exports, imports
selene inspect <file.wasm> --functions # list all functions and signatures
selene inspect <file.wasm> --exports # list exports
--verbose # Log IR and show compilation steps
--interpret # A fallback interpreter mode, no JIT
--dump-ir # Log zjit IR before code generation
--dump-asm # Log native ASM output
- Zig 0.14.0 or later
- A
.wasmbinary
git clone https://github.com/acctress/selene.git
cd selene
zig build./zig-out/bin/selene run file.wasm- Wasm binary parser
- Magic number + version validation
- Section loop (type, func, code)
- LEB128 decoding
- Wasm validator
- Wasm to zjit IR translator
- Arithmetic opcodes (i32.add, i32.sub)
- Control flow (block, loop, if, br, br_if)
- Function calls
- zjit JIT backend integration
- Native code execution
- Host + sandbox
- Linear memory
- Imports and exports
- WASI support
- CLI
-
runsubcommand -
inspectsubcommand -
--dump-irflag -
--dump-asmflag -
--interpretfallback
-
- Optimisation passes
- Pass manager
- Constant folding
- DCE
- Copy propagation
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Distributed under the MIT license. See LICENSE.txt for more information.
Discord - acctress
Email - 0x2014@proton.me
Project Link: https://github.com/acctress/selene
