Commit Graph
5926 Commits
Author SHA1 Message Date
Chris Tate 68ddd68210 Keep the elements of InlineArray fields in their instances (#2380) 2026-10-27 23:55:57 -05:00
Chris Tate e3f079e12b Give integer clones borrowed records and worker programs (#2450) 2026-10-27 23:50:34 -05:00
Chris Tate 5ec343312a Keep process's emitter methods as Node shows them in Node islands (#2452) 2026-10-27 23:22:26 -05:00
Chris Tate d03c4b9b57 Merge main 2026-10-27 23:16:08 -05:00
Chris Tate 82ba2ef6ed Merge main 2026-10-27 23:02:33 -05:00
Chris Tate 18a47fedd5 Run npm packages in Node islands: object handles and compiler routing (NI-4) (#1899) 2026-10-27 22:42:29 -05:00
Chris Tate 08c7b72c2d Keep process's emitter methods as Node shows them in Node islands
The island host replaced process.on, process.addListener and
process.prependListener with separate wrappers, and process.emit with its
own, as own enumerable properties of process. Island code could see the
difference: Object.keys(process) listed the four, process.on was no
longer process.addListener, prependListener was named addListener, and
each was an own property where Node inherits it.

One wrapper now serves on and addListener, and prependListener and emit
keep their names. They are defined on process's own prototype, which
Node gives process below EventEmitter.prototype, with
EventEmitter.prototype's attributes. process has no own property for
them, so Object.keys, Object.hasOwn and for...in see what they see in
Node. for...in lists a prototype's keys before its parent's, so the
keys EventEmitter.prototype lists before the wrapped ones (_events,
_eventsCount, _maxListeners, setMaxListeners, getMaxListeners) are
defined there too, with the same values, in their order.

6891 compares the identities, names, lengths, own-ness, Object.keys and
for...in over process against Node.
2026-10-27 22:33:01 -05:00
Chris Tate 590ed5ecff Keep emission's workers busy (#2451) 2026-10-27 22:27:48 -05:00
Chris Tate 93081ea679 Host the runtime's event loop on Node's libuv once Node loads (NI-3) (#1696) 2026-10-27 22:19:38 -05:00
Chris Tate 506683f16b Distribute conditional members over a generic body's bound parameter (#2258) 2026-10-27 21:56:52 -05:00
Chris Tate 9df673b23e Keep unloaded packages out of import() graphs and reject those imports (#1526) 2026-10-27 21:53:19 -05:00
Chris Tate 9e91b7d912 Merge main 2026-10-27 21:44:40 -05:00
Chris Tate 7f27866add Keep emission's workers busy 2026-10-27 21:43:36 -05:00
Chris Tate c2ebd0d4a4 Check the elements a new Set takes from InlineArray field reads
`new Set([a, b])`, where `a` and `b` are reads of the same InlineArray
field, gave a Set of size 2 where Node gives size 1: each read may give
another array, and the source proof checked Set elements only when they
were added with `add`. It now reports SC7009 when the seed of a new Set,
or the values of a Map that become a Set (`new Set(map.values())`), may
hold a field's array.
2026-10-27 21:35:51 -05:00
Chris Tate ed90c10fce Compile small release and speed programs in partitions (#2449) 2026-10-27 21:35:30 -05:00
Malte UblandClaude 5.5 c959443a80 Exercise the unary island-call fix from the corpus program
The corpus case passed `new Swapper(tricky)` straight to `+`, which the
argument check already treated as effectful, so it never distinguished
the two lowerings. Bind the swapper to a local: an identifier is what
the old check called inert, and the program now prints "replaced
replaced" without the fix and matches Node with it. The class also used
a parameter property, which Node's strip-only mode rejects.

Co-Authored-By: Claude 5.5 <noreply@anthropic.com>
2026-10-27 19:34:46 -07:00
Chris Tate 9bb4692959 Convert more structural values: class views, promise arms, index-signature records, tuple unions (#2442) 2026-10-27 21:29:07 -05:00
Chris Tate 37bdea8162 Pin constrained generic members and probe through assertions (#2443) 2026-10-27 21:27:21 -05:00
Chris Tate d4d7995d68 Treat a call that never returns as an exit in presence proofs (#2445) 2026-10-27 21:17:38 -05:00
Malte UblandClaude 5.5 7d1a7f3882 Merge origin/ni/i2-handles into the local branch
Co-Authored-By: Claude 5.5 <noreply@anthropic.com>
2026-10-27 19:15:54 -07:00
Chris Tate d97e816848 Keep integer clones off records that may be views
A checked conversion can answer a record view: an object of the target
record type whose fields live in the record it views, at that record's
offsets (record-views.ts). An integer clone read the fields of a borrowed
record at its own shape's offsets, so for a view it read the view's unused
slots and returned wrong results.

Record shapes that may be views are no longer references a clone reads, so
functions that read them keep the ordinary body, which reads a view's fields
through the original record. The emitter now plans integer clones after
record views.

integer-recursion-records.ts gains a recursive sum over a view.
2026-10-27 21:15:37 -05:00
Malte UblandClaude 5.5 4535c4f90e Merge the hosted-loop base into the handles branch
Co-Authored-By: Claude 5.5 <noreply@anthropic.com>
2026-10-27 19:14:04 -07:00
Malte UblandClaude 5.5 1ab14172c6 Keep a unary island-call argument effectful and link islands beside streams
`+x`, `-x` and `~x` convert their operand with ToNumber, which calls a
user-defined `valueOf`; treating such an argument as inert let the
lowering read the island method after the conversion ran, so the call
reached a method the conversion had replaced. Only a numeric literal
operand is inert now, and the corpus program's `valueOf` replaces the
method it is called through.

A program that uses web streams and Node islands selected one
`scr_async.c` variant by condition count, so the tie between the
one-condition variants left either SCR_NATIVE_REACTIONS or
SCR_NODE_ISLANDS undefined and the hosted-loop symbols unresolved. Add
the combined variant, with a matrix test that pins the selection for
both features together and for each alone.

Co-Authored-By: Claude 5.5 <noreply@anthropic.com>
2026-10-27 19:12:36 -07:00
Malte UblandClaude Opus 5.5 da240b72e0 Merge ni/3-hosted-loop into ni/i2-handles
Brings the island signal listener bookkeeping and migrated timer refresh
fixes into the stack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 19:08:55 -07:00
Malte UblandClaude Opus 5.5 9ad04922b2 Reject a literal import() of a module inside a rejected import graph
A module reached by an already-rejected literal import() is `covered`, but a
direct import() of that module still needs its own rejection entry: its graph
rejects when that import runs, so it must not join the compiled graph merely
because another rejected import also reaches it. Without the entry the module
is compiled and lowering fails on the unloaded binding instead of the
import() rejecting at run time as Node does.

Walk each direct root independently and extend the unloaded-dynamic-import
fixture with a direct import() of the rejected graph's dependency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 19:05:26 -07:00
Malte UblandClaude Opus 5.5 3e643fbb7c Merge origin/opt/npm-unloaded-dynamic
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 19:05:04 -07:00
Malte UblandClaude Opus 5.5 9931a36bba Absorb a top-type result in a distributed conditional member
The checker's union of `{}` (or `object`, `Object`) with a concrete result
is the top type itself, but mapDistributedConditional mapped the parts
separately and interned a union with a `dyn` arm. Emitting the member then
failed validation with SC9001 ("union ...: arm 0 is dyn"). Return the
checked-dynamic type as soon as a part maps to it, like the existing
`unknown`/`any` absorption.

Cover it in the units corpus: an `Empty<K>` member holds its mapping in a
local so the emitted union is actually exercised.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 19:04:58 -07:00
Malte UblandClaude Opus 5.5 8887f35f74 Fix island signal listener bookkeeping and migrated timer refresh
An island signal registration is now tagged with the raw listener it
installed, so a once registration and an on registration of one function
dispatch through their own listeners instead of both resolving to the plain
function, and the once registration no longer fires indefinitely. The
removal handler forgets the entry whose raw listener is no longer on
process, so a once wrapper that removes itself leaves its runtime
registration behind no longer; duplicate registrations of one function
share a raw listener, and the most recent of those is removed.

refresh() of a timer armed before Node loads re-arms at now + the delay the
timer was created with. Its Node handle was created with the remaining delay
at handoff and a due timer had no handle at all, so the handle is replaced
rather than refreshed.

The signal program registers one function once and on; a new timer program
refreshes a timer most of whose delay passed before Node loaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 19:04:26 -07:00
Chris Tate 439c485506 Represent unions of classes as the instance pointer itself (#2448) 2026-10-27 21:04:17 -05:00
Chris Tate e585024a97 Optimize the speed runtime with a committed runtime profile (#2446) 2026-10-27 21:03:29 -05:00
Chris Tate 677c74c78a Give integer clones borrowed records and worker programs
Integer clones run a pure number function on int32 values and fall back to
the ordinary body when a value leaves the int32 range. Until now a clone
could only take numbers, booleans and borrowed number arrays, and worker
programs had no clones. Recursive functions that walk a record graph, such
as a tree count, always ran on doubles.

A clone now also takes borrowed record parameters:

- A parameter qualifies when its type is a record or `R | null` for a
  record `R`, and its function borrows it.
- The clone reads number fields (exactly int32, otherwise it falls back),
  boolean fields and reference fields of those records in place, tests
  references against `null`, narrows them to the record arm (`null` falls
  back, so the ordinary body reports it), and passes them to other clones.
- A clone has no effect, so the records it reaches stay alive and unchanged
  while it runs: it reads them without retaining them.
- Fields that a clone cannot read in place (inline unions, optional
  properties, other kinds) keep the function on the ordinary path, as do
  class instances.

ELF worker executables now have clones too:

- The stack guard is the thread's own.
- A clone polls the thread's pending word, which a stop request also sets,
  when it is called and every 64 iterations of a loop over plain tail
  calls. On a set word it falls back, and its dispatcher forwards the
  pending exception or stop. Accumulating loops need no poll: their virtual
  stack bounds them.
- Worker programs on other targets keep no clones.

New corpus programs: integer-recursion-records.ts and
integer-recursion-records-workers.ts.
2026-10-27 21:02:26 -05:00
Chris Tate b1e3c46976 Convert unions with typed array, date and regexp arms to strings
String(), template literals and `+` with a string refused a union with an
object arm other than a program class or URL (SC1090). classUnionToString
now also takes typed array, Date and RegExp arms and converts each arm as
ensureString converts it alone: a typed array through its join (a Buffer
through its own toString), a date through toString, a regular expression
through its source and flags.

The npm any-chaining fixture compiles with this PR's index-signature
record conversions and then reached String() of a `URL | Uint8Array`
option in its package. It now matches Node, and its KNOWN entry is
removed.

Adds corpus program union-object-arms-to-string.ts, its corpus cost and
its preflight/order baseline.
2026-10-27 20:49:51 -05:00
Chris Tate 05810305cf Compile small release and speed programs in partitions 2026-10-27 20:49:11 -05:00
Chris Tate b2acdc90a5 Check the lowerer's dynamic import rejections like its other load inputs
The lowerer keeps LoadResult.dynamicImportRejections, the import() roots
that never load. Unit records now check its size, as they check
inlineRequireCycleCalls, so the unit journal covers it.
2026-10-27 20:48:22 -05:00
Chris Tate 6758fabe80 Evaluate computed in receivers and read getter arms in asserted probes
A statically decided `in` over a union of fixed record shapes treated
every field read as a pure receiver, so `"k" in (make().stored as R)`
folded to a constant without calling make(), and the several-arm answer
re-read the receiver once per tag test. A field read is now pure only
over a pure object (isSafeToRepeat). Any other receiver rides one tag test
when the answer is constant, and the several-arm answer evaluates it once
into a hidden local instead of refusing.

A presence probe through an assertion (`typeof (u as R).member`) answered
an arm with a getter of that name as if it lacked the member: undefined,
without running the getter. The per-arm read now calls the getter on that
arm, as Node's read does, and an arm with only a setter keeps the
assertion's checked extraction.

asserted-arm-probe.ts covers both: a receiver whose call is counted, and a
getter arm beside a data arm.
2026-10-27 20:44:33 -05:00
Chris Tate ca4a162e35 Merge main 2026-10-27 20:40:14 -05:00
Chris Tate a0494cdfa3 Keep optional-chain calls out of presence exits
A call whose checker type is never exits the statement only when the call
is made. In an optional chain (`maybe?.fail()`, `this.helper?.fail()`,
`fail?.()`), a missing receiver or callee ends the chain without making
the call, and the checker still types the call never when the chain's
base has a non-nullable declared type, as an array element read does.
Such a statement completes, so a read after it is not proven present.

exitsAbruptly now skips a call whose callee chain uses `?.`.
2026-10-27 20:38:14 -05:00
Chris Tate 1856713700 Represent unions of classes as the instance pointer itself
A union of two or more class arms and at most two unit arms (`A | B`,
`A | B | undefined`, sum types over classes) now holds the instance
pointer instead of a reference-counted %ScrUnion box, as unions of
records already do. NULL and the null sentinel encode the unit arms.

The arm of a value is the arm whose preorder interval holds the
instance's class id. On 64-bit targets, hierarchy members already keep
their class id in the high half of the rc word, or in the 32-bit header
of ProgramLifetime classes. A standalone class that is an arm of such a
union now keeps its id the same way and counts in the low half; the
count reaches the immortal all-ones value instead of wrapping, as for
hierarchy members.

Each union has a tag helper that narrowing checks inline. Unions over
the same classes share one retain, release and trace: retain and
release use the shared 32-bit count, and only a release of the last
reference dispatches on the arm to that class's release. Unions over
ProgramLifetime classes retain and release nothing. When one arm
carries a collector header, every class of every arm's hierarchy does.

Arms may not extend one another, and must all be compact or all keep
the rc word, and all be ProgramLifetime classes or none. 32-bit
targets, library builds, lifetime-region programs, debug builds, and
unions used as Map keys or Set elements keep boxes.
2026-10-27 20:30:01 -05:00
Chris Tate f662831bda Merge main 2026-10-27 20:23:37 -05:00
Chris Tate 21fa3a8ec7 Merge main 2026-10-27 20:22:19 -05:00
Malte UblandClaude 5.5 cc3ed3abf4 Merge origin/main into fix/distributed-conditional-members
Co-Authored-By: Claude 5.5 <noreply@anthropic.com>
2026-10-27 18:16:20 -07:00
Malte UblandClaude 5.5 447493b0a9 Merge origin/main into opt/npm-unloaded-dynamic
Co-Authored-By: Claude 5.5 <noreply@anthropic.com>
2026-10-27 18:16:04 -07:00
Chris Tate 95e715febd Optimize the speed runtime units with a committed runtime profile
The LLVM helper's runtime-unit now optimizes a unit itself (--opt-level),
with IR instrumentation (--profile-generate) or a profile (--profile-use),
through the same pipeline as program code. The Linux x64 pack's speed
units are compiled to unoptimized bitcode and optimized there with
packages/runtime-pack-common/profiles/linux-x64-gnu.profdata.gz, so one
LLVM writes and reads every profile. Release and library flavors are
unchanged. The pack manifest records how the profile matched the units.

Code the runtime profile finds cold is optimized for speed, not size: a
runtime function the training programs rarely call can be hot in another
program. scr_message.c is optimized without the profile.

scripts/refresh-runtime-profile.mjs trains the profile on the runtime
benchmark workloads and, optionally, a tsc-ts checkout, and keeps only the
records of functions the instrumented runtime units define
(merge-profiles --keep-functions). Tests check that the profile still
matches the runtime and names only runtime functions.
2026-10-27 20:11:44 -05:00
Chris Tate a4a844f446 Revert "Keep frozen checked records frozen, and give sloppy-mode this the global object" (#2444) 2026-10-27 20:08:07 -05:00
Chris Tate e00c08d4af Treat a call that never returns as an exit in presence proofs
presentAtUse proves that a binding read cannot be undefined when an
earlier `if` leaves only for an absent value, as in
`if (x === undefined) return;` or `throw`. A branch that calls a function
declared to return `never`, such as `if (x === undefined) fail();` or
`this.fail()`, also never completes. It did not count, so the read stayed
possibly undefined.

A function returning such a read as `string` was then taken to return
undefined too. A string[] it filled counted as holding undefined
elements, which applies to every string[] in the program, so an element
of another string[] passed to process.stdout.write failed to compile
(SC2020, "process.stdout.write of non-string data").

exitsAbruptly now counts an expression statement whose call has type
`never`. The lowerer answers that from the checker
(PresenceBindings.neverReturns).
2026-10-27 20:06:19 -05:00
Chris Tate 6d94457760 Relower units that add Node island module loads and name the island set a setting 2026-10-27 19:55:16 -05:00
Chris Tate b16c739d34 Classify zero-cost gate differences instead of failing every runtime change (#2271) 2026-10-27 19:27:25 -05:00
Chris Tate 919b79b62a Revert "Keep frozen checked records frozen, and give sloppy-mode this the global object" 2026-10-27 19:20:37 -05:00
Chris Tate 7d670f0e2a Merge main 2026-10-27 18:53:59 -05:00
Chris Tate d2595a4a70 Merge main 2026-10-27 18:49:24 -05:00