Sigil 0.5.0
This release is all about stability and correctness. A comprehensive audit of the garbage collector uncovered and fixed a critical write barrier gap, and GC stress testing now runs across the entire compiler pipeline. The HAMT dict implementation is complete, arbitrary-precision integers (bignums) are fully integrated, and every open issue has been resolved. Performance improves with inline caching and superinstructions, and the multimedia packages have been reorganized for flexibility.
GC Correctness
The most impactful change in this release: the tri-color write barrier was implemented but never called. Every mutation site that writes a heap pointer into an existing object could violate the tri-color invariant during incremental marking. This was the root cause of several hard-to-reproduce crashes.
- Write barriers: Added
sigil__gc_write_barrier()calls to all 13 heap mutation sites across vm.c and natives.c - Compiler rooting: Removed the
SIGIL_GC_DISABLE_DURING_COMPILATIONworkaround entirely. Fixed 46+ unrooted allocation sites in the compiler through systematic audit - GC stress testing:
SIGIL_GC_STRESS=1forces GC on every allocation, maximizing the window for bugs. All tests pass under stress
Performance
- Inline caching: Module binding lookups now use per-code cache arrays. On benchmarks, 3.3M hash lookups reduced to ~38K cold-start misses, with 100% steady-state cache hit rate
- Superinstructions: Peephole optimizer fuses 8 common opcode patterns (e.g., PUSH_LOCAL+PUSH_LOCAL, PUSH_CONST+ADD). Compiler-level fusion merges source location tracking with call opcodes
Arbitrary-Precision Integers
Integers larger than 2^47 now automatically promote to bignums instead of raising an error:
- Full arithmetic operations (add, subtract, multiply, divide, modulo, GCD)
- Comparison and bitwise operations
- Transparent promotion and demotion (bignum results that fit in a fixnum automatically demote)
- Serialization support in bytecode files
Dict Completeness
The HAMT (Hash Array Mapped Trie) implementation is now feature-complete:
- Printing: HAMT dicts display all entries with
displayandwrite - Equality:
equal?walks HAMT nodes for structural comparison - Collision handling: Fixed silent key dropping when hash collisions occur at the same node
- Removal: Proper structural
dict-removewith sharing, branch collapse, and HAMT-to-array demotion when count drops below 8
Error Handling
- Three
exit(1)calls in the module system replaced withsigil__vm_error()so the Scheme-level exception system handles them gracefully OP_ABORT_TO_PROMPTnow extracts real error messages from exception objects- Macro expansion errors propagate properly to the compiler
matchraises an error instead of printing a warning when no clauses match
Stack Traces
Procedures now track where they were defined. Stack traces show definition locations, making it easier to identify which function failed:
Stack trace (most recent call first):
0: my-helper
at utils.sgl:42:5Multimedia Packages
sigil-studio has been split into three independent packages for more flexible dependency management:
| Package | Description |
|---|---|
sigil-app | Windowing, input, application lifecycle (sokol_app) |
sigil-graphics | 2D rendering, image loading, font rendering (sokol_gfx, stb) |
sigil-audio | Sound effects and music streaming (sokol_audio, stb_vorbis) |
sigil-studio remains as a meta-package that pulls in all three. New: playlist support with wait-music-end and play-playlist.
Build System
- Test harness generation for packages with native C dependencies
c-flagsfield on library definitions--profileflag for opcode-level performance analysis- Build safety: warns when replacing the running binary, errors on 0-byte output or missing target package
Test Coverage
Added test suites for 15+ packages that previously had none, including sigil-crypto, sigil-tls, sigil-web (routing, middleware, cookies, SSE, security), sigil-socket, sigil-process, sigil-mcp, sigil-jwt, sigil-websocket, sigil-markdown, sigil-format, and sigil-sxml. Error path tests added across the standard library.
Bug Fixes
- Fixed
assq-refto return values instead of aliasingassq; addedassv-ref - Fixed
number->stringprecision for exact IEEE 754 roundtrip (was losing digits on large flonums) - Fixed REPL
string-lengtherror after exception recovery - Fixed cross-module symbol resolution corruption
- Fixed bundle directory listing for bundled applications (VFS)
- Fixed
sigil-runre-import of(sigil core)before calling entry main - Fixed process port caching for stable repeated access
- Removed dead opcodes (
OP_LOAD_BYTECODE,OP_MAKE_CLOSURE_RT,OP_WRITE_BYTECODE_FILE)