Any Moment Is the Right One: Arbitrary-Point Suspension in Virtual Machines
Abstract
We present BASIC26 --- a minimalist, portable and safe stack-based virtual machine for long-running untrusted code with arbitrary-point suspension and full resource control. Existing solutions (CPython, Wasmtime, Luau, BEAM) do not simultaneously provide predictable suspension on arbitrary metrics, a yield mechanism, memory control and an embeddable C API. We justify the architectural decisions (stack-based model, no JIT, dynamic typing, the "Mechanisms, Not Policies" principle), describe the implementation in Zig, and report an empirical evaluation on two platforms --- ARM64 (Apple M3) and x86_64 (Intel Core i5-11600K) --- against CPython 3.14 and Wasmtime 47.0.3. BASIC26 uses 5--12× less memory than CPython and 4× less than Wasmtime; on ARM64 it outperforms both references on CPU-bound workloads, while on x86_64 it is comparable to CPython and slower than Wasmtime (which ran with Cranelift JIT). The suspension overhead is 6--32% at a quantum of 100--1000 opcodes. The codebase (3546 lines of Zig) is smaller than a single component of the Luau VM (19676 lines of C++), which makes it suitable for formal verification and educational use.
// Source
Authors: Igor Spichkin