Commit Graph
3704 Commits
Author SHA1 Message Date
Chris Tate b34a769aca Match Node 24.22 cipher behavior
- chacha20-poly1305 refuses non-empty AAD once data has been processed
  (ERR_CRYPTO_INVALID_STATE); empty AAD is still accepted.
- chacha20-poly1305 decryption without setAuthTag() succeeds when no
  authTagLength was passed, and is verified when one was.
- Changing the output encoding of update() or final() throws
  ERR_INVALID_ARG_VALUE instead of ERR_INTERNAL_ASSERTION.
- The ctsMode and xtsStandard options are validated in Node's order;
  the implemented ciphers report ERR_CRYPTO_UNSUPPORTED_OPERATION.
- The list of known but unimplemented cipher names follows Node 24.22's
  getCiphers(), so the CBC-HMAC names are unknown ciphers.
2026-10-14 21:44:18 -05:00
Chris Tate 76dee28d8a Add 8-byte allocator size classes below 128 bytes 2026-10-14 21:28:04 -05:00
Chris Tate da89261676 Run V8's TimSort for comparator sorts
Array.prototype.sort and toSorted with a comparator now run V8's
TimSort (array-sort.tq) step for step in the runtime, in the generated
sort for booleans and unions with undefined, and in the checked-value
sort. The comparator is called as f(x, y) < 0 in Node's argument order,
so a comparator sees Node's calls in Node's order and an inconsistent
comparator yields Node's permutation. Undefined values, including a
union's undefined arm, are set aside before sorting and never reach the
comparator, and a checked comparator's result converts with ToNumber.
Structured inputs take fewer comparator calls than the previous merge
sort. Each thread reuses one sort buffer of up to 1 MiB.
2026-10-14 21:22:39 -05:00
Chris Tate def59ed975 Merge main 2026-10-14 21:22:07 -05:00
Chris Tate 7252e667f5 Match Node's per-architecture parseInt rounding (#993) 2026-10-14 21:19:06 -05:00
Chris Tate bd438a6d5e Add Blob and File
Blob and File (globals and node:buffer exports) compile to native
handles in the new scr_blob.c, following Node 24.22's
lib/internal/blob.js and file.js. A Blob is a window over a shared,
immutable byte store plus the byte length of each part. Sources (strings,
typed arrays, DataView, ArrayBuffer, Buffer, other Blobs, Set and Map)
convert as a Web IDL sequence, with each non-buffer part converted to a
string, before the options are read, and are copied when the Blob is
built. The constructors throw Node's Web IDL TypeErrors and its
ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE and ERR_MISSING_ARGS errors,
and read and convert their options in Node's order. The type is
lowercased, or cleared when it holds a character outside U+0020..U+007E.
endings: "native" rewrites CRLF, CR and LF to the platform's line break.
File takes its name with lone surrogates replaced and lastModified as a
number (Date.now() when absent).

slice() converts its offsets as a [Clamp] long long (rounded half to
even) and keeps the parts Node's data queue keeps. text(), bytes() and
arrayBuffer() settle on the same microtask turn as in Node, which depends
on the part count. util.inspect prints Node's `Blob { size, type }` and
`File { ..., name, lastModified }` forms, with `[Blob]` past the depth
limit. String() and toString() give the class tag, JSON.stringify gives
{}, and structuredClone returns a new Blob or File over the same bytes.
instanceof works for both spellings. stream(), textStream() and the
Object.prototype members other than toString() fail at compile time.
Non-array iterables other than Set and Map throw SC2020.

Three handle-table additions support this: a structuredClone hook, a
JSON `{}` flag, and a bracketed past-depth inspect flag. scr_blob.c is an
optional unit selected by dynAsync, because the dynamic dispatch path
boxes its reads as dyn promises through scr_async_dyn.c.

Corpus 5285-5290 and a node-types fixture check the behavior against
Node.
2026-10-14 21:17:46 -05:00
Chris Tate b3217f0650 Build Object.values natively when its result is only iterated or read
In TypeScript, Object.values over a checked-dynamic value whose result is
only iterated with for-of, indexed, or passed to every, some, findIndex,
forEach, join or reduce now returns a native vector of the checked values.
The program never observes the array itself, so the checked-dynamic array
and, for for-of, the dynamic iterator protocol are skipped. Typed records
fill the vector through their record ops table and plain data objects
from their entries in own-key order. Other uses, and JavaScript files,
keep the checked-dynamic array.
2026-10-14 21:14:09 -05:00
Chris Tate 8c3b1f9e60 Add the zlib stream classes
Deflate, Inflate, Gzip, Gunzip, DeflateRaw, InflateRaw and Unzip, from
createGzip() and the other factories or new zlib.Gzip(options), are
runtime Transform streams over zlib.

- scr_zlib.c gains a step engine that follows Node's ZlibContext: lazy
  init, Unzip's gzip-magic detection, the dictionary retry, Gunzip's
  multi-member loop, and Node's error messages, codes and errno.
- scr_zlib_stream.c, linked when a program uses zlib and streams, runs
  each write as engine steps on the worker pool with Node's output
  chunking, the finish flush from 'prefinish', read-side backpressure,
  flush(), params(), close(), reset() and bytesWritten, and validates
  options in Node's order.
- The fallback declarations add the classes, factories and a
  literal-typed ZlibConstants; zlib.constants and the module-level Z_*
  copies bake as literals. Brotli streams and their factories are refused
  by name.

Corpus programs 5370-5377 cover round trips, chunking and event order,
errors, options, flush and params, stream/promises, constants and
backpressure.
2026-10-14 21:09:51 -05:00
Chris Tate b072f22c4e Widen record parameters and returns by flow class
A record built from unchecked element reads can hold undefined in a field
the checker calls present. Such a record kept its widened layout only in
an inferred binding: an annotated parameter or return, or an unannotated
return, converted it to the declared layout with a checked narrow, which
throws a TypeError for a missing element where Node passes undefined
through.

Record values that flow between bindings and the parameters and results
of functions and methods whose every call is visible now form flow
classes. A class takes the widened layout, with the union of its members'
optional fields, when it is closed: each value entering it is a fresh
object literal or comes from a member, each use of a member reads or
writes its fields, passes it to another member or only inspects it, and
every member declares the same shape. Members then share one layout, so
no conversion runs at the boundary and the record keeps its identity.

A class that reaches other storage keeps the declared layout for every
member, including the inferred bindings and the record parameters the
analysis widened before. Converting there copied the object, so writes
through a parameter or a pushed record did not reach the caller's object;
such a literal now converts once where it is created.
2026-10-14 21:07:40 -05:00
Chris Tate 9843f8efd2 Inline interface dispatch and lend array elements to it
Interface dispatch now unboxes a receiver it has matched by key with one
load and no reference count change, and keeps its checked fallback out of
line so the key tests inline at each call site. A loop over an array of
interface values lends each element to a dispatch whose implementing
methods cannot release it; the fallback, which can run any code, takes
its own reference to the receiver.
2026-10-14 21:06:15 -05:00
Chris Tate 8b89cb0aee Define new runtime globals with initializers so library localization hides them (#992) 2026-10-14 21:04:33 -05:00
Chris Tate 7e8fee8457 Regenerate the Node compatibility artifacts 2026-10-14 21:01:27 -05:00
Chris Tate b5cb8b397a Add the Readable operators, the Readable.from options and stream.compose
The Readable operators (map, filter, forEach, toArray, some, find, every,
flatMap, drop, take, reduce) run over string and Buffer chunk streams with
Node's ordering, errors, and concurrency, highWaterMark and signal options.
Readable.from reads arrays lazily and accepts the objectMode and
highWaterMark options, and its JavaScript form follows from.js's checks.
stream.compose returns a Duplex over a pipeline of stream instances.

pipeline now follows pipeline.js: per-stream destroyers and eos watchers,
and the callback on a tick once every watcher finished. 'finish' waits for
a pending _final or _flush callback, and a failed synchronous write emits
'error' one tick later, as in Node.
2026-10-14 20:58:41 -05:00
Chris Tate 1cb9d2201f Match typed JSON.parse member names against the text and read scalar members inline
The schema reader scanned every member name with the general string scan,
compared it with memcmp, and re-entered the recursive reader for every
value. The expected next member's name is now compared directly against
the text and its closing quote when the name has at most eight bytes and
none that JSON text escapes; other keys keep the general scan and compare
names with scr_key_equal. Number, boolean and string members and elements
are read in the record and array loops; records and arrays still recurse.
2026-10-14 20:38:52 -05:00
Chris Tate 7dfe4e8bea Merge main and update test fixtures for the cipher link feature
The native link feature records in the self-hosting tests list cipher,
and the library profile test uses crypto.createSign for its remediation
example now that createCipheriv is supported.
2026-10-14 20:31:47 -05:00
Chris Tate 93720d1f9e Run the Mach-O library and arm64 string oracle tests in the pull request macOS suite
The pull request macOS lane runs the darwin suite: the differential corpus
plus every file whose assertions take darwin-specific branches. The library
suites (library-multi, library-callbacks, library-dispatch) take the Mach-O
localization and link arms on darwin, and the runtime string oracle checks
the arm64 parseInt answers, but none of them were in the list, so changes
that broke them on macOS reached main before a macOS run saw them. Add the
four files to darwinFiles.
2026-10-14 19:58:19 -05:00
Chris Tate abd77dfcf3 Match Node's per-architecture parseInt rounding and record both answers in the string oracle
For radixes other than 2, 4, 8, 10, 16 and 32, V8 folds each 32-bit digit
chunk with `value * multiplier + part`. Node's arm64 builds fuse that
multiply-add into one rounding and its x64 builds round twice, so long
inputs such as parseInt("9007199254740993", 36) answer
1.9896986116031812e+24 on arm64 and 1.9896986116031807e+24 on x64. The
runtime followed the same split only through the C compiler's default
contraction, and the committed string oracle held one architecture's
answers: regenerating it on x64 replaced the two arm64 values, failing the
string oracle tests on macOS arm64.

scr_radix_fold now writes out each form: fma() on aarch64, and an unfused
multiply and add with contraction disabled elsewhere, so the result matches
the same architecture's Node under any contraction setting. The generator
records the architecture-dependent cases once per architecture
("parseInt.arm64" / "parseInt.x64") from a listed table and checks the
current machine's answer against Node, so the committed file is the same
whichever machine generates it. The C harness runs the cases for the
architecture it was built for.
2026-10-14 19:57:00 -05:00
Chris Tate 9621b895ce Define new runtime globals with initializers so library localization hides them
scr_cyc_types, scr_str_scan and scr_wtf8_lone were tentative definitions.
The macOS runtime build emits tentative definitions as COMMON symbols, and
Mach-O `ld -r` writes COMMON symbols back out as commons, which
-exported_symbols_list does not demote. Every runtime-localized library
archive therefore defined them next to its declared API, failing the
library-multi M1 and M7 symbol checks on macOS. Linux clang defaults to
-fno-common, so the same declarations were ordinary definitions there and
the checks passed.

Initialize the three globals explicitly, as scr_sa and
scr_stdio_write_hook already are, and add a runtime test that compiles
every runtime source with -fcommon in the plain and worker configurations
and expects no COMMON symbols, so a new tentative definition fails on
Linux too.
2026-10-14 19:48:01 -05:00
Chris Tate f6e9fbe056 Support subclassing EventTarget and Event (#988) 2026-10-14 18:57:20 -05:00
Chris Tate cfe28b7ad1 Move scriptc to Node 24.22.0 (#989) 2026-10-14 18:49:17 -05:00
Chris Tate bb24a37329 Write typed JSON.stringify arrays from their slots and append fixed text inline (#991) 2026-10-14 18:39:51 -05:00
Chris Tate b710e74acb Lower value-position writes to the writable Event accessors
Assignments to returnValue and cancelBubble on a typed Event subclass
receiver lower in value position as well as in statements: an
initializer (`const r = (ev.returnValue = false)`), a call argument, and
a chained assignment write the accessor through event.set and yield the
assigned value. The short-circuit forms (&&=, ||=, ??=) read the
accessor through event.get and write it only on the branch that assigns.
The receiver now evaluates before the assigned value, as in Node.
2026-10-14 18:25:05 -05:00
Chris Tate 2519c79617 Store arrays of interface values natively and read interface fields directly (#990) 2026-10-14 18:18:33 -05:00
Chris Tate f7390b4f05 Match Node 24.22 HTTP write coalescing, fetch connection headers and crypto.constants
OutgoingMessage now corks the message for a tick like Node 24.22, so
chunked writes in one tick (and a corked end(chunk)) go out as one chunk,
for server responses and client requests. Fetch accepts a connection
header that is a comma list of tokens, as Undici 7.29.1 does. The
crypto.constants declaration matches the Node 24.22 table, with a pin test.
2026-10-14 18:12:09 -05:00
Chris Tate d2a84e4a41 Write typed JSON.stringify arrays from their slots and append fixed text inline
The emitted JSON writers read each array element through scr_arr_state
and scr_arr_get_ref, retaining and releasing it, and appended every
bracket, comma and key through a runtime call. Arrays whose indices below
the length all hold values now serialize from their slots
(scr_arr_dense_slots) with borrowed elements; other arrays keep the
element walk. Fixed text is stored inline when it fits the buffer's spare
capacity, booleans write their literal inline, and numbers are formatted
directly into the buffer.
2026-10-14 18:05:50 -05:00
Chris Tate 022ac6eba9 Store arrays of interface values natively and read interface fields directly
Arrays whose elements are class-backed interface values are native arrays
of the element capsules, so iteration, indexing and most array methods no
longer go through the checked-dynamic array, and method calls receive a
receiver they can dispatch. Methods without a native form for these
elements run on the array's live dynamic view.

A read of an interface property signature has the property's static type
and reads the field of an implementing class directly. Accessors, object
literals and JavaScript classes keep the checked property read.
2026-10-14 17:38:02 -05:00
Chris Tate 9835ad0d75 Move scriptc to Node 24.22.0
Pin Node v24.22.0 (commit f14cd3aa7bf9, Undici 7.29.1, OpenSSL 3.5.8) in
.node-version, Dockerfile.sandbox, the docs matrix fallback, the
compatibility pin, the fetch profile, and process.version. A node-pin test
checks that these pins agree. The Node compatibility snapshot is
regenerated from the v24.22.0 API docs; the new stream_iter chapter maps
to node:stream/iter, and the SuiteContext rows no longer match the
TestContext evidence.

Runtime and compiler changes follow Node 24.22 behavior:

- fs.read, fs.readSync, and FileHandle.read validate the position before
  the zero-length return.
- fs.statfs results include frsize; Windows reads
  FileFsFullSizeInformation and reports bfree and bavail separately.
- fs.utimes, futimes, and lutimes keep nanosecond precision.
- ServerResponse sets writableFinished where 'finish' is emitted and runs
  end() callbacks before the 'finish' listeners while the socket is still
  attached; a request read to 'end' closes before its response.
- socket.write(string, 'buffer') throws ERR_UNKNOWN_ENCODING.
- URL protocol-setter rejections keep the current URL, the host setter
  no longer leaves a "/." escape when it adds a port to a "//" path, and
  new URLSearchParams(null) parses "null".
- util.stripVTControlCharacters uses Node 24.22's ANSI pattern,
  util.styleText accepts #RGB and #RRGGBB colors, and
  util.types.isDataView has its JS name and length.
- structuredClone and AbortSignal.any use the "cannot be converted to
  sequence" message.
- crypto.getCiphers, getHashes, and constants match Node 24.22.
- dns.lookup, net.connect, and tls.connect throw ERR_INVALID_ARG_VALUE for
  hosts with null bytes.
- fs.readFile validates options.buffer and refuses its valid forms;
  httpValidation and certificateCompression refuse by name.
- url.domainToASCII, url.domainToUnicode, and url.parse hostnames follow
  ada 4.0: ASCII domains are lowercased without checking their xn--
  labels, the RFC 5893 rule checks how LTR labels end and how RTL labels
  start, a Punycode label whose decoded form begins with "xn--" fails, and
  ToUnicode decodes only labels that pass the ToASCII checks. The url
  legacy test cases are regenerated with Node 24.22.

Corpus programs 5275-5279 cover the new behavior. 1640, 2283, 2599, and
3136 are updated where they pinned Node 24.15 output.
2026-10-14 17:27:02 -05:00
Chris Tate 30e291a341 Support subclassing EventTarget and Event
Typed and JavaScript classes can extend the global EventTarget and Event.
%EventTarget and %Event are runtime-provided hierarchy roots like the
EventEmitter: a subclass instance embeds a prefix pointing at the engine
state that super() creates (the target's listener core, the event's
state), and the backend's emitter prefix handling becomes a table of
runtime prefixes that covers all three bases.

The instances' checked-dynamic capsules use the runtime RC adapters, so
the engine recognizes them: a target instance is its listeners' `this`
and its events' target, and an Event subclass instance is the event its
listeners receive, with its own fields and methods. The inherited
methods and accessors lower directly on typed receivers (including
super.dispatchEvent) and answer through the class property dispatch and
the runtime's capsule hooks for checked-dynamic values, with Node's
util.inspect output, @@toStringTag and leak-warning class name. Members
read as values are the prototype's functions, also for plain handles.

A target keeps its own capsule in its state, so repeated dispatches reuse
it; the state and an event's target are traced, so the collector
reclaims targets whose listeners capture them. Subclass members that
spell an inherited member are refused, since the engine would never call
or read them.

Listener objects that are class instances now work: when a program can
register EventTarget listeners and declares a class with a handleEvent
method, %main installs a compiled `listener.handleEvent` reader that the
engine uses at every dispatch, so the class's own, inherited or
overridden method runs with the instance as `this`, as in Node. An
unannotated arrow in an object literal whose contextual type maps to a
checked-dynamic slot or to no lowered type (an EventTarget subclass's
listener union) no longer adopts the void callback slot's return type,
so `{ handleEvent: (e) => n++ }` passed as a listener keeps the result
its record field promises.
2026-10-14 17:18:04 -05:00
Chris Tate 99386913c4 Inline Map/Set iteration steps and skip deleted leading entries (#987) 2026-10-14 17:01:30 -05:00
Chris Tate c43ff734fa Merge main 2026-10-14 17:00:49 -05:00
Chris Tate 90c035adee Add readline/promises, stream.addAbortSignal and the stream/promises options (#983) 2026-10-14 16:11:25 -05:00
Chris Tate 62900f535b Make typed record to unknown conversions cheaper (#984) 2026-10-14 15:59:49 -05:00
Chris Tate 766b564659 Inline Map/Set iteration steps and skip deleted leading entries 2026-10-14 15:17:21 -05:00
Chris Tate c9fe456a96 Support crypto.createCipheriv and createDecipheriv 2026-10-14 15:14:14 -05:00
Chris Tate ed55fa44d8 Make typed record to unknown conversions cheaper 2026-10-14 14:11:58 -05:00
Chris Tate 63012c09b1 Add readline/promises, stream.addAbortSignal and the stream/promises options 2026-10-14 14:10:43 -05:00
Chris Tate f7a9887709 Add process.memoryUsage, process identity members, and performance marks and measures (#977) 2026-10-14 13:57:47 -05:00
Chris Tate 57a29caaf9 Store scalar-union fields inline in records and objects (#982) 2026-10-14 13:37:52 -05:00
Chris Tate 397290579e Expand dynamic spreads into checked performance argument arrays 2026-10-14 13:16:30 -05:00
Chris Tate f3ace69760 Store scalar-union fields inline in records and objects 2026-10-14 13:02:38 -05:00
Chris Tate f951af1e8f Merge main into process and perf_hooks 2026-10-14 12:46:19 -05:00
Chris Tate 47223bdfaa Use plain wording in docs, comments and test names (#981) 2026-10-14 12:25:43 -05:00
Chris Tate d25fa587ae Add the legacy url API and url.domainToASCII/domainToUnicode (#973) 2026-10-14 12:08:16 -05:00
Chris Tate 5cb25cfcde Lower typed-array sort and toSorted (#980) 2026-10-14 11:48:27 -05:00
Chris Tate 3f8e0bcb13 Use plain wording in docs, comments and test names 2026-10-14 11:43:44 -05:00
Chris Tate 5ef650b5e7 Merge main into the legacy url API 2026-10-14 11:30:47 -05:00
Chris Tate a93c7f4400 Call class methods directly through interfaces (#974) 2026-10-14 11:24:50 -05:00
Chris Tate 23124ccdb0 Lower typed-array sort and toSorted 2026-10-14 11:15:37 -05:00
Chris Tate c7439a179e Read interface methods before arguments another function can assign 2026-10-14 10:55:08 -05:00
Chris Tate 86f77c88e9 Add process.memoryUsage, process identity members, and performance marks and measures 2026-10-14 09:58:18 -05:00