Expand description
kataan — a high-performance JavaScript (ECMAScript) engine written
entirely in Rust, depending on no foreign code.
Kataan is built bottom-up in layers, and is usable three ways — as a Rust
library, as a C library (the ffi feature), and as a standalone command-
line tool / REPL (the cli feature). See ROADMAP.md for the full design
and milestone plan.
The pipeline:
source ──[lexer]──▶ tokens ──[parser]──▶ AST ──[compiler]──▶ bytecode
│
[interpreter]§no_std
The language core is #![no_std] and needs only alloc. The std feature
(default, implies alloc) adds the host runtime — the event loop, timers,
file system, network (fetch over rsurl), and crypto (over
purecrypto). Build the bare core with --no-default-features --features alloc.
Re-exports§
pub use error::Error;pub use error::Result;pub use limits::Limits;pub use limits::WasmLimits;
Modules§
- ast
- The abstract syntax tree produced by the
parser. - atom
alloc - Interned strings (“atoms”): distinct identifiers/property keys mapped to
small
Copyintegers for O(1) comparison. Needsalloc. Interned strings — “atoms” (ROADMAP.md§3, item 4). - bignum
alloc - A pure,
alloc-only arbitrary-precision integer — the foundation for a conformantBigInt(ROADMAP.md). Needsalloc. A pure,alloc-only arbitrary-precision signed integer — the foundation for a conformantBigInt(replacing the boundedi128approximation). - bytecode
alloc - A portable
KTBCserialization codec for the bytecode VM’s compiled programs (the code cache —ROADMAP.mdPhase D′). Needsalloc. A portable serialization codec for the bytecode VM’s compiled programs (ROADMAP.mdPhase D′ — serializable bytecode / code cache). - cell
alloc - Heap cells — the reference types (object / string / array / function) a heap
slot holds. Needs
alloc. Heap cells — the reference types the managed heap holds (ROADMAP.md§3). - common
- Cross-cutting building blocks shared by every layer of the engine: source
positions (
Span) and, as the engine grows, the string interner, the diagnostic types, and the bump arena. - env
alloc - Lexical environments (scope chains) for closures over the new model. Needs
alloc. Lexical environments (scope chains) for the tree-walker over the new model (ROADMAP.md§3 → Phase D migration, the function/closure piece). - error
- The engine-level error type.
- flatbc
alloc - Flat, fixed-record bytecode executed in place over a (possibly
mmap’d) byte buffer — the true zero-copy reload path (Phase D′). Needsalloc. Flat, fixed-record bytecode executed in place over a byte buffer — the true zero-copy reload path (ROADMAP.md§2.2): the interpreter runs directly over the mapped bytes, decoding one fixed-size record at a time, without ever deserializing into an ownedVec<Op>. - gc
alloc - A mark-and-sweep tracing garbage collector over
heap::Heap— reclaims unreachable objects, including reference cycles. Needsalloc. A mark-and-sweep tracing collector overHeap(ROADMAP.md§3, the GC). - heap
alloc - The managed heap (generational handle table) that NaN-boxed handles index
into — groundwork for the object model & GC. Needs
alloc. A generational handle table — the managed heap thatNanBoxhandles point into (ROADMAP.md§3, the object model & GC). - ic
alloc - Inline caches for property access, keyed on
shape::Shapeidentity — the fast path that turns a repeatedobj.xinto a slot load. Needsalloc. Inline caches for property access (ROADMAP.md§3, item 2). - json
alloc - Shared,
alloc-onlyJSON.parse/JSON.stringifyover realm values. Pure,alloc-onlyJSON.parse/JSON.stringifyover realm values. - lexer
- The lexer: ECMAScript source text → a stream of
Tokens. - limits
- Tunable resource limits (recursion depths, allocation sizes, regex/wasm
budgets) with safe defaults, overridable per
realm::Realm. Central, tunable resource limits for the engine. - nanbox
- NaN-boxed value representation — groundwork for the performance object model
(
ROADMAP.md§3). - nbeval
alloc - Evaluates the real parser AST (the expression subset) over the
Realm/NanBoxmodel — the front-end → new-representation bridge. Needsalloc. Evaluating the realast::Exprover theRealm/NanBoxmodel (ROADMAP.md§3 → Phase D migration). - nbexec
alloc - Executes real statements (variables, scope, control flow, assignment) over
the
Realm/NanBoxmodel — the imperative core on the new representation. Needsalloc. Executing real statements and functions over theRealm/NanBoxmodel (ROADMAP.md§3 → Phase D migration). - nbvm
alloc - A minimal register VM over the
Realm/NanBoxrepresentation — the proof that the performance object model executes code. Needsalloc. A minimal register VM over theRealm/NanBoxrepresentation (ROADMAP.md§3 → Phase D migration). - object
alloc - The performance-era object: a
shape::Shapepaired withnanbox::NanBoxvalue slots — composes the object-model pillars. Needsalloc. The performance-era object: aShape(hidden class) paired with a flat vector ofNanBoxvalue slots (ROADMAP.md§3). - parser
- The parser: a token stream → an AST.
- realm
alloc - The object-model context (
Realm) bundling the heap, the shared root shape, and the atom table behind the allocate/get/set/collect API a VM uses. Needsalloc. The object-model context that ties the foundation together (ROADMAP.md§3). - regex
regex - The in-house regular-expression engine (the
regexfeature). Pure Rust,no_std-compatible (alloconly). A small, in-house regular-expression engine (no foreign code). - rope
alloc - Rope strings: lazy O(1) concatenation so building a string piecewise is not
quadratic. Needs
alloc. Rope strings — lazy-concatenation string values (ROADMAP.md§3, item 4). - shape
alloc - Hidden classes (“shapes”): shared property-layout descriptors with a
transition tree — groundwork for the object model. Needs
alloc. Hidden classes (“shapes”) — shared property-layout descriptors (ROADMAP.md§3, the object model). - snapshot
alloc - Heap snapshots of the live
Cellobject graph — capture an initialized heap and restore it into a fresh realm (Phase D′ heap-snapshot tier). Needsalloc. Heap snapshots of the liveCellobject graph (ROADMAP.md§2.2, the heap-snapshot tier). - wasm
alloc - The WebAssembly peer engine: lowers the numeric subset of JS functions to
WebAssembly text (WAT) — a second compilation target. Needs
alloc. A WebAssembly backend — the WASM peer engine (ROADMAP.md). - wasm_rt
alloc - The WebAssembly execution engine (Phase H): decodes and runs
.wasmbinaries — the peer engine proper, distinct fromwasm(JS→WASM). Needsalloc. A WebAssembly execution engine (Phase H) — the peer engine that runs.wasmmodules, distinct fromcrate::wasm(which compiles JS to WASM). - wasm_
spec alloc - A WebAssembly spec-test harness: typed
assert_return/assert_trap/assert_invalidcommands run against thewasm_rtengine. Needsalloc. A WebAssembly spec-test harness (ROADMAP.mdPhase H — “validated against the WebAssembly spec test suite”). - wtf8
alloc - WTF-8 string codec: UTF-8 extended to encode lone UTF-16 surrogates, so
DOMString values round-trip losslessly. The storage foundation for rope/atom.
Needs
alloc. WTF-8 — the string-storage codec (ROADMAP.md§3, item 4; milestone B1).
Constants§
- VERSION
- The crate version, from
Cargo.toml.