jnz/q3vm
FreeQ3VM - Single file (vm.c) bytecode virtual machine/interpreter for C-language input
About jnz/q3vm
Q3VM is a lightweight, embeddable bytecode virtual machine and interpreter implemented in a single C file (vm.c) with no external dependencies. Based on the Quake III Arena virtual machine, it executes compiled bytecode files (.qvm) generated from C source code using the included LCC C compiler. The interpreter features static typing, static memory allocation (no garbage collector), and computed gotos for improved performance when compiled with GCC. It is battle-tested through 20 years of use in Quake III Arena and has undergone static code analysis, test coverage, and Valgrind testing. Q3VM is ideal for sandboxing untrusted code, embedding in game engines, IoT applications, and educational projects.
Key Features
Pros & Cons
- Extremely small and lightweight – one .c file to include
- No need to learn a new scripting language; uses C as input
- Static memory allocation avoids unpredictable garbage collection pauses
- Ability to revert to native C code if VM performance is insufficient (Plan B)
- Leverages the full C toolchain (debuggers, profilers, static analyzers)
- Faster than the similar Triseism Q3VM interpreter
- Battle-tested reliability from decades of Quake III Arena usage
- Only supports C as input language; not intended for dynamic or interpreted languages
- Requires implementing four callback functions for embedding, which may involve a learning curve
- Computed gotos are GCC-specific; performance may be lower on other compilers
- No built-in support for modern language features (e.g., exceptions, reflection)