Skip to content

Releases: theMackabu/ant

v0.9.0.1775718146

09 Apr 07:25
4486894

Choose a tag to compare

Release Notes

Web Platform, WinterTC & Core Runtime Surface

Ant’s WinterTC API surface grew substantially in this cycle:

  • Added DOMException
  • Added AbortController and AbortSignal support as first-class runtime pieces
  • Added WinterTC global scaffolding and related globals wiring
  • Brought EventTarget much closer to compliance and separated global-vs-emitter event type handling
  • Added Headers
  • Added Blob
  • Added FormData
  • Added Request
  • Added Response
  • Added BOM stripping in response handling
  • Brought URL closer to spec
  • Fixed URL sorting/index-walk edge cases
  • Added Promise.allSettled
  • Added regex v flag support
  • Added matchAll
  • Added Float16Array
  • Added TypedArray.from
  • Improved JSON behavior, including UTF-8 parsing and several response/request integration paths
  • Improved structured clone behavior, including DataView cloning
  • Added more reliable brand helpers and branding checks across web-facing objects
  • Marked Date brand information more reliably in slots

Streams, Pipes, Encoding & Compression

Streaming support moved from partial support into a much more complete platform layer:

  • Rewrote the iterator system and added iterator hooks that several web APIs now rely on
  • Added ByteLengthQueuingStrategy
  • Added CountQueuingStrategy
  • Added ReadableStream
  • Added WritableStream
  • Added TransformStream
  • Added queue handling for streams
  • Added blob streaming
  • Added stream codec support
  • Added compression/decompression streams
  • Added Brotli to compression and decompression paths
  • Revised text encoding and decoding to be closer to spec
  • Migrated the old node:stream stub to a proper module and wired in FS stream hooks
  • Revised FS stream behavior after the stream-module work landed

Fetch, HTTP, Server & Networking

The server and HTTP stack changed dramatically:

  • Added shared http.c helper plumbing
  • Revised the fetch API surface
  • Added buffer-backed fetch bodies
  • Added chunked upload support in fetch
  • Improved fetch error handling
  • Added appendHeader support in the Node HTTP compatibility layer
  • Added internal HTTP parser/writer helpers and exposed ant:internal helpers for HTTP work
  • Landed a brand new server.c with fresh parser/writer, listener, and connection plumbing
  • Added node:http
  • Added node:http2
  • Added node:https
  • Added node:tls
  • Added node:net
  • Added node:zlib
  • Improved compatibility for modern SSR/RSC-style workloads, especially around fetch, async iterables, promises, collections, abort handling, path handling, builtin lookup, and server behavior

Node Compatibility & Utility Modules

The Node-facing compatibility layer broadened:

  • Added node:assert
  • Added node:v8
  • Added node:diagnostics_channel
  • Added node:querystring
  • Added string_decoder
  • Added util.deprecate
  • Added util.debuglog
  • Added a V8/Node-style error shim
  • Added missing prototypes in worker_threads
  • Improved CommonJS namespace/default interop
  • Fixed exports defined as accessors in CommonJS
  • Fixed CommonJS namespace population so accessors do not invoke getters unexpectedly
  • Switched missing named exports from an undefined placeholder to an explicit error
  • Prevented nested export graphs from erroring incorrectly
  • Added a loader path for circular dependencies
  • Added canonical module handling
  • Rewrote readline to use a proper EventEmitter
  • Added async readline support
  • Preserved readline flags more carefully
  • Continued cleaning up the readline module after the rewrite

Module Loader, Import Semantics & Resolution

Import and resolution behavior saw a lot of work:

  • Allowed dynamic TLA
  • Centralized module import context for import.meta and dynamic import
  • Simplified module context handling through the module_ctx backlink
  • Added lexical bindings for subdirectory import metadata
  • Started preferring reads from node_modules first for executable/package resolution paths
  • Fixed crashes and bad states when trying to fetch CommonJS defaults
  • Improved builtin bundle handling as more Node compatibility modules were added

Async Engine, Event Loop & Promise Behavior

The async side of the runtime got one of the deepest internal rewrites in the release:

  • Rewrote the async engine
  • Added support for custom thenables
  • Fixed microtask ordering coverage with new tests
  • Improved event loop throughput substantially after eliminating a stack scan
  • Fixed several promise/coroutine/GC interactions during async resolution
  • Deferred active async coroutine unlinking so GC can still see VM state during promise resolution
  • Marked awaited coroutines during GC through the promise handler path
  • Reworked timer/process/io integration around the new async behavior
  • Improved async compatibility for server workloads, streams, and SSR/RSC-style flows

VM, Compiler, JIT & Object Model

A huge amount of work landed below the public API layer:

  • Fixed a crash involving upvalues
  • Optimized garbage collection during JIT execution
  • Re-enabled GC during JIT in phases
  • Added dynamic buffer handling for string replacements while tuning JIT+GC behavior
  • Refactored VM call handling around clearer call modes and execution plans
  • Added support for explicit this binding mode in call handling
  • Improved closure and cfunc resolution logic in the VM
  • Enabled JIT in regex paths
  • Moved iteration to new opcodes
  • Added an iteration fast path
  • Added faster string-shape slot lookup
  • Added a direct own-shape fast path for with() on ordinary objects
  • Improved hot property access fast paths
  • Fixed optional chaining behavior
  • Passed through active strict context more reliably
  • Fixed arrow-parameter handling around void token lists
  • Cleaned up proto-constructor handling
  • Added Ant.match
  • Added Ant.highlight
  • Cleaned up unused internal slots and removed dead headers

Closures, Upvalues, Shapes & Object Semantics

Many smaller commits in this range were correctness and hot-path-oriented:

  • Ensured upvalues stay in VM stack range before being dropped
  • Added slot-in-VM-range upvalue capture
  • Prevented arg closure buffers from being dropped during deopt
  • Made local capture lighter
  • Made JIT capture lazier
  • Classified child closure kinds more precisely
  • Dried up JIT fallback paths
  • Prevented segmentation faults when assigning to T_CFUNC
  • Re-synced cached pointers in sv_frame
  • Trimmed slot_buf usage in JIT paths
  • Pinned object and array literals to primordial prototypes
  • Prevented prototype enumeration leaks
  • Improved object enumeration handling for exotic objects
  • Walked the prototype chain in for...in for more spec-compliant behavior
  • Refactored Object.assign through a clearer enumerable-property helper
  • Updated collections to use canonical values

Memory Management, GC & Safety Fixes

This release includes a dense run of GC and safety work:

  • Fixed crashes on cstack paths
  • Made N-API interaction safer under GC
  • Prevented N-API stripping on Darwin builds
  • Migrated buffers to a finalizer-based lifetime system
  • Revised buffer semantics and root collection
  • Fixed a WeakMap mark-phase use-after-free
  • Prevented OOM during JSON parsing by tightening temp-root handling
  • Fixed a compile-time string table slowdown
  • Reduced one string scan from O(n^2) to O(n) with caching
  • Prevented unnecessary string allocation during initialization
  • Prevented a calloc crash
  • Ensured shapes never receive a bare T_ERR
  • Improved symbol usage and followed up with more symbol cleanup
  • Rooted important prototypes during stream/queue work

WebAssembly, WASI & Platform Coverage

WASM and platform portability has been added:

  • Added WebAssembly support
  • Added WASI support
  • Added a WebAssembly demo and example assets

Crypto, TLS, Dependencies & Build System

  • Killed MbedTLS and started the move to BoringSSL
  • Updated TLSUV for the BoringSSL backend
  • Added Brotli as a vendored dependency
  • Migrated away from libuuid
  • Migrated away from libsodium

Validation, Specs, Benchmarks & Regressions

A lot of the range is also validation work, which is useful to call out in a changelog this size:

  • Added or expanded spec coverage for assert, blob, buffer, diagnostics_channel, events, fetch, formdata, headers, match, readline, request, response, streams, text codecs, url, v8, and zlib
  • Added import, import.meta, and nested-directory regression coverage
  • Added WebAssembly API tests
  • Added stream abort capture coverage
  • Added multiple Vite watcher repros
  • Added SSR/RSC-style regressions around async iterables, row parsing, server actions, and mixed HTTP/fetch data flows
  • Added promise/thenable ordering tests
  • Added regressions for literal primordials, array subclassing, accessor spreads, missing named exports, property shape slots, iterator-result fast paths, JSON temp roots, and typed-array metadata leaks
  • Added server and regex benchmarks
  • Added JIT bailout and captured-local/param benchmarks
  • Refreshed compatibility results repeatedly as new features landed

To install Ant v0.9.0:

curl -fsSL https://ant.themackabu.com/install | bash

v0.8.0.1774087286

21 Mar 11:34
8d963e4

Choose a tag to compare

Release Notes

Generational Garbage Collector

The monolithic gc.c has been split into six modules

  • Nursery-based generational scheme with adaptive thresholds for minor/major collection
  • Write barrier for old→young cross-generation references
  • Integrated rope string and interned string GC with pool-aware sweep

Object Shapes & Inline Caches

A hidden-class system replaces hash-based property lookup with slot-indexed access:

  • Shape transitions when properties are added; shared shapes are COW-cloned on mutation
  • First 4 properties stored inline in the object struct, overflow spills to a separate array
  • Per-slot writable, enumerable, configurable flags with optional getter/setter pairs
  • Support for both interned string keys and symbol keys
  • IC epoch bumped on every GC cycle to invalidate stale cache entries
  • Shapes integrated into the collection cycle

Typed Memory Pools

A new pool allocator (include/pool.h) for frequently allocated types:

  • 32 size-class buckets with free-list reuse
  • Dedicated pools for ropes (64 KB), symbols (32 KB), bigints (64 KB), and strings (128 KB)

Swarm Compiler Type Hints & Inline Caches

The Silver bytecode compiler now emits type information and inline cache indices:

  • Local type tracking with inferred types (NUM, STR, ARR, OBJ, BOOL, etc.)
  • Numeric fast-path opcodes: ADD_NUM, SUB_NUM, MUL_NUM, DIV_NUM skip type checks
  • 16-bit inline cache index on field and global access opcodes
  • IC slot on INSTANCEOF for prototype chain caching
  • Iterator hints for fast-path array/string iteration
  • Object literal site caching for shape reuse across repeated allocations
  • Per-IC warmup/miss tracking for adaptive IC disabling

Boxing & JIT Fixes

  • Value stack operations properly unbox Number, String, and Boolean wrappers before operating
  • Post-increment/decrement on upvalues correctly boxes the result

Internal Slot Optimization

  • sv_closure_t now stores bound_this, bound_args, super_val, and call_flags directly, eliminating hash-based slot lookups for hot paths like Function.prototype.bind

To install Ant v0.8.0:

curl -fsSL https://ant.themackabu.com/install | bash
# or with MbedTLS
curl -fsSL https://ant.themackabu.com/install | MBEDTLS=1 bash

v0.7.1.1773194854

11 Mar 02:31
a3a38c6

Choose a tag to compare

Release Notes

BigInt

BigInt rewritten with a limb-based implementation:

  • Full arithmetic: addition, subtraction, multiplication, division, modulo
  • Bitwise operations: AND, OR, XOR, NOT with two's complement conversion
  • Left/right shift at the limb level
  • Radix string conversion for bases 2–36
  • Overflow-safe allocation throughout

Math

  • Math.random() now backed by libsodium's randombytes_buf() instead of the C stdlib
  • Boxed Number coercion fixes for wrapped math values

REPL

  • UTF-8 aware cursor movement, backspace, and delete
  • Virtual rendering for proper cursor positioning across wrapped lines

Additional Changes

  • Consolidated resolution and loading logic in ESM
  • Improved boxed value handling in the Swarm JIT

To install Ant v0.7.1:

curl -fsSL https://ant.themackabu.com/install | bash
# or with MbedTLS
curl -fsSL https://ant.themackabu.com/install | MBEDTLS=1 bash

v0.7.0.1772610809

04 Mar 08:23
e12bfda

Choose a tag to compare

Release Notes

Bytecode Compiler & JIT

Engine rewritten to a full bytecode compiler (silver) and JIT backend powered by MIR:

  • Silver: AST → bytecode pipeline with lexer, parser, compiler, and opcode set
  • MIR JIT: hot functions are compiled to native code with type-feedback-guided specialization for arithmetic, comparisons, and calls
  • On-stack replacement (OSR): long-running loops can transition mid-execution from interpreted to JIT'd code
  • Bailout & deoptimization: JIT'd code safely falls back to the interpreter when type assumptions are violated

REPL Overhaul

The REPL has been completely rewritten:

  • Syntax highlighting: live JS highlighting with 30+ token classes (keywords, strings, regex, template literals, numbers, comments, functions, classes)
  • Multiline-aware wrapping: proper cursor movement and rendering across wrapped lines and terminal widths
  • Lexical declaration tracking: let/const/class redeclaration errors are caught before evaluation, matching browser DevTools behavior
  • .copy [expr]: evaluate an expression and copy the result to the system clipboard
  • _ and _error: special variables for last result and last error

N-API Module

A new napi implementation enables loading native Node addons:

  • Value creation, type checking, coercion, and property access
  • Function/constructor calls, napi_wrap/napi_unwrap
  • napi_create_async_work / napi_queue_async_work via libuv
  • Threadsafe functions with queue, mutex, and uv_async dispatch
  • Handle scopes, references, error handling, and napi_module_register

Worker Threads

A new ant:worker_threads module provides subprocess-based workers:

import { Worker, isMainThread, workerData } from 'ant:worker_threads';

const worker = new Worker(new URL('./task.js', import.meta.url), {
  workerData: { input: 42 }
});

worker.on('message', msg => console.log('got:', msg));
worker.on('exit', code => console.log('exited:', code));
  • Worker, MessageChannel, MessagePort constructors
  • parentPort.postMessage() for child→parent communication
  • setEnvironmentData / getEnvironmentData for shared config
  • worker.terminate() returns a Promise

TTY Module

A new ant:tty module with ReadStream and WriteStream classes:

  • tty.isatty(fd), stream.getWindowSize(), stream.getColorDepth()
  • clearLine(), clearScreenDown(), cursorTo(), moveCursor()
  • setRawMode() for stdin
  • hasColors() with FORCE_COLOR / NO_COLOR / COLORTERM detection
  • rows and columns getters on process.stdout / process.stderr

Date Module

The Date constructor has been fully reimplemented as a standalone module:

  • All ES5/ES6 getters, setters, and string formatters
  • Date.parse() supporting ISO 8601, RFC 2822, and loose formats
  • Date.UTC(), Date.now()
  • Symbol.toPrimitive with proper hint dispatch
  • Timezone abbreviation parsing (GMT, EST, PST, CET, etc.)

RegExp Module

RegExp has been extracted into a dedicated module backed by PCRE2:

  • Symbol.match, Symbol.replace, Symbol.search, Symbol.split well-known symbol protocols
  • Symbol.species for subclass construction in @@split and @@replace
  • RegExp.escape() static method
  • RegExp.prototype.compile() for legacy compatibility
  • flags getter synthesized from individual flag properties
  • Named capture groups, Unicode property escapes (\p{Letter}), and JS→PCRE2 pattern translation
  • Regex cache with GC-aware eviction

Additional New Modules

  • ant:dns (stub): DNS resolution
  • ant:util: util.inspect(), util.format(), util.types
  • ant:async_hooks: async hook stubs
  • ant:module (stub): module.createRequire()
  • ant:net (stub): TCP socket stubs

Runtime Architecture

The monolithic src/ant.c has been decomposed into focused subsystems:

  • src/errors.c: error formatting and stack traces
  • src/gc.c: garbage collector
  • src/descriptors.c: property descriptors
  • src/esm/loader.c: ES module loader
  • src/esm/commonjs.c: CommonJS require
  • src/esm/library.c: built-in module registry
  • src/silver/: bytecode compiler, VM, JIT, lexer, AST, and opcode definitions

ES6 Spec Compliance

  • new.target meta-property
  • Enhanced destructuring for arrays and objects (nested patterns, defaults, rest elements)
  • Symbol.unscopables for with statement property hiding
  • Symbol.species for Promise, Array, and RegExp
  • Super class expressions in class definitions
  • String literal export/import names
  • Improved spread operator for arrays, strings, and dynamic arguments
  • Internal subclassing system rewrite

fs Module Additions

New synchronous and async filesystem operations:

  • fs.mkdirSync, fs.rmdirSync, fs.unlinkSync, fs.renameSync
  • fs.copyFileSync, fs.chmodSync, fs.chownSync
  • fs.realpathSync, fs.accessSync
  • Async variants via the unified event loop

Vendor Updates

Dependency Old New
tlsuv 0.40.10 0.40.13

New vendored dependencies:

  • MIR: lightweight JIT compiler backend
  • uriparser: RFC 3986 URI parsing
  • utf8proc: Unicode text processing

Additional Changes

  • Windows builds use WIN32_LEAN_AND_MEAN and compat.h for platform specifics
  • Uint8Array constructor validation fixes
  • Binding loss fixes for this context
  • process.features, TypeScript declarations for util, worker_threads, and fs

To install Ant v0.7.0:

curl -fsSL https://ant.themackabu.com/install | bash
# or with MbedTLS
curl -fsSL https://ant.themackabu.com/install | MBEDTLS=1 bash

v0.6.4.1771407535

18 Feb 09:41
ee6fc97

Choose a tag to compare

Release Notes

Watch Mode

Ant can now restart a module automatically when the entry file changes:

ant --watch server.js
ant --watch app.ts --no-clear-screen
  • Debounced restarts with graceful SIGTERM → SIGKILL fallback
  • --no-clear-screen preserves terminal output across restarts

LMDB Database Module

A new ant:lmdb module exposes the LMDB api for fast key-value storage:

import lmdb from 'ant:lmdb';

const env = lmdb.open('./mydb', {
  noSubdir: true,
  mapSize: 4 * 1024 * 1024,
  maxDbs: 8
});

const db = env.openDB('main', { create: true });

db.put('hello', 'world');
db.getString('hello');   // 'world'
db.get('hello', 'utf8'); // 'world'

const bytes = new Uint8Array([1, 2, 3, 255]);
db.put('bin', bytes);
db.getBytes('bin'); // Uint8Array [1, 2, 3, 255]

const tx = env.beginTxn();
tx.put(db, 'key', 'value');
tx.commit();

const ro = env.beginTxn({ readOnly: true });
ro.getString(db, 'key'); // 'value'
ro.abort();

db.close();
env.close();

File Encoding Support

fs.readFile and fs.readFileSync now accept encoding options and return Uint8Array by default, supports utf8, utf16le, latin1, base64, base64url, hex, and ascii encodings:

import fs from 'ant:fs';

const bytes = fs.readFileSync('image.png');        // Uint8Array
const text = fs.readFileSync('file.txt', 'utf8');  // string
const hex = fs.readFileSync('data.bin', 'hex');    // hex string
const b64 = fs.readFileSync('data.bin', 'base64'); // base64 string

GC Compaction Improvements

Garbage collection compaction has been simplified and made less likely to stall:

  • js_gc_compact() internalized as gc_compact() — no longer part of the public API
  • needs_gc flag now set at the beginning of compaction instead of after skip

Additional Changes

  • Multiple input arguments now supported via command line
  • process.features object added to snapshot generation
  • Enter key in raw mode normalized to emit '\r'

To install Ant v0.6.4:

curl -fsSL https://ant.themackabu.com/install | bash
# or with MbedTLS
curl -fsSL https://ant.themackabu.com/install | MBEDTLS=1 bash

v0.6.3.1771218233

16 Feb 05:19
97cd4d3

Choose a tag to compare

Release Notes

All core vendored dependencies have been updated:

Dependency Old New
libuv 1.51.0 1.52.0
nghttp2 1.62.1 1.68.0
tlsuv 0.40.6 0.40.10
zlib-ng 2.3.2 2.3.3

libuv and llhttp now build as Meson subprojects instead of external CMake dependencies.
Windows builds now use the MSYS2 Clang64 toolchain instead of MinGW64.

Additional Changes

  • All platforms now have a MbedTLS binary option
  • hex_digit() uses a 256-byte lookup table instead of branch chains
  • libant header generation receives version metadata as arguments

To install Ant v0.6.3:

curl -fsSL https://ant.themackabu.com/install | bash
# or with MbedTLS
curl -fsSL https://ant.themackabu.com/install | MBEDTLS=1 bash

v0.6.2.1770953487

13 Feb 03:43
455a498

Choose a tag to compare

Release Notes

Dot Operator Inline Cache

Property lookups on objects now use an inline cache for frequently accessed properties:

const obj = { name: 'Ant', version: '0.6.2' };
console.log(obj.name); // Cached after first access
console.log(obj.version);

class MyClass {
  get value() { return 42; }
}
const instance = new MyClass();
console.log(instance.value); // Still benefits from caching
  • Cache keyed by code pointer and offset for stable property lookups
  • Automatic invalidation when object structure changes
  • Eliminated memory leaks in tail call argument handling

Array.from Iterator Support

Array.from now properly supports iterable objects and mapping functions:

const unique = Array.from(new Set(['a', 1, 'a', 2, '1']));
console.log(unique); // ['a', 1, '1', 2]

const doubled = Array.from(new Set([1, 2, 3]), x => x * 2);
console.log(doubled); // [2, 4, 6]

const chars = Array.from("abc");
console.log(chars); // ['a', 'b', 'c']

const arr = Array.from([10, 20, 30]);
console.log(arr); // [10, 20, 30]

Package Manager Enhancements

The CLI package manager now supports bulk operations and project scaffolding:

# Install multiple packages at once
ant add pkg1 pkg2 pkg3

# Create project from template
ant create react my-app
ant create next my-next-app

# Create from GitHub repository
ant create github-org/repo my-project
ant create https://github.com/org/repo.git my-project

To install Ant v0.6.2:

curl -fsSL https://ant.themackabu.com/install | bash
# or with MbedTLS (darwin only)
curl -fsSL https://ant.themackabu.com/install | MBEDTLS=1 bash

v0.6.1.1770760605

10 Feb 22:10
d695ef1

Choose a tag to compare

Release Notes

Unified Escape Sequence Decoder

String escape sequence handling has been completely rewritten with a unified decoder:

// All escape sequences now handled consistently
const str = "\x41\x42\x43\u0041\u0042\u{1f600}\n\t";
console.log(str); // "ABCAB😀" + newline + tab

// Template literals use the same decoder
const name = "world";
const tpl = `Hello\n\u0041\u{1f600} ${name}`;
console.log(tpl); // "Hello\nA😀 world"
  • Fixed incorrect unhex implementation
  • Octal escapes properly rejected in template literals
  • Proper UTF-8 encoding for all Unicode escape sequences (\u{NNNNN})

beforeExit Event

The process module now emits a beforeExit event before the event loop exits:

let iterations = 0;

function work() {
  iterations++;
  if (iterations < 1000000) setImmediate(work);
}

work();

process.once('beforeExit', () => {
  console.log(`Completed ${iterations} iterations`);
});
  • Emitted after the event loop finishes but before process termination
  • Can schedule additional async work to keep the process alive
  • Useful for final cleanup and performance reporting

Tail Call Optimization Fixes

Multiple TCO edge cases have been fixed:

// Zero-argument tail calls now work correctly
function countdown(n) {
  if (n <= 0) return 'done';
  return countdown(n - 1);
}
countdown(1000000); // No stack overflow

// TCO disabled for array/object literals to prevent incorrect optimization
const arr = [1, 2, 3];  // Properly parsed
const obj = { a: 1 };   // Not subject to TCO
  • Fixed zero-argument tail call iteration
  • TCO disabled during array and object literal parsing
  • Ternary expressions and tail span checks now properly supported
  • Eliminated memory leaks in tail call argument handling

To install Ant v0.6.1:

curl -fsSL https://ant.themackabu.com/install | bash
# or with MbedTLS (darwin only)
curl -fsSL https://ant.themackabu.com/install | MBEDTLS=1 bash

v0.6.0.1770714933

10 Feb 09:19
9b26492

Choose a tag to compare

Release Notes

v0.6.0 is the one of the largest releases since the project began. 56 commits touching 73 files with over 8,000 lines of new code. Three core data structures have been replaced: strings now use ropes, arrays use dense backing buffers, and the tokenizer caches streams per function body. The garbage collector gained conservative stack scanning and controlled safepoints, and the runtime now performs tail call optimization. This is effectively a new engine underneath the same API.

We also now have a discord: http://discord.gg/CH7YSjWGzY


Rope Strings

String concatenation now uses a rope data structure for deferred flattening:

let s = '';
for (let i = 0; i < 10000; i++) {
  s += 'x'; // O(1) concatenation via rope nodes
}
  • Flattening deferred until string content is actually read
  • Max depth of 64 with automatic flattening at 32KB threshold

Dense Arrays

Arrays now use a dense backing store for indexed elements:

const arr = [1, 2, 3, 4, 5]; // Stored as contiguous jsval_t buffer
arr.push(6);                 // Appends to dense buffer
arr[100] = 'sparse';         // Falls back to property storage

Token Streaming Cache

Function bodies are now tokenized once and replayed on subsequent calls:

  • token_stream_t caches token type, offset, length, and literal values
  • Cached per-function via parsed_func_t hash table

Tail Call Optimization

Recursive functions in tail position are optimized to reuse the current call frame:

function factorial(n, acc = 1n) {
  if (n <= 1n) return acc;
  return factorial(n - 1n, n * acc); // Tail call: no stack growth
}

factorial(10000n); // Works without stack overflow
  • Token stream scanned at parse time to detect tail call patterns
  • scan_tail_span() analyzes return statements for eligible calls

GC Safepoints & Stack Scanning

Garbage collection now uses controlled safepoints and conservative stack scanning:

  • Engine now marks safe points for collection
  • GC scans C stack for heap pointers reducing manual rooting overhead
  • Expression operands rooted across sub-expression evaluation
  • Adaptive cooldown tuned for heap size (2-8 second intervals)
  • GC throttling during server response handling and coroutine execution
  • Promise offset tracking prevents premature collection of pending promises

BigInt Bitwise Shifts

BigInt now supports left and right shift operators:

const a = 1n << 64n;  // 18446744073709551616n
const b = 256n >> 4n; // 16n
  • Optimized fast path for values fitting in uint64_t
  • Arbitrary-precision fallback using multiply/divide by powers of 2

Class Computed Property Keys

Classes now support computed property names for fields, methods, and static members:

const key = 'x';
class Vec {
  [key] = 0;
  ['get' + 'Value']() { return this.x; }
  static ['create']() { return new Vec(); }
}

const sym = Symbol('id');
class Entity {
  [sym] = 42;
}
new Entity()[sym]; // 42
  • Computed keys evaluated once at class definition time
  • Symbol, string, and numeric keys supported
  • Side-effect expressions ([makeKey()]) only run during class creation

ES6 Feature Additions

  • Symbol.species for subclass constructor customization
  • Object.is() for same-value equality
  • Number.parseInt / Number.parseFloat aliases
  • Promise.race() and Promise.all() accept any iterable
  • Proxy support for push, pop, splice, includes, indexOf, and instanceof
  • Static class members properly initialized

Stdin Piping

Ant now reads from stdin when no file argument is given:

echo "console.log('hello')" | ant
cat script.js | ant

Unified Event Loop

All async modules now share uv_default_loop() directly:

  • Removes per-module private event loops (fs, fetch, child_process)
  • Fixes deadlocks when async operations ran on unpolled loops
  • Server integration via js_reactor_set_poll_hook()
  • Per-emitter event tracking via emitter_registry

Unified String Handling

New js_to_cstr() API for safe value-to-C-string conversion:

char buf[512];
js_cstr_t str = js_to_cstr(js, value, buf, sizeof(buf));
printf("%s\n", str.ptr);
if (str.needs_free) free((void *)str.ptr);
  • Stack buffer fast path avoids allocation for small strings
  • Automatic heap fallback for large values
  • Eliminates memory leaks from tostr_alloc() call sites

Absolute Path Imports

ES modules now resolve absolute paths with extension probing:

import config from '/etc/myapp/config.js';
  • Tries .js, .ts, .mts, .cts, .json extensions
  • Consistent with relative path resolution behavior

URL Module Prototype Migration

The URL constructor now uses proper prototype-based methods:

  • Methods like toString(), toJSON() moved to URL.prototype
  • SLOT_ENTRIES for search params iterator state
  • js_eval_cached() API for snapshot-based evaluation

Additional Changes

  • Arena shrinking and memory decommit for reduced RSS
  • Interned property cache invalidated by generation counter on GC
  • Weak reference handling for collections GC updates
  • Dedicated descriptor entry for array length property
  • Reactor event polling optimized for fewer wakeups
  • Consolidated runtime cleanup logic
  • Child process event loop detection and polling improvements
  • Event system memory cleanup on emitter teardown
  • Comprehensive BUILDING.md guide added

To install Ant v0.6.0

curl -fsSL https://ant.themackabu.com/install | bash
# or with MbedTLS (darwin only)
curl -fsSL https://ant.themackabu.com/install | MBEDTLS=1 bash

v0.5.2.1770185958

04 Feb 06:53
89f6d43

Choose a tag to compare

Release Notes

Revised Symbol System

The Symbol implementation has been completely rewritten for spec compliance:

const sym = Symbol('desc');
console.log(sym.toString());        // "Symbol(desc)"
console.log(sym.description);       // "desc"

const obj = { [Symbol.toPrimitive]: () => 42 };
console.log(+obj);                  // 42
  • Symbol.toPrimitive and Symbol.hasInstance now supported
  • Symbol keys properly handled in object coercion

BigInt Performance & Methods

BigInt.prototype.toString rewritten for faster radix conversion:

const big = 2n ** 256n;
console.log(big.toString(16));  // much faster hex conversion
  • O(n²) → O(n log n) improvement for large numbers
  • BigInt.asUintN(bits, value) - wrap to unsigned N-bit integer
  • BigInt.asIntN(bits, value) - wrap to signed N-bit integer

(API change) Dynamic Object Keys

Custom objects can now provide dynamic key enumeration:

js_set_keys(js, obj, my_keys_fn);

Object.keys(dynamicObj);    // Calls custom keys function
Object.values(dynamicObj);  // Uses keys + getter
Object.entries(dynamicObj); // Uses keys + getter
  • js_set_keys() registers a callback for Object.keys()
  • Works with existing js_set_getter() and js_set_setter()
  • Used internally for process.env enumeration

Improved process.env

Environment variable handling now fully supports enumeration and modification:

process.env.MY_VAR = 'value';
console.log(Object.keys(process.env));  // lists all env vars
delete process.env.MY_VAR;

Scope Management Fixes

Function call scope handling has been corrected:

  • Function scope now pushed to stack after creation (not parent scope)
  • Fixes variable resolution in nested function calls
  • Constant assignment errors now always throw (not just in strict mode)

Map/Set GC Improvements

Collection registry restructured for proper GC forwarding:

  • map_registry_entry_t and set_registry_entry_t track object offsets
  • Separate reserve and update phases for GC roots
  • Prevents dangling references after compaction

Additional Changes

  • Array literal handling optimized
  • Buffer out-of-bounds access fixed
  • js_try_get() as single source of truth for property access
  • Null check for realloc in various modules
  • [object Array] now returned for Object.prototype.toString.call([])
  • Redundant GC code and gc_suppress flag removed
  • File prefix resolution for package manager

To install Ant v0.5.2

curl -fsSL https://ant.themackabu.com/install | bash
# or with MbedTLS (darwin only)
curl -fsSL https://ant.themackabu.com/install | MBEDTLS=1 bash