Overview of LightVM
SmolStr and Ahash for metadata management).website·Indexed 30 days ago
https://lightvm.vercel.appA high-performance, deterministic virtual machine designed to bridge the gap between high-level logic and low-level execution. LightVM features a stack-based architecture, a dedicated validation and security layer called Krates, a symbol resolver named Torja, and a built-in optimizer called Gazle. It supports Node.js and Rust projects, providing a comprehensive instruction set for mathematics, vector operations, and OOP, alongside a TypeScript-compatible API for VM control and bytecode management.
SmolStr and Ahash for metadata management).pass_weights) to prioritize the most effective optimizations.LightVM categorizes features into three support levels to indicate stability and reliability:
wasm32 for browsers is currently in an experimental stage.| OS / Runtime | Architecture | Toolchain | Rust | Node.js | Web |
|---|---|---|---|---|---|
| Windows | x64, ia32 | MSVC | ✓ | ✓ | - |
| Linux | x64, ia32, arm64 | GNU (glibc) | ✓ | ✓ | - |
| Linux (musl) | x64, ia32, arm64 | musl | ✓ | ✓ | - |
| macOS (Darwin) | x64 | Apple Clang | ✓ | ✓ | - |
| Android | arm64, arm | NDK | ✓ | ✓ | - |
| FreeBSD | x64 | Clang | ✓ | ✓ | - |
| Web / Browser | wasm32 | wasm-pack / wasm-bindgen | - | - | ✓ |
Torja is the core Symbol Resolver of LightVM. It acts as a bridge between high-level bytecode (using human-readable names) and the execution engine (using numerical indices). Before execution, Torja performs a pass to resolve all symbolic references into fixed-position indices to minimize runtime lookups and reduce CPU overhead.
Key operations include:
get_or_insert_idx logic to assign a new index via an incrementing counter (next_idx) when a new variable is encountered.get becomes get_idxset becomes set_idxinc becomes inc_idxdec becomes dec_idxFunc instructions into the symbol table to support the VM's stack-based architecture.LightVM operates on three fundamental pillars:
LightVM uses a stack-based architecture for data storage and retrieval. The following opcodes are used to manipulate the stack:
push [value]: Inserts a specific value onto the stack.dup: Duplicates the top value currently on the stack.swap: Swaps the top value of the stack with the value immediately below it.on method in LightVM is used to register callbacks that trigger when specific VM lifecycle events occur. This is used for logging, monitoring state changes, or executing external logic in real-time. No specific capability is required to use this method. Supported events include Tick, Halt, Panic, Start, and Finish.The paniclog method returns persisted panic records as a structured array, containing bounded diagnostic context and VM state.
Requirements & Constraints:
Debug capability..paniclog() method is unavailable in WebAssembly builds.