Commit Graph
4135 Commits
Author SHA1 Message Date
Chris Tate de28aeca20 Map JavaScript [] literal fields dynamically and keep union-added fields unit-only
Two JavaScript object literal mappings from #1799 broke packages.

A property initialized to `[]` has the checker type `never[]`, and never's
element maps to f64. A literal with such a property builds as a
checked-dynamic object when it lowers on its own. A literal nested in one
that maps to a record (`{ common: { issues: [] }, path: params?.path || [] }`,
zod 3's parse context) lowers against its record type, so the property was a
`number[]`. `ctx.common.issues.push(issue)` then threw "TypeError: expected
number at $, got object", where Node pushes the record. Such a property now
maps to the checked-dynamic array, as a property initialized to `undefined`
or `null` maps to the checked-dynamic value.

That `undefined`/`null` rule also matched the properties the checker adds
when it normalizes a union of literals: `{ _tag, value } | { _tag, error }`
gains an optional `error?: undefined` and `value?: undefined`. Mapping those
to the checked-dynamic value let `{ _tag, value }` fit both arms, and Effect
4's CLI parser (`consumeFlagValue`) failed with SC2003 "union conversion has
no unambiguous layout mapping". The rule now skips optional properties, so
they keep their unit-only type and each literal converts to its own arm.
2026-10-22 18:24:10 -05:00
Chris Tate e0c70c0c01 Enumerate each record in the key order its object literal wrote (#1802) 2026-10-22 18:23:26 -05:00
Chris Tate 81891d55f7 Fix boxed record field hooks and moving key writes, and merge main 2026-10-22 18:19:14 -05:00
Chris Tate 3b4a3c3cdd Write and hash the LLVM module text in slices instead of whole copies (#1878) 2026-10-22 18:16:13 -05:00
Chris Tate 0ebd2c2e4c Compile conditional spreads of several properties and (#1820) 2026-10-22 18:15:22 -05:00
Chris Tate 067be15683 Write and hash the LLVM module text in slices instead of whole copies
The native compiler wrote the module's LLVM text, 150 MB on a large
program such as tsc-ts, by encoding the whole string at once; its frontend
cache entry by first escaping the whole text into a second string and then
encoding that; and it read the written file back whole to key the object
cache. Those copies were the build's peak.

Text parts are now encoded and written in slices of at most 1 MiB UTF-16
units that never split a surrogate pair. The frontend cache entry is
generated while it is written: the LLVM text is escaped slice by slice,
which is the same JSON as escaping it whole, the entry is hashed in the
same pass, and an entry past one native string abandons its write as it
was skipped before. The object cache key hashes the file in 1 MiB blocks.
The files and cache keys are unchanged.
2026-10-22 18:12:38 -05:00
Chris Tate a0c207cc25 Merge main 2026-10-22 18:12:20 -05:00
Chris Tate b955ea3817 Give arrays state bytes only once they hold a hole or undefined (#1827) 2026-10-22 18:09:47 -05:00
Chris Tate 6fe5612e48 Merge main 2026-10-22 18:05:53 -05:00
Chris Tate 0e30dfaf87 Revert "Dispatch checked-dynamic method calls on method ids" (#1876) 2026-10-22 18:04:14 -05:00
Chris Tate dc2b238df7 Revert "Dispatch checked-dynamic method calls on method ids (#1851)" 2026-10-22 18:02:51 -05:00
Chris Tate 78c9317a2c Construct builtins through stored constructors and fix function-local class names and dispatch (#1807) 2026-10-22 17:56:42 -05:00
Chris Tate db7bd1111f Find Buffer search candidates with memchr (#1830) 2026-10-22 17:56:21 -05:00
Chris Tate a147bb5b52 Read the characters of ASCII strings in versioned scan loops as bytes (#1846) 2026-10-22 17:50:54 -05:00
Chris Tate 98712c364a Merge main 2026-10-22 17:49:58 -05:00
Chris Tate 8bc8fc54ca Bound string reads of while loops by their counter tests
With while-loop versions, `while (pos < end && s.charCodeAt(pos) === 32)
pos++` took a version whose guard could never hold. The counter scan
records only typed-array accesses, so the string read fell back to the
statically ranged check. For a counter held in an int32 slot, that check
asks for a length above 2^31 - 2. The loop paid for the guard and ran its
checked copy.

The counter scan now records `s.charCodeAt(i)` and `s.charAt(i)` of a
string like typed-array reads. Their guard compares the counter's bound
with the string's length, as for a typed array. Corpus 7302 adds while
loops over counters below a string's length.
2026-10-22 17:47:26 -05:00
Chris Tate edb2755a9b Merge main 2026-10-22 17:46:30 -05:00
Chris Tate fad298582c Move the emitter's loop optimization state into loop-state.ts (#1585) 2026-10-22 17:44:05 -05:00
Chris Tate 289a6f619d Merge main 2026-10-22 17:39:40 -05:00
Chris Tate d8d74dab97 Keep declaration order and override placeholders in record spreads (#1834) 2026-10-22 17:32:44 -05:00
Chris Tate 6132fcf7c2 Dispatch checked-dynamic method calls on method ids (#1851) 2026-10-22 17:25:35 -05:00
Chris Tate 4f6c55a8e6 Narrow filter results through written type predicates with checked conversions (#1819) 2026-10-22 17:21:41 -05:00
Chris Tate 4082dd0189 Check integer-or-NaN indexes without a double round trip (#1872) 2026-10-22 17:21:21 -05:00
Chris Tate 3b3d78f5d3 Emit function bodies on forked workers (#1852) 2026-10-22 17:21:00 -05:00
Chris Tate 5195e2b63a Merge main 2026-10-22 17:19:37 -05:00
Chris Tate 3520eaa09d Merge main 2026-10-22 17:17:27 -05:00
Chris Tate 81bf6cb0c7 Check integer-or-NaN indexes without a double round trip
An array or typed-array index that is an exact integer or NaN, such as an
element read that may miss (`t[i]!`), a `charCodeAt`, or a sum of those, is
a valid index when it is ordered and below the length. The index check now
tests that with one ordered compare and the integer, taken from the value's
32-bit view or from one conversion, instead of converting the index back to a
double and comparing it.

Number locals that are declared once with an initializer, are not captured
or boxed, and are only written such values carry the same fact, so
`const c = t[i]!; table[c]` and `(h * 31 + c) | 0` take the integer paths
that the inline read already takes.
2026-10-22 17:14:28 -05:00
Chris Tate 5f5cf8f5be Keep aliases of evolving empty arrays on the array they alias (#1812) 2026-10-22 17:12:17 -05:00
Malte Ubl 69cbdc2d94 Merge remote-tracking branch 'origin/main' into up/key-order-spreads 2026-10-22 15:11:56 -07:00
Chris Tate 5772f58cad Skip emitter analysis walks whose answers are already known (#1861) 2026-10-22 17:04:12 -05:00
Chris Tate 9b0ec269ac Select AST children by wire slot in the generated getters (#1870) 2026-10-22 17:01:35 -05:00
Chris Tate cdc7b384d4 Convert doubles below 2^63 to int32 with one conversion (#1871) 2026-10-22 17:01:09 -05:00
Chris Tate b2bb7be0b4 Support the env option of spawnSync (#1825) 2026-10-22 17:00:17 -05:00
Chris Tate 159740c685 Convert doubles below 2^63 to int32 with one conversion
ToInt32 and ToUint32 of a double that no range proves an integer took the
i64 conversion only up to 2^53 in magnitude, and decoded the double's bits
above that. Every double between 2^53 and 2^63 is an integer, so the i64
conversion is exact there too, and its low 32 bits are the result. The bit
decoding now handles only NaN, the infinities and magnitudes from 2^63.

Multiplicative hashes such as `((h ^ b) * 16777619) >>> 0` and
`(h * 1000003 + b) | 0`, whose products usually pass 2^53, convert on the
fast path.
2026-10-22 16:57:09 -05:00
Chris Tate 8bc4586b9a Select AST children by wire slot in the generated getters 2026-10-22 16:56:13 -05:00
Chris Tate 57c10fc767 Build Sets, Maps and weak collections from checked-dynamic iterables (#1856) 2026-10-22 16:53:29 -05:00
Chris Tate b03cb004ad Send an http client request's head and body in one write (#1867) 2026-10-22 16:50:41 -05:00
Chris Tate 631d4dcc30 Keep record types acyclic when only result-slot stores write their fields (#1865) 2026-10-22 16:50:21 -05:00
Chris Tate 74a958408f Compile chalk 5 and hot-shots 8 from built-in shims with callable class instances (#1836) 2026-10-22 16:49:19 -05:00
Chris Tate 9df9cfc82f Keep literal key order for records a narrowing throw arm types (#1837) 2026-10-22 16:48:21 -05:00
Chris Tate 36db0613cc Bound the compiler's cyclic garbage to twice its live heap (#1863) 2026-10-22 16:46:32 -05:00
Chris Tate 7a5fdae1bd Send an http client request's head and body in one write
request.end(body) on a request whose head was not sent yet wrote the
head and then the body. On a socket that was already connected (a
reused keep-alive connection), each write is sent at once, so the two
went out as separate segments, and the server could handle the head and
answer before the body arrived. Node sends the head together with the
body. When the client and the server run in one program, the server's
'end' and 'close' for the request and the client's reading of the
response then depended on which socket the poller reported first: corpus
5409-http-held-request-body printed the client's line before the
request's 'end' and 'close' in a macOS dev build.

The head and a body known at end() now go out as one write, as Node
sends them (the server's response already did).
2026-10-22 16:45:59 -05:00
Chris Tate fa62abce4d Keep record types acyclic when only result-slot stores write their fields
The backend gives every function that returns a complete record literal a
result-slot entry, `%into.<fn>(...params, dst)`, which stores the literal's
fields into caller frame storage. The cycle analysis counted those stores
as writes after construction, so a record type that refers to itself and
is never written after construction carried the cycle collector's header,
its live count and its candidate checks in release builds, even when
nothing called the entry. Dev builds, which add no entries, left it
acyclic.

The destination is frame storage of a caller that only projects the value
(stack-objects.ts): no object can point to it, so its fields cannot lie on
a cycle. computeCycleMutability now skips those stores, under the same
condition emit-statements.ts already uses to emit them as initializations
(resultSlotStore in the new result-slots.ts). Every other store still
makes its field mutable. The same facts mark such fields as never
replaced, so reads of them borrow instead of retaining.

A program that rebuilds a tree of 2^21 - 1 object literals 12 times runs
in 1.19 s instead of 1.35 s and peaks at 68 MB instead of 84 MB: each node
is 32 bytes instead of 40.
2026-10-22 16:45:06 -05:00
Chris Tate 5dacb5bed3 Keep running maximum and minimum updates as branches (#1826) 2026-10-22 16:42:08 -05:00
Chris Tate d7717ff1e9 Type empty array literals by their slots, and report package diagnostics accurately (#1799) 2026-10-22 16:40:40 -05:00
Chris Tate 753c64febc Test for-in key presence in the overflow map instead of a fresh key list (#1859) 2026-10-22 16:35:49 -05:00
Chris Tate bb34d61b55 Read optional elements at a proven integer index without a round trip (#1845) 2026-10-22 16:32:32 -05:00
Chris Tate ee865bcb0d Support the legacy createCipheriv modes and crypto.checkPrime/generatePrime (#1832) 2026-10-22 16:32:12 -05:00
Chris Tate 48a08dce8e Store arrays of ProgramLifetime instances in 4-byte slots on Linux (#1847) 2026-10-22 16:29:42 -05:00
Chris Tate d2408a09ad Match Node for reduce accumulators and callback arguments.length (#1828) 2026-10-22 16:27:50 -05:00