Sigil 0.11.0
Register VM and self-hosting CPS compiler. This release adds a register-based virtual machine as an alternative backend for the CPS compiler introduced in 0.10.0. The new toolchain is opt-in via SIGIL_NEXT=1 and is 7-57% faster than the direct compiler across all benchmark categories. It is fully self-hosting — the CPS compiler running on the register VM can compile itself.
Register VM
Enable with SIGIL_NEXT=1. This activates both the CPS compiler and the register VM together. All stdlib modules compile, all ecosystem tests pass (zero regvm-specific failures across ~2,700 tests in 23 repos).
The register VM uses 32-bit fixed-width instructions with 3-address register operands. Key design features:
- Liveness-aware register allocation via CFG-based backward dataflow analysis
- Register coalescing eliminates redundant moves between registers
- Self-tail-call loop optimization converts recursive tail calls to JMP instructions
- Call window optimization overlaps caller/callee register frames
- Full continuation support — call/cc, delimited continuations, abort-to-prompt
- Exception handling — raise, guard, with-exception-handler
New source files:
regvm.c-- register VM interpreter (90+ opcodes)regvm.h-- register VM instruction encoding and opcodescps-emit-reg.c-- CPS IR to register bytecode emission
Performance
Benchmarks across 60+ tests (ratio = register VM time / direct compiler time, lower is faster):
| Category | Ratio | Improvement |
|---|---|---|
| Compute (fib, tak, ack) | 0.79-0.93x | 7-21% faster |
| Closures | 0.56-1.03x | Up to 44% faster |
| Tail calls | 0.76-0.96x | Up to 24% faster |
| String processing | 0.43-0.90x | Up to 57% faster |
| Allocation/trees | 0.80-1.01x | Up to 20% faster |
| Higher-order functions | 0.72-1.03x | Up to 28% faster |
| JSON encode/decode | ~1.0x | Parity (stdlib-bound) |
The register VM went from 3.3x slower (initial prototype) to consistently faster than the direct compiler through register allocation, coalescing, and call window optimizations.
Self-Hosting Bootstrap
The CPS compiler + register VM can compile itself. A two-stage bootstrap (stack VM binary compiles regvm binary, regvm binary recompiles itself) produces byte-identical output for 43/44 stdlib modules. This proves the new toolchain is correct enough to replace the direct compiler.
CPS Compiler Improvements
Fixes and enhancements to the CPS compiler from 0.10.0:
- Forward-referenced macro expansion during CPS conversion
- CFG-based liveness analysis for register and slot allocation
- Rest parameter slot allocation fix (was dropping the rest param)
- GC rooting for import set datums during module loading
- Module context save/restore across nested module loads
- call/cc stack reservation for lambda locals
- CPS emitter abort-to-prompt continuation routing for delimited continuations
- 19 primitive operation fallbacks added to register emitter
- Syntax transparency for register VM type predicates (car, cdr, null?, pair?, symbol?)
- Bignum arithmetic operations (mod, rem, neg, abs, number->string)
Other Changes
SIGIL_NEXT=1flag activates CPS + register VM togetherSIGIL_MODULE_MAX_MACROSincreased from 64 to 256- Benchmark suite added at
benchmarks/for release-to-release comparison