boomkat

architecture

Engine architecture

How Boomkat compiles and executes JavaScript and TypeScript while keeping binary size small and startup under 2 ms.

Front end: flat AST and register bytecode

Source code is lexed and parsed into a flat AST rather than a pointer-heavy tree of heap-allocated nodes. TypeScript type annotations are stripped during compilation so .ts and .tsx files run without an external transpiler. The compiler emits register-based bytecode and applies constant folding, peephole optimization, fused operations, and inlining.

Virtual machine and value representation

The default interpreter uses direct-threaded VM dispatch (THREADED_DISPATCH). Size-focused builds can switch to a smaller switch-based loop (SMALL_VM).

Values use 64-bit NaN-boxing by default, packing primitives and pointers into IEEE 754 NaN payloads. Building with -D NONANBOX switches to a 16-byte tagged union (TVal), which is useful for platforms or debugging scenarios where NaN-boxing assumptions do not hold.

Memory management

Boomkat uses an incremental, generational tracing garbage collector to keep pause times low, paired with reference counting for strings. Because a host can link Boomkat into long-lived or memory-constrained processes, the C API lets embedders supply a custom allocator via bk_runtime_options and enforce memory limits per runtime.

Profiles and precompiled bytecode

Optional language subsystems (Intl, Temporal, TypeScript, JSX, BigInt, Proxy, RegExp) are gated by compile-time flags. At the smallest end, boomkat-tiny compiles out the parser and compiler completely (~700 KB) and executes precompiled .bk bytecode images emitted by boomkat_tiny_compile.

Further reading