Commit Graph
196 Commits
Author SHA1 Message Date
Chris Tate dde66d0699 feat(compiler): add Node module resolution introspection 2026-09-14 16:28:03 -05:00
Chris TateandPaolo Anzani 2bfc37b138 fix(compiler): support branded primitive types (#320)
Co-authored-by: Paolo Anzani <201222836+paoloanzn@users.noreply.github.com>
2026-09-14 13:46:36 -05:00
Chris TateandMateus Mamede Lage 16de852347 fix(compiler): lower dynamic any-local operators (#319)
Fixes #290

Co-authored-by: Mateus Mamede Lage <23098414+mmamedel@users.noreply.github.com>
2026-09-14 12:31:25 -05:00
Chris Tate 74dce238ab perf(runtime): scale URLSearchParams sorting (#318) 2026-09-14 11:53:42 -05:00
Chris Tateand2youg1 b74364ed01 fix(compiler): preserve leading BOM literals (#316)
Co-authored-by: 2youg1 <65069696+2youg1@users.noreply.github.com>
2026-09-14 10:29:16 -05:00
Chris Tate 073c840564 Enforce TypeScript 7 and Node type-link parity (#315)
* Enforce TypeScript 7 and Node type-link parity

* fix(compiler): normalize Windows resolver paths

* fix(compiler): canonicalize Windows realpaths
2026-09-14 09:19:08 -05:00
Chris Tate a8a5204574 Implement typed async generators (#310) 2026-09-14 00:38:06 -05:00
Chris Tate 9fb0620f06 Implement explicit resource management (#309) 2026-09-13 23:34:17 -05:00
Chris Tate d7aed4b722 Unify TS 7 project module resolution (#308) 2026-09-13 21:53:45 -05:00
Chris Tate 94fd361b54 Implement sparse native arrays and missing-value parity (#297)
Represent ordinary JavaScript arrays with hole, value, and explicit-undefined states; add sparse side storage and carry missing values through the frontend, native backends, runtime, and Node-facing consumers.
2026-09-12 22:39:07 -05:00
Chris Tate 4b241f77d7 Replace quadratic array sorting with stable merge sort (#296)
* Fix Sandbox command transport and pinned native setup

Build the Linux LLVM helper and runtime pack before running both test lanes, and align native cache contracts with the current target policy. Full managed Sandbox gate passed.

* Replace quadratic array sorting with stable merge sort

Cover sort snapshots, consistent-comparator results, stable ties, and comparator complexity with Node differential fixtures. Document differences from V8 TimSort.
2026-09-12 16:05:16 -05:00
Chris Tate 0bf47eb87e feat: support static ESM import metadata 2026-09-02 18:18:09 -05:00
Chris Tateandyowainwright 1071b87d77 Lower Math.PI and Math.E statically (#279)
Co-authored-by: yowainwright <1074042+yowainwright@users.noreply.github.com>
2026-09-01 00:47:23 -05:00
Chris Tateandmmamedel 9080986166 Add sparse UTF-16 indexing for large strings (#275)
* fix: index large unicode strings sparsely

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: retain sparse anchors for long ascii prefixes

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: skip sparse index for proven ASCII strings

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: complete sparse UTF-16 string indexing

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* test: rebase static size contracts for sparse index

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* test: retain sparse checkpoints through ASCII prefix end

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: retain sparse anchors across threshold append

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: retain sparse indexes beyond cursor cache

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: bound sparse string index residency

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* fix: isolate sparse string index residency

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>

* test: restore parseInt oracle outputs

* test: verify committed string oracle

- Regenerate the string case oracle with the active Node executable.\n- Compare the checked-in fixture byte-for-byte before native runtime checks.\n- Keep the Linux parseInt ULP allowance scoped to native output.

---------

Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>
2026-08-31 17:12:52 -05:00
Chris Tateandmmamedel 0b1738d51e optimize string self-concatenation ownership (#267)
Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>
2026-08-30 17:53:30 -05:00
Chris Tateandmmamedel 5b7a5bd82b fix(compiler): reshape inline record assertions (#266)
Co-authored-by: mmamedel <23098414+mmamedel@users.noreply.github.com>
2026-08-30 17:05:44 -05:00
Chris TateandxXCrash2BomberXx 2cbd7a56ee fix(compiler): lower dyn-backed record equality reads (#184)
- Route JSDoc record absence probes through checked-dynamic keyed reads.
- Cover strict equality, missing keys, and object identity for dot and bracket access.

Co-authored-by: xXCrash2BomberXx <91439080+xXCrash2BomberXx@users.noreply.github.com>
2026-08-20 18:07:21 -05:00
Chris Tate 6310dfb960 Reuse reachability lowering output (#178)
* Reuse reachability lowering output

- Retain reachable IR and assemble the emitted module without lowering bodies a second time
- Preserve reached-only artifact filtering, coverage remainder behavior, and add lowering phase timing

* Preserve record order in retained lowering

* Preserve record order in retained helpers

* Preserve generic lowering record order

* Recheck retained generic rest order

* Record retained lowering parity fixtures

* Preserve retained lowering failure parity
2026-08-20 14:01:39 -05:00
Chris Tate 273ceac4a7 Optimize same-shape record spreads (#168)
* Optimize same-shape record spreads

- Lower TypeScript record updates through reusable clone helpers
- Outline large record clones in C and LLVM to reduce generated code
- Add ownership, IR, integer-proof, and differential coverage

* Fix cast record spread clone fallback
2026-08-17 23:37:15 -05:00
Chris Tate ff98ee2330 Speed up scriptc builds (#166)
* Speed up scriptc builds

- Cache native compilation inputs and enable Node 24 bytecode caching
- Memoize frontend type lowering and reduce checker overfetch
- Add dev-mode library optimization and phase timing

* Fix persistent cache invalidation

* Fix native cache dependency validation

* Fix native cache header shadow invalidation
2026-08-17 20:15:56 -05:00
Jimmy Miller 729f809099 Merge pull request #153 from vercel-labs/split/filter-truthy-predicate
feat(compiler): accept truthy filter predicates
2026-08-17 08:56:40 -07:00
Jimmy Miller b98b7c4a49 fix(compiler): guard zero-arg dynamic filter calls 2026-08-17 10:34:43 -04:00
Chris TateandKayakyx 952f5788aa fix(runtime): trust Windows root certificates (#158)
* fix(runtime): trust Windows root certificates

- Load default TLS roots from the Windows ROOT store.
- Link crypt32 for Windows TLS builds.
- Cover the certificate-store import in cross-build tests.

Co-authored-by: Kayakyx <Kayakyx@users.noreply.github.com>

* fix Windows CA store policy handling

* fix(runtime): cover Windows policy root stores

* fix(runtime): dedupe Windows root stores

* fix(tls): match Windows system CA stores

---------

Co-authored-by: Kayakyx <Kayakyx@users.noreply.github.com>
2026-08-15 19:27:33 -05:00
Chris TateandJohn Lindquist 1e4f71dddf fix(compiler): recognize tuples in Array.isArray (#154)
* fix(compiler): recognize tuples in Array.isArray

- Treat fixed tuple record shapes as JavaScript arrays.
- Keep union tag tests and narrowing aligned.
- Add Native SDK facade regression coverage.

Co-authored-by: John Lindquist <36073+johnlindquist@users.noreply.github.com>

* fix(compiler): narrow readonly tuple arrays

* fix(compiler): preserve narrowed readonly tuples

---------

Co-authored-by: John Lindquist <36073+johnlindquist@users.noreply.github.com>
2026-08-14 10:50:35 -05:00
Jimmy Miller 0bd90765cf feat(compiler): accept truthy (non-bool) filter predicates
`.filter(fn)` required the callback to return exactly bool. JS applies
ToBoolean to whatever the predicate answers, so `xs.filter((s) => s)` — the
idiomatic drop-the-falsy — was refused for no semantic reason.

The filter loop now wraps the call in the same toBool an `if` statement would
apply. A bool answer is unchanged and emits identical IR. A union answer
routes through its interned per-arm truthy helper, requested at the call site
where a real node exists for the diagnostic. A unit-only answer is constantly
falsy, and the call still runs for its effects.

The kinds with no native ToBoolean keep the fence: void has no value at all,
and dyn/jsval/caught truthiness needs the embedded engine.

Verified against Node: filtering strings, numbers, and a
`(string | undefined)[]` all print identically in both.

Diagnostics 100, filter corpus 9 across both
backends.
2026-08-14 10:27:38 -04:00
Jimmy Miller 990c7ce048 fix(compiler): preserve runtime-optional soundness 2026-08-13 15:47:45 -04:00
Jimmy Miller d091443dc9 fix(compiler): guard runtime-optional captures 2026-08-13 15:47:44 -04:00
Jimmy Miller 46541750e0 feat: support compiling and running Portless
What we did:

- Add the compiler and runtime support required to build the real Portless CLI as a fully static native binary and run its proxy, alias, framework, parallel-registration, and process-cleanup workflows without Node.
- Support Portless's dual HTTP/1.1 and HTTP/2 secure-server graph, including ALPN dispatch, shared request/connect listeners, HTTP/2 CONNECT responses, enableConnectProtocol settings, req.stream access, session errors, and the required ownership and lifecycle handling.
- Lower Portless's indexed absence probes, strict indexed comparisons, optional chains, server options, and container patterns. Preserve Node-style self-reexecution and correctly frame forwarded chunked responses.
- Add focused corpus and server differentials plus an isolated-copy acceptance harness that builds and exercises the pinned Portless checkout in plain and sanitized modes without modifying the external checkout.
- Validate the static binary against Portless's official e2e suite: all 13 files and 16 tests pass.

What we decided was out of scope:

- Broader HTTP/2 client policy, lifecycle compatibility, protocol validation, listener overloads, and unrelated HTTP/2 completeness.
- General runtime-optional soundness beyond the Portless paths. Making that mechanism generally sound requires function-scoped tracking so reused local IDs cannot leak optional state between functions, assignment-aware tracking so writing a definitely present value clears hidden undefined state, and correct preservation across generators, modules, and finally blocks. That larger cross-cutting change remains a dedicated follow-up.
- Removing the self-reexecution heuristic's inherent ambiguity. A direct invocation whose first user argument canonically names the executable is currently treated as Node's repeated script slot and collapsed. An explicit native reexec marker can address that in future work.
2026-08-13 15:47:42 -04:00
Chris TateandAlbert 31f268be2b feat: support wasm32-wasi as a production target (#133)
* feat: support wasm32-wasi as a production target

- Add production LLVM WASI codegen with a 32-bit ABI, coroutines, and dynamic modules
- Integrate WASI builds and execution into the CLI with capability diagnostics
- Add differential coverage and document the fourth production target

Co-authored-by: Albert <57402359+bulatovv@users.noreply.github.com>

* fix: address wasm target review findings

* fix WASI guest paths and fetch alias detection

* fix WASI async bridge and fetch detection

---------

Co-authored-by: Albert <57402359+bulatovv@users.noreply.github.com>
2026-08-11 14:12:59 -05:00
Chris Tateandsqlpxc 2c164dd374 feat: support x86_64 Linux musl targets (#131)
* feat: support x86_64 Linux musl targets

- add musl runtime shims for randomness, fibers, and child-process cwd support
- validate executable and library outputs against Alpine Linux
- document x86_64-linux-musl cross-compilation

Co-authored-by: sqlpxc <38583139+sqlpxc@users.noreply.github.com>

* fix: harden musl runtime portability

* fix: keep child fixture portable across hosts

---------

Co-authored-by: sqlpxc <38583139+sqlpxc@users.noreply.github.com>
2026-08-11 12:10:03 -05:00
Chris TateandEli Sterling acf0a2b905 Support static HTTP server timeout properties (#127)
* Support static HTTP server timeout properties

- Lower typed timeout property reads and writes through both native backends.
- Store Node-compatible defaults independently on each HTTP/HTTPS server.
- Cover defaults and assignments with differential corpus tests.

Co-authored-by: Eli Sterling <240321107+eli-sterling@users.noreply.github.com>

* Support keep-alive timeout buffer property

* Fix HTTP server timeout property lowering

* fix: scope HTTP server timeout handling

* fix: preserve HTTP server timeout semantics

---------

Co-authored-by: Eli Sterling <240321107+eli-sterling@users.noreply.github.com>
2026-08-11 08:33:38 -05:00
Chris TateandI Plan Websites e281259db3 feat(fs): expose Stats disk metadata (#120)
* feat(fs): expose Stats disk metadata

- Lower blocks, nlink, and atimeMs through the C and LLVM backends.
- Populate path, promise, file-handle, and dynamic bridge stats across supported platforms.
- Add differential, declaration, and npm bridge coverage.

Co-authored-by: I Plan Websites <787729+iplanwebsites@users.noreply.github.com>

* fix(fs): keep Windows stats snapshots coherent

* fix(fs): preserve Windows lstat metadata

* fix(fs): validate Windows mount point payloads

---------

Co-authored-by: I Plan Websites <787729+iplanwebsites@users.noreply.github.com>
2026-08-10 12:21:11 -05:00
Chris Tateandmorler 00eb380a0f perf: use integer induction for byte loops (#121)
- Recognize canonical typed-array loops with semantics-safe fallbacks.
- Emit integer induction and direct integer byte indices in C and LLVM.
- Add backend and differential regression coverage.

Co-authored-by: morler <478444+morler@users.noreply.github.com>
2026-08-10 11:33:17 -05:00
Chris Tate 4d96d2de28 feat(fs): support three-argument writeFile (#112)
* feat(fs): support three-argument writeFile

- Lower static UTF-8 encoding and mode options for fs/promises.writeFile.

- Add mode-aware runtime and backend support with promise rejection behavior.

- Cover supported options and failures in the differential corpus.

* fix fs write option evaluation and mode validation

* fix fs prototype-backed write options

* fix: preserve ignored write option semantics
2026-08-10 10:19:51 -05:00
Chris Tate 17ee5eff94 feat: support process write callback and encoding args (#114)
* feat: support process write callback and encoding args

- Lower static stdout and stderr writes with encoding and callback overloads.
- Schedule completion callbacks through the next-tick queue in C and LLVM builds.
- Cover encoding aliases, ordering, and async-free refusal behavior.

* fix: handle omitted process write arguments
2026-08-10 10:07:08 -05:00
Chris Tate b94c88e31c feat: support static non-UTF-8 TextDecoder labels (#111)
* feat: support static non-UTF-8 TextDecoder labels

- Recognize static WHATWG labels and aliases during builtin lowering.
- Add feature-gated portable decoders generated against the pinned Node runtime.
- Cover legacy encodings, malformed input, and unsupported dynamic labels.

* fix: match Node legacy decoder recovery

* fix TextDecoder edge-case parity

* fix(runtime): match Node malformed text decoding

* fix TextDecoder recovery edge cases
2026-08-09 23:15:51 -05:00
Chris Tate 8188470e3a feat: support fs/promises FileHandle (#110)
* feat: support fs/promises FileHandle

- Add static lowering and typing for fs/promises.open and the supported FileHandle surface.

- Implement FileHandle ownership and I/O across the C runtime and C/LLVM backends.

- Add differential corpus coverage and refresh the supported-surface manifest.

* fix fs file handle argument handling

* fix fs file handle validation

* fix(fs): preserve FileHandle read error codes

* fix(runtime): match empty FileHandle buffer behavior
2026-08-09 21:22:19 -05:00
Chris Tate a9b6dba424 feat(string): support static split limits (#109)
* feat(string): support static split limits

- Lower split limits for string and literal RegExp separators across C and LLVM.
- Match JavaScript ToUint32 limit semantics in the runtime.
- Add differential coverage and refresh diagnostics and surface metadata.

* fix(string): default undefined split limits
2026-08-09 18:09:00 -05:00
Chris Tate f1066d7825 Support variable Buffer.toString encodings (#108)
* Support variable Buffer.toString encodings

- Lower runtime-valued BufferEncoding arguments through checked C and LLVM paths.
- Normalize aliases and casing while preserving Node unknown-encoding errors.
- Add differential coverage and remove the obsolete diagnostic fence.

* fix(buffer): preserve unknown encoding messages

* fix(buffer): preserve optional encoding defaults

* fix(runtime): handle empty Buffer decoding ranges
2026-08-09 17:23:13 -05:00
Chris Tate 82b065c014 feat(fs): support static writeSync (#106)
* feat(fs): support static writeSync

- Lower Buffer-window and UTF-8 string overloads through the C and LLVM backends.
- Match Node's positioned and current-offset write behavior, validation, and errors.
- Add differential corpus coverage and publish the static surface manifest entry.

* fix(fs): preserve writeSync runtime semantics

* fix fs.writeSync error parity

* fix fs write descriptor errors
2026-08-09 16:54:33 -05:00
Chris Tate b3d3101550 Add static array unshift and reverse (#107)
- Lower unshift and reverse through the C and LLVM backends.
- Preserve spread, mutation, evaluation-order, and reference-counting semantics.
- Add runtime, differential, and surface-manifest coverage.
2026-08-09 14:25:53 -05:00
Chris Tateandryoppippi 23a2d3309e feat(fs): support static rename APIs (#104)
* feat(fs): support static rename APIs

- Lower fs.rename, fs.renameSync, and fs/promises.rename through the C and LLVM backends.
- Add runtime callback, error, and promise handling for rename operations.
- Cover typed and check-JS usage with differential corpus tests.

Co-authored-by: ryoppippi <1560508+ryoppippi@users.noreply.github.com>

* fix Windows rename semantics

* fix: move callback rename work off main thread

* fix(runtime): preserve rename callback checkpoints

---------

Co-authored-by: ryoppippi <1560508+ryoppippi@users.noreply.github.com>
2026-08-09 13:29:15 -05:00
Chris Tate a4e9970119 Support static util.parseArgs (#103)
* Support static util.parseArgs

- Lower typed util.parseArgs calls through the C and LLVM backends.
- Add a link-gated native parser with Node-compatible options, tokens, defaults, and errors.
- Cover ESM, CommonJS, default argv, sanitizer, and TS7 behavior.

* fix(runtime): align parseArgs behavior with Node

* fix(runtime): close parseArgs parity gaps

* fix(runtime): match parseArgs edge cases

* fix(runtime): preserve parseArgs short and default semantics
2026-08-09 08:57:03 -05:00
Chris Tateandsensei-woo e5c875bd97 Support Date instance lowering (#101)
* Support Date instance lowering

- Lower read-only Date values and constructors through the C and LLVM backends.

- Add portable calendar helpers, differential coverage, and documented surface contracts.

- Fence unsupported mutation, identity, locale, and component-constructor forms.

Co-authored-by: sensei-woo <sensei-woo@users.noreply.github.com>

* Fix Date exception and timezone semantics

* fix: harden Date lowering edge cases

* fix Date lowering edge cases

* Fix Date union fences and offset clipping

---------

Co-authored-by: sensei-woo <sensei-woo@users.noreply.github.com>
2026-08-08 23:17:58 -05:00
Chris Tateandsensei-woo 0c45ee7d90 Support positioned fs.readSync calls (#99)
* Support positioned fs.readSync calls

- Lower numeric positions while preserving omitted and null current-offset behavior.

- Add offset-preserving native reads across POSIX and Windows runtimes.

- Cover positioned reads, offset semantics, EOF, and invalid positions.

Co-authored-by: sensei-woo <sensei-woo@users.noreply.github.com>

* fix(runtime): preserve partial positioned reads on Windows

* fix zero-length positioned reads

* fix(runtime): match empty readSync validation order

* fix(compiler): accept parenthesized null read positions

---------

Co-authored-by: sensei-woo <sensei-woo@users.noreply.github.com>
2026-08-08 16:58:34 -05:00
Chris Tateandmorler 53e2f08227 perf(compiler): specialize typed-array element access (#97)
* perf(compiler): specialize typed-array element access

- Lower typed-array reads, writes, and lengths directly by IR element kind.
- Preserve coercion, bounds, and receiver lifetime semantics across C and LLVM.
- Cover emission, ABI layout, and Node-differential behavior.

Co-authored-by: morler <478444+morler@users.noreply.github.com>

* fix: retain typed-array receiver across nested assignments

---------

Co-authored-by: morler <478444+morler@users.noreply.github.com>
2026-08-08 14:39:41 -05:00
Chris Tate 782d3b8451 fix(compiler): support implicit top-level await modules (#94)
* fix(compiler): support implicit top-level await modules

- Match Node 24 syntax detection by treating top-level await as an ES module marker.

- Add differential corpus coverage for TypeScript files without explicit imports or exports.

* fix Node ESM classification for top-level await

* fix ESM require diagnostics and classification caching

* fix require binding and package type precedence

* fix: align top-level await module detection with Node
2026-08-08 11:35:01 -05:00
Jimmy Miller d41b5dd3c3 Add generations to cycle detection (#30)
* runtime: pin the ScrCycHdr layout the LLVM backend hardcodes

scr_cyc_mark_live is a static inline, so there is no symbol for the LLVM
backend to call — it open-codes the retain hook as a raw `store i32 0` at
obj-16 and reaches the cycle header at obj-32. Three sites emit that
(llvm/shapes.ts, llvm/classes.ts, llvm/emitter.ts), which makes the C
struct's size and its `color` offset a real ABI between the runtime header
and hand-written IR. The stored VALUE is part of that ABI too: the emitted
store is the literal 0, not the enumerator, so SCR_CYC_BLACK's numeric value
is pinned as surely as the offsets are.

Nothing enforced any of it. llvm-runtime-abi.test.ts mechanically checks that
every `declare @scr_*` agrees with its C prototype, but that is the FUNCTION
ABI; a struct-offset skew is invisible to it, to the type system, and to the
C compiler. Narrowing `color` and putting another field in the freed bytes
compiles clean and silently zeroes that field on every retain; reordering the
color enum compiles clean and makes every retain write the wrong color.

Assert the four properties the emitted IR actually depends on, so the next
edit to this struct or that enum fails the build instead of miscompiling.

The three layout assertions bake in 64-bit pointers and size_t, which every
current target has. A 32-bit port would trip them — correctly: the backend's
hardcoded -16/-32 would need fixing too.

* runtime: collect cycles generationally

A trial-deletion pass costs O(objects reachable from its candidates), and a
candidate inside a large live structure reaches all of it. Collecting every
256 candidates therefore made total collection work quadratic in a growing
live heap: the V8 splay benchmark spent 749ms per iteration, ~99% of it in
the collector re-walking a tree that was entirely live and never garbage.

Make the collector generational, in the shape CPython uses for this same
algorithm. Each header carries a generation; a pass names the oldest one it
will walk and skips anything above it, exactly as it already skips NULL and
immortals; survivors are promoted so later nursery passes never re-walk
them. A pass then costs what was allocated since the last one rather than
the whole heap.

Restricting the walk stays sound because trial deletion is already
conservative in the safe direction: an edge from a skipped older object is
never trial-deleted, so its target keeps that count and reads as externally
referenced — the same answer the collector gives for a stack reference.
What it gives up is cycles that span generations, and the full pass (which
skips nothing, and so is exactly the old algorithm) is what finds those.

Three things that are load-bearing and were not obvious:

- A restricted pass may spare a candidate ONLY because the edge keeping it
  alive came from a generation it refused to walk. The candidate buffer is
  the collector's only root set and markRoots consumes the entry, so
  dropping such a survivor retires the one record that the object is a
  possible cycle root — and a dead cycle whose members were all spared that
  way is then invisible to every later pass, full ones included. So a
  restricted pass hands its survivors back as candidates. A full pass needs
  none of this: it walked every edge, so rc > 0 there is a genuine outside
  reference and Bacon-Rajan's own reasoning retires the candidate.

- Live data that is unlinked INTO a dead cycle grows no counter: those
  objects were tallied when they were allocated, and they are not in the
  nursery. A heap-growth trigger alone therefore never fires for a program
  that churns its long-lived structures, so the mature candidate buffer's
  own size is a second full-pass trigger.

- Restricting the walk leaves one edge accounted by NOBODY. markGray does
  not trial-delete an edge into a skipped generation, and the teardown
  contract has free_fn release exactly the UNTRACED children — because every
  traced edge was supposed to have been decremented by markGray. So freeing
  a white object that holds a traced edge into an older generation drops the
  edge while the target keeps the count, and that phantom reference reads as
  an external one to every later pass, full ones included: the target and
  everything it links to would never be reclaimable again.

  The white set pays those edges off explicitly, in two halves, because the
  walk cannot do it inline — a release there could free a survivor that
  scr_promote still points at, or cascade into the white set mid-teardown.
  Each target is PINNED with a retain while `gen` still holds the values the
  walk filtered on, and after the teardowns the pin is dropped and the edge
  given up for real. Two decrements per entry, because the pin is one of
  them; a single release would only undo the pin and leave the phantom edge
  where it was. The pin is also what makes the second decrement safe, since
  a teardown's releases of untraced children can reach a cycle-headered
  object — that is how they re-buffer survivors. One entry per skipped edge,
  so several edges sharing a target settle it once each. Nothing pinned can
  be in the white set: a skipped older object's edges were never
  trial-deleted, so anything it references was scan-blacked rather than
  whitened, by the same conservatism above.

The event loop's between-turns collection now runs one scheduled pass
instead of scr_collect_cycles(); a full sweep per turn would walk the whole
live heap every turn, which is the cost the generations exist to avoid.
scr_collect_cycles() stays the exit / session-reset sweep, where the RC
audit runs straight after and wants nothing reclaimable left.

757-cycle-cross-generation.ts covers the third point: a live list mutated
until its nodes promote, then dead nursery cycles holding traced edges into
it. Unaccounted, the sanitized lane reports 60 objects live at exit — the
whole list, held by phantom counts.

Measured, best-of-7 against the previous collector:

  splay          620.45ms -> 1.45ms   (428x)
  deltablue         1.25  -> 0.81     (1.55x)
  richards          1.196 -> 1.162    (1.03x)
  crypto/navier-stokes/raytrace/regexp   unchanged

  an LRU cache (200k entries, 200k ops)  32137ms -> 93ms   (345x)
  a large live cache + 500 event-loop turns  3095ms -> 776ms  (4.0x)

The trade is space: floating cyclic garbage is now a bounded fraction of the
live heap instead of a fixed candidate count, so peak RSS on
cyclic-garbage-heavy programs runs ~1.4x the old collector's. Bounded and
flat in run length, not a leak — verified by holding a 200k-object live heap
while churning 200k dead cycles per round for 30 rounds.

Test lanes show byte-identical failure sets against the previous collector:
Linux sanitized 164, Linux plain 528, macOS differential corpus 66 — all
pre-existing on those machines, none introduced or fixed here.

* runtime: bound scheduled mature cycle backlog

* runtime: rearm cycle trigger after candidate deaths
2026-08-08 11:32:45 -05:00
Chris Tate 52459a86d4 feat(compiler): lower stored text codec calls (#85)
* feat(compiler): lower stored text codec calls

- Lower same-scope const TextEncoder and TextDecoder call receivers without runtime instances.
- Preserve fences for escaping, captured, and imported codec values with actionable diagnostics.
- Add differential, diagnostic, and preflight baseline coverage for the supported idiom.

* fix(compiler): fence deferred text codec calls

* fix text codec switch-clause TDZ handling
2026-08-02 21:24:33 -05:00
Chris Tate 8a204cc7e7 fix(fetch): address remaining review regressions 2026-07-30 12:33:26 -05:00