Commit graph

58 commits

Author SHA1 Message Date
kommander
0a8fd7250b test(codemode): regenerate the Linux-only libm cases through the language runtime 2026-11-19 01:22:22 +00:00
Sebastian Herrlinger
1d250bc759 test(codemode): record the conformance cases through the reference's language runtime 2026-11-19 01:53:45 +01:00
Sebastian Herrlinger
3cf39e761d test(codemode): record unsupported syntax at run time and acorn's parse errors from the reference
Programs in frames/core.ts record, with message and location, unsupported syntax that
runs or is never reached (classes, with, debugger, new.target, import.meta, super,
nested exports), the bindings it hides, using declarations, nested imports, names
located inside parentheses, and parse errors in acorn's words; a suspension reaches
unsupported syntax after resuming. New cases record values around it, and the api
test checks the suggestion, which the recordings do not capture. streaming.json is
to be regenerated at integration.
2026-11-19 00:28:20 +01:00
Sebastian Herrlinger
fcc9ebcd46 test(codemode): record unknown-tool suggestions and regenerate the streaming recording 2026-11-18 23:55:55 +01:00
Sebastian Herrlinger
93abe8d1e5 fix(codemode): let then name a namespace path, and never take a namespace as a thenable
Reading then from a namespace gave undefined, so awaiting one could not
mistake it for a thenable and call a tool. The reference reads it as a
path like any other (typeof tools.then is "function") and never takes a
namespace as a thenable. Rust now does both: the read gives the path, and
resolving a promise with a namespace, or crossing one, doesn't look for
then.

Recorded: boundary-namespace-then.
2026-11-18 23:50:22 +01:00
Sebastian Herrlinger
a0ab788627 fix(codemode): refuse calling the namespace itself and hide an uncaught value that isn't data
Left over from the boundary sweep, outside its files: tools() fails with
tools is not a function, delete with a number or symbol key on a
namespace fails as reading one does, and a thrown value that holds a
function, a promise, a namespace or a built-in object, at any depth,
fails as Uncaught: a non-data value, as the reference's
containsRuntimeReference has it.

Recorded: boundary-namespace-calls and six uncaught values.
2026-11-18 23:11:59 +01:00
Sebastian Herrlinger
9e87d3b91a fix(codemode): check prototype method receivers and arguments in the reference's order
Headers and URLSearchParams methods count their arguments before they check their receiver; Uint8Array.set reads
its offset as a number before its source; Number.prototype methods name themselves ("Number.prototype.toFixed
requires that 'this' be a Number."); Array.with words an index out of range as the reference does. A namespace is
no callable receiver for Function.prototype.call, apply and bind (Rust called the tool), no argument list for apply
(which words any other non-object the reference's way), and no Set-like object for the Set methods.
Object.prototype.toLocaleString refuses a symbol as it refuses null, since neither has a prototype to look in.
2026-11-18 23:05:06 +01:00
Sebastian Herrlinger
9f4fca2982 fix(codemode): refuse built-in inputs as the reference does
Built-ins given a namespace, a promise or a primitive where they need something else now fail with the reference's
words: new Map, Set, WeakMap and WeakSet, Object.groupBy and the other prelude loops over a value with no iterator
fail InvalidData "for...of requires an iterable value, received <a Date>.", naming the value as describeValue does
(also in the for...of statement, which said "an object" for a Date, a RegExp or a URL). Array.from, Iterator.from,
String.raw and new Promise take no namespace, which is no object; Object.isFrozen, isSealed and isExtensible answer
for it as for a primitive; Object(...) and new Number, String and Boolean word their refusals as the reference does,
and String.fromCodePoint words an invalid code point as the reference's host. A combinator's rejection for an input
it cannot iterate points at its call, as the reference's does.

Records cases for these and for the member writes, deletes, in and instanceof of the earlier commit.
2026-11-18 23:05:06 +01:00
Sebastian Herrlinger
f2eb1ac29f fix(codemode): word the two symbols as the reference's host does
The reference's symbols are its host's, described "codemode.iterator" and "codemode.async-iterator". Where its
host's String makes a symbol text (String(s), a template literal, join, the String methods' arguments, an Error
message), it reads "Symbol(codemode.iterator)"; Rust threw "Cannot convert a Symbol value to a string" or wrote
"Symbol(Symbol.iterator)". The host's + still refuses ("Cannot convert a symbol to a string"), ToNumber words its
refusal "Cannot convert a symbol to a number", Object.prototype.toString gives "[object Object]", JSON.stringify
writes a symbol as an object with no fields, as the reference's walk with a replacer already did, and an uncaught
symbol names itself the same way.
2026-11-18 23:05:06 +01:00
Sebastian Herrlinger
1bfc8f666d fix(codemode): read namespace paths and nullish bases as the reference does
A namespace path takes string names only: a number or a symbol key fails "tools paths must use string property
names.", where Rust read undefined or a path named by the number. Object.keys and for...in of a path that names
neither a tool nor a namespace fail with the reference's UnknownTool "Unknown tool namespace '<path>'." instead of
listing nothing.

A computed member write on null or undefined fails as the read the reference resolves it with, and an object key in
that message is made without calling the program ("[object Object]"), as the reference's coerceToString makes it.
Promise.prototype.then, catch and finally name themselves and the receiver they refuse, and new URLSearchParams
words a symbol as the reference does.
2026-11-18 23:05:06 +01:00
Sebastian Herrlinger
84d9ab3f47 fix(codemode): take enumeration sources and property bases as the reference does
Object.keys, values, entries, assign and hasOwn, for...in, object spread and object rest read their source through
the reference's enumerableSource: null and undefined fail "<label> cannot convert null to an object.", a promise
fails InvalidData "<label> received an un-awaited Promise; ..." and a namespace InvalidData "<label> cannot read
tools: it is a namespace of host functions, not plain data. ...", except that Object.keys and for...in list a
namespace's names. Rust gave V8's message, and enumerated a promise or a namespace as empty. Object.assign names the
target it refuses, sets fields on a promise as they are, and a string source reads as its characters (so it owns
length); Object.getPrototypeOf and Object.create word their failures as the reference does.

Destructuring null or undefined no longer quotes the value. A member assignment on null or undefined fails as the
read the reference resolves it with, on a primitive names the value, and a symbol has no properties to read, write or
delete. `in` checks its right side before it converts its key, and fails for a namespace or another opaque operand as
the binary operators do; instanceof is false for a namespace and words its failures as the reference does.

The spread and rest checks run inside one out-of-line call each, as the copy before them did: a second call in those
arms of the run loop cost numeric-loop 1% of its instructions.
2026-11-18 23:00:42 +01:00
Sebastian Herrlinger
a56513f977 fix(codemode): reject String method arguments that are still not data
The reference's String methods read each argument through requireDataArgument once the receiver and the arguments
converted: one that is still a promise or a namespace fails with InvalidData "String.<name> expects argument <n> to
be a data value.", in the order the method reads its arguments (padStart checks its length before its fill, split
its limit before its separator, replace its pattern before its replacement). Rust read a promise as
"[object Promise]" and threw for a namespace.

A receiver of null or undefined now names the method ("String.prototype.trim called on null or undefined."), and
split tells a missing separator from one that converts to undefined by the argument, as the reference does.
2026-11-18 23:00:42 +01:00
Sebastian Herrlinger
a31e7f534d fix(codemode): convert a namespace or a promise without calling its methods
The reference keeps its namespace references outside its objects, so a built-in that converts one reads the text
"[object Object]" (NaN as a number) without a call and without a conversion request of its own; Rust threw
"Cannot convert object to primitive value." for String(tools), [1, 2].join(tools), Math.max(tools) and the like.
Its $vmToPrimitive also keeps a promise as it is, spending only its own unit, so that what reads it can reject it as
an un-awaited value; Rust called the promise's toString and valueOf.

primitive_of now returns both unchanged, number_of and string_of give their text and NaN, and a list of conversions
counts neither as an object to convert. A property key made from either is its text: key_of looped forever on one
before (const { [tools]: a } = {} overflowed the stack).
2026-11-18 23:00:42 +01:00
Sebastian Herrlinger
b97c413f60 fix(codemode): match the reference's callback rules and messages in built-ins
Found while reading the rebase's recordings; none of these were recorded
before, and the pre-rebase reference behaves the same except where noted.

- Callback sites (array methods, sort, then/catch/finally, replace and
  replaceAll, JSON.parse's reviver and JSON.stringify's replacer) admit
  what the reference's isSupportedCallback does: not the Promise statics
  or Symbol (marked NOT_CALLBACK), nor a namespace reference, each refused
  with the site's wording. The hint now says (value) => fn(value), as on
  dev.
- Symbol says it isn't callable, and new Symbol() asks for a call.
- Array.prototype methods on a receiver that isn't an array name themselves
  and what they got.
- JSON.parse fails with its host runtime's message after the reference's
  prefix, from the parser Response.json already used.
- Assigning to a namespace says only data fields may be assigned; a
  namespace is described as a namespace reference, and the un-awaited
  promise hint names load(...), as on dev.

Recorded: std-callback-admission, std-json-parse-errors and
std-array-receivers.
2026-11-18 21:55:08 +01:00
Sebastian Herrlinger
e941709ea3 test(codemode): mirror the reference's host-call argument tests
tools.rs mirrors codemode.test.ts: a tool's arguments leave a function (a
toJSON included) out and await a promise, pending ones too, and a rejection
fails the call before the tool runs. extensions.rs mirrors extensions.test.ts
and language.test.ts: a host function from a result arrives back as itself
wherever it sits, a program function or a global's function is left out, a
promise that never settles waits until the timeout, and a result holding
functions is handed to a tool as its data. The host-args-promise case mirrors
promise.test.ts: a tool's promise inside another call's arguments is awaited.
2026-11-18 21:29:00 +01:00
Sebastian Herrlinger
462f1b82c8 test(codemode): regenerate the recordings from the rebased reference
The reference now carries dev's changes: tool and search arguments cross
through the host-call path (functions dropped, promises awaited, toJSON
not called), imports that can't resolve say why, namespace references are
no longer called tool references, extension arguments are passed to the
host, and an un-awaited promise's hint names load(...). The suspension
that started tools.wait inside a toJSON in tool arguments is removed: the
reference no longer calls that toJSON, so the wait never starts.

The Rust side follows in the commits after this one.
2026-11-18 20:50:32 +01:00
Sebastian Herrlinger
d507a5971a test(codemode): record the call depth limit and its RangeError
The deepest level and the error there, with one frame per level (plain,
method, call, apply, generator, async, and built-ins calling the
recursing function back: map, forEach, toString, replace, toJSON,
Array.from, reduce, sort), two frames and three, probed from the
program's top level; exactly the limit succeeding while one more level
fails; and the uncaught RangeError with its location.
2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
88e9f8d5e3 test(codemode): check libm-dependent pow and hypot cases on Linux only 2026-11-18 18:56:12 +01:00
Sebastian Herrlinger
36a9080b98 fix(codemode): enter promise handlers at the reference's cost
The reference enters a promise reaction's handler, a finally cleanup, a
thenable job's then, an executor and a Promise.try callback without a call
(enterSettlingCall): a plain function's frame costs nothing beyond the job,
and a promise's resolve function nothing; anything else goes through
$vmSettleCall, so an async or generator function costs a call and a native
fifty. Rust charged every closure a call and every native nothing, so a busy
loop through rejected tool calls, or any then, refilled fuel at another step.
Promise.try spends its fifty before the callback runs, as the native returns
first.

A finally cleanup's outcome now passes through one more promise, a job
later, as the reference chains finallyCleaned and finallyOutcome.

Recorded: busy loops through invalid and failing tool calls, an unknown
tool, and each kind of handler, and the order of finally against other jobs.
2026-11-18 18:56:12 +01:00
Sebastian Herrlinger
a7f1c106a1 fix(codemode): JSON.stringify stops at the reference's depths
The reference's native stringify throws past depth 32 and its internal walk, with a replacer or a property list, past 100, a primitive included: RangeError "Value exceeds the maximum depth of N.". Rust allowed 512. Recorded in the std-json-stringify-depth case and a busy loop of failing walks.
2026-11-18 18:56:12 +01:00
kommander
54f0d1e41a feat(codemode): hold huge sparse arrays
The reference keeps an array's elements in a host JavaScript array, which
JavaScriptCore stores sparsely, so a[4294967294] = x works and makes the
length 4294967295. Here a write that far failed with 'Invalid array length'.

An array now turns sparse when a write lands past the longest dense array
(MAX_ARRAY_LEN): its items keep the dense prefix, the SPARSE object flag is
set, and its other elements and its length are its own properties, so
snapshots and reachability carry them unchanged. Element reads and writes,
in, hasOwnProperty, delete, keys, for-in, length (which makes it dense again
once short enough), push, pop, at, slice, includes, indexOf and lastIndexOf
work on it as in the reference, and the callback methods, reduce, flat and
flatMap visit only the elements it holds. Code that walks every element
makes the array dense first and fails with the reference's errors when it
is too long ('Invalid array length', 'Out of memory' for sort), where the
reference either fails or runs on for minutes. Logs show its first
elements. Arrays at most MAX_ARRAY_LEN long, every one the benchmarks make
among them, stay dense and take the same paths as before.

Setting length out of range and spreading too many values now say
'Invalid array length' without a period, as the reference does. Touches
object.rs (SPARSE), ops.rs (element and length paths, define, iteration),
convert.rs, host.rs, web.rs (structured clone), object.rs, buffer.rs.

The last nine test262 files leave rust-skipped.txt, which is now empty.
2026-11-18 18:56:11 +01:00
kommander
3d0b1a1c61 fix(codemode): a program may name things await and still await at the top level
When the script reparse cannot be used because the program also awaits at the top level, the awaits the reference reads as names (bindings, names inside non-async functions, escaped labels; never inside an async function's parameters or body) are renamed for the module parse to a same-length identifier the source lacks, which compiles as await again. Top-level arrow parameters named await are rejected, as the reference reads them as an expression first.
2026-11-18 18:56:11 +01:00
kommander
a302fac828 fix(codemode): iterator helpers name the call that made a record whose next is not a function
Like the reference, stepping an iterator whose next is not a function fails with "<callee> is not a function.", naming the call that made the record: Iterator.from(...) or helpers.map(...) for a helper, which keeps the name (snapshots included), and the running call for toArray, reduce and the other eager methods. An inner flatMap iterator is "The called value".
2026-11-18 18:56:11 +01:00
kommander
6c2724c58f fix(codemode): new Map and Object.fromEntries reject a non-entry as the reference does
Both read their input as iteration yields it, reject an entry that is not an object (Object.fromEntries also one holding an opaque reference) with the reference's message, and close the iterator first.
2026-11-18 18:56:11 +01:00
kommander
e10ecb8811 fix(codemode): read 2^32 - 1 and above on an array as plain keys
An array's numeric read took any integer as an element index, so a[2 ** 32 -
1], which is stored as a plain property, read through to the prototypes
and came back undefined. Only indexes below 2^32 - 1 are elements, as the
writes already knew. Touches ops.rs (get_elem).

Two test262 files leave rust-skipped.txt.
2026-11-18 18:56:11 +01:00
kommander
d1cffe8e14 fix(codemode): word RegExp syntax errors as the reference's host does
new RegExp reported regress's errors ('Unbalanced parenthesis'), and
regress accepts a few patterns JavaScriptCore rejects, such as \b* outside
the unicode flags. The new regexp_syntax module ports the error checks of
JavaScriptCore's YarrParser as Bun ships it (escapes, classes, v-mode class
sets and string disjunctions, groups and modifiers, quantifiers, named and
numbered references with the legacy reparse), and finds the first error in
the order that parser meets it, with its message ('missing )', 'nothing to
repeat'). regress answers the Unicode questions: property names and the
characters of group names. A random sample of 9,000 patterns over the three
flag modes matches the reference's validity and message for every one.

It also covers \k inside a class with named groups, which the duplicate
named groups rewrite used to check.
2026-11-18 18:56:11 +01:00
kommander
d0ea5e8e79 feat(codemode): keep lone surrogates in strings
Strings are UTF-8, which cannot hold a lone surrogate, so every one became
U+FFFD: '\ud800' === '\udc00' was true and s[0] + s.slice(1) lost the pair.
A string that is not well-formed UTF-16 now keeps its code units behind a
flag (Strings::wtf), and its text is a canonical carrier: UTF-8 in which
each lone surrogate is U+10FFFF followed by a private-use character that
encodes it, and a real U+10FFFF is doubled. Text equality stays string
equality, so comparisons, Map and Set keys and property keys need nothing
new, and every allocation decodes the carrier, so a high and a low
surrogate brought together by concatenation, repeat, padding or
replacement become their character.

Code that counts or cuts code units reads them through StrRef (length,
charCodeAt, slice, comparison, search, split); iteration, String.raw,
fromCharCode, JSON.parse escapes, literals and regex matches produce lone
surrogates; JSON.stringify and RegExp.escape write them as \u escapes;
isWellFormed, toWellFormed, encodeURI (URIError, with the reference's
message) and localeCompare see them. localeCompare weighs them as the
reference's ICU does, where ICU4X would weigh them as U+FFFD. URL,
URLSearchParams, TextEncoder and Buffer's UTF-8 take USVStrings, so a lone
surrogate becomes U+FFFD there, as in the reference; Buffer's latin1 and
utf16le take the code units.

At the host boundary the reference hands its strings over as they are; a
Rust host value is UTF-8, so results, tool arguments, logs and diagnostics
carry U+FFFD for a lone surrogate, the bytes the reference's own
TextEncoder writes for them. Text from the host has a real U+10FFFF
doubled on the way in. Snapshots save the carrier and restore it exactly.

Instructions (5 iterations) stay within 0.1% on all nine programs; JSON
round-trip 1922M -> 1923M, Map/Set 1021M -> 1017M, string building
717M -> 713M. Touches strings.rs, compiler.rs (literals), convert.rs
(JSON, host values), host.rs (host values), ops.rs (string iteration),
run.rs (diagnostics) and vm.rs (char_str).

Eight test262 files leave rust-skipped.txt.
2026-11-18 18:56:11 +01:00
kommander
2c721e5b69 feat(codemode): collate localeCompare like the reference's host
localeCompare used a case-folding heuristic that disagreed with the
reference on 634 of 4,841 sampled pairs (accents, punctuation, canonical
equivalence, scripts). It now uses ICU4X's root collation, which the
reference's host uses for its en-US default, and agrees on all of them.

Dependency: icu_collator 2.4 with compiled data (pure Rust, Unicode's
ICU4X). It adds 1,247,048 bytes to the stripped embed example
(4,785,968 -> 6,033,016; bench/RESULTS.md (d) updated); nearly all of that is the root collation table,
so generating data for the root locale alone saves under 1 KB.
2026-11-18 18:56:11 +01:00
kommander
493240ee71 fix(codemode): match the reference's Array methods on frozen arrays, callbacks and iteration
Mutating Array methods run the reference's check of what their first write
would hit: adding to a non-extensible array, deleting from a sealed one, or
writing a frozen one each fail with the reference's message, sealed arrays
no longer pop or shift, and reverse leaves a frozen array of fewer than two
items alone. sort checks its comparator first and leaves the array as it
was when the comparator throws; it used to empty it.

Callback methods of Array, Map, Set and Uint8Array.sort name themselves in
the reference's 'Array.map expects a function callback.' forEach, map,
filter, some, every, flatMap and reduceRight skip indexes a callback cut
off by shrinking the array, and includes and indexOf on an empty array
return before converting fromIndex.

Array.from checks its mapper first, maps an iterable as it reads it and
closes the iterator when the mapper throws (an endless iterator ran out of
memory), and rejects primitives and promises. Object.fromEntries reads its
entries one at a time, closes the iterator on a bad entry, and accepts only
entries without opaque references, like the reference. Array.prototype is
an array, and an arguments object is never frozen merely by being
non-extensible.

On top of the array holes: mutating methods check mutability once (push
returns at once for an array with no such flags), and an index read past an
array's end or at a hole finds Array.prototype's own items, which store an
index without interning it. Touches ops.rs (inherited_elem).
2026-11-18 18:56:11 +01:00
kommander
29915a5310 fix(codemode): assigning undefined fails like assigning a constant
As in the reference, `undefined = 12` and its compound, logical and destructuring forms throw "Cannot assign to constant 'undefined'." instead of a ReferenceError.

language/global-code/import.js fails in the reference as it does here (a relative import throws when it runs instead of a parse error), so it moves from rust-skipped.txt to the reference's skipped.txt.
2026-11-18 18:56:10 +01:00
kommander
19bfb0df7a fix(codemode): name the callee in call errors, as the reference does
Calling or constructing what cannot be now says "o.f is not a function.", "f(...) is not a constructor." or "The called value is not a function.", named from the call expression like native engines. Each function keeps its call sites' callee names for the error path only. Function.prototype.call, apply and bind name an incompatible receiver, and the callback methods of Array, Uint8Array, Map, Set and Promise use the reference's messages.
2026-11-18 18:56:10 +01:00
kommander
03066b4ba3 fix(codemode): delete, arguments, await names and iterator errors match the reference
- delete: optional and parenthesized targets delete; an identifier fails when it runs; built-in constants and prototypes refuse; a function's name and length can be deleted; strings and nullish bases get the reference's errors; tool references refuse.
- arguments: delete leaves a hole, length is a hidden writable property, the binding can be reassigned, and iterating it reads its enumerable own values.
- await is a plain name at the top level unless an expression starts with it, and an escaped await is a label.
- A named function expression's own name is bound before its parameters, so their defaults see it read-only.
- Iterators that break the protocol get the reference's errors everywhere they are opened, stepped or closed, including async yield* over a non-iterable.
- Promise.all, allSettled, any and race reject when their input is not iterable or iterating it fails.
- An accessor in an object literal fails when the literal runs, and export is a parse error, as in the reference.

Drops 77 files from rust-skipped.txt.
2026-11-18 18:56:10 +01:00
kommander
1b65246dfe fix(codemode): let a function's name and length be deleted, and name bound functions
A function's own name and length are configurable in the reference:
deleting one leaves the inherited Function.prototype value ("" and 0), and
assigning still fails as read-only. Two object flags record the deletion,
and reads, 'in' and hasOwnProperty honour them; a frozen or sealed
function still refuses. bind now gives the bound function its own
'bound <name>' and the target's length less the bound arguments.

delete's errors read 'Cannot delete property 'k'.' everywhere, as in the
reference, for arrays and Uint8Array too. Touches object.rs (flags) and
ops.rs (get, has, has_own, delete).

25 test262 files leave rust-skipped.txt.
2026-11-18 18:56:10 +01:00
kommander
f304df0a4f fix(codemode): reject Promise combinators whose input cannot be iterated
Promise.all, allSettled, any and race threw synchronously when their
argument was not iterable or iterating it failed; like the reference they
now return a promise rejected with that error, and word the non-iterable
case as the reference does ('Promise.all expects a synchronous iterable,
received a number.').

GetIterator now uses the reference's messages for a Symbol.iterator that is
not a function or returns a non-object, in every place that iterates.
Touches ops.rs (get_iterator, get_async_iterator).

70 test262 files leave rust-skipped.txt.
2026-11-18 18:56:10 +01:00
kommander
ff6da3f34b fix(codemode): resolve \k to whichever duplicate named group matched
regress binds \k<name> to the first group of that name only. When a name is
duplicated, at most one of its groups participates and a back-reference to
a group that did not participate matches empty, so compile now rewrites
\k<name> to the back-references of every group of that name in sequence,
(?:\1\2). With named groups present, \k inside a class is a syntax error
in the reference, which regress accepted; it now throws too.

Three test262 files leave rust-skipped.txt.
2026-11-18 18:56:10 +01:00
kommander
98653cbfff feat(codemode): add console.table
Ported from the reference's formatConsoleTable: one tab-separated line per
row under an (index) header, object rows spread into their keys (or the
chosen columns), primitives under Value, strings unquoted and other cells
in the console's format. Data holding a function or other opaque reference
logs [opaque reference]. console.dir() with no argument now logs undefined,
as in the reference.
2026-11-18 18:56:10 +01:00
kommander
3767364ca8 fix(codemode): match the reference's host for Math.sumPrecise and **
Math.sumPrecise is a port of JavaScriptCore's xsum accumulator as the
reference's Bun ships it, including its rounding of negative sums (Bun's
WebKit predates the fix in 8ee560d748ea, so Math.sumPrecise([-1]) is
-1.0000000000000002 there, and here). ** and Math.pow follow
JavaScriptCore's operationMathPow: square roots for ±0.5 and
square-and-multiply for integer exponents up to 1000, so 10 ** 23 is 1e+23
as in the reference. Touches vm.rs (js_pow).
2026-11-18 18:56:10 +01:00
kommander
e690e3b0b8 fix(codemode): throw when a built-in accessor is read off its prototype
RegExp's flags, source and lastIndex, Uint8Array length, Map/Set and
URLSearchParams size, URL's fields and searchParams, and TextDecoder's
encoding, fatal and ignoreBOM are getters on the prototype in the
reference, so reading one from the prototype itself or from an object that
only inherits it is a TypeError. Their prototype slots now hold Uninit,
which a property read turns into the reference's 'called on incompatible
receiver' error. Touches ops.rs (get).
2026-11-18 18:56:10 +01:00
kommander
e4c73711f3 feat(codemode): real array holes
Arrays hold holes from elisions, Array(n), delete, length and far writes. A hole is not an own property: reads and `in` fall through to the prototypes, keys and for-in skip it, and logs print it empty. Methods follow the reference: the callback methods skip indexes not in the array, the find methods read them live, sort puts holes last, flat drops them, and spreads and copies such as toReversed read them as undefined. Holes cross the extension boundary as holes.

Drops 40 files from rust-skipped.txt, and 15 stale entries from the reference's test262 skipped.txt that its runner passes.
2026-11-18 18:56:10 +01:00
kommander
01ba82d8a7 fix(codemode): one arguments object per call, keys converted once
A function makes its arguments object once, at entry, and arrows read
their enclosing function's; an index past the arguments is an ordinary
property. A computed key converts once in compound assignment, ++/--
and before an object literal's value is evaluated, and strings compare
by UTF-16 code units in every relational operator.
2026-11-18 18:56:10 +01:00
kommander
bcb2ddf1b9 fix(codemode): guard opaque operands and word iteration errors like the reference
Operators reject promises and tool references as the reference does
(Binary/Unary operators require data values, '++' requires a data
value), reading or adding a property a promise lacks reports it as
un-awaited, and for...in over a promise throws. A value that is not
iterable reports where it was iterated: for...of and for await...of as
an invalid data value naming it, destructuring, spread and yield* with
their own messages.

An opened iterator keeps the next method it had, as iterator records do,
and spread, rest and Object.assign copy the confined symbol keys.

call() returns packed words, so short callbacks no longer stall on the
reload of a two-word Value.
2026-11-18 18:56:10 +01:00
kommander
2c04a01ef6 test(codemode): adapt the reference's language tests as lang- cases
Programs from the reference's for-await, generator, promise, lexical,
labeled-control, constructor, new-expression and var-hoisting tests,
with expectations generated from the reference.
2026-11-18 18:56:10 +01:00
kommander
3fa2858c50 feat(codemode): add tagged templates
A tag is read like a callee, so a member tag keeps its receiver, and is
called with the site's strings array and the substitutions. The array
holds the cooked text, undefined for an invalid escape, and a read-only
raw array of the source text; each site makes it once per run. A
read-only assignment now reports the reference's message.
2026-11-18 18:56:09 +01:00
kommander
eddd08ca02 fix(codemode): reject circular values and Promise.race([]) like the reference
A member assignment, Array push, unshift, splice and fill, and
Object.assign throw a TypeError (an invalid data value) when the stored
value reaches its container through data objects, as the reference does
on purpose. Promise.race over an empty iterable rejects with the
reference's hint instead of never settling.
2026-11-18 18:56:09 +01:00
kommander
7a3d2e1fe0 feat(codemode): add async generators and for await
Async generator functions, for await...of and Symbol.asyncIterator, as
the reference has them: requests queue with their promises and run the
body when it waits for one, yield and return await their value, and a
sync iterable adapts to async with each value awaited and a rejection
closing it.

A generator's return() now runs the compiled return path after its
yield, so finally blocks and enclosing iterators close as for a return
statement. yield* forwards next, throw and return to its iterator.
Generator functions get their own prototype, so g() instanceof g holds.

run() hands its exit value back packed in one word: returning a two-word
Value stalled on store forwarding in short callbacks.
2026-11-18 18:56:09 +01:00
kommander
f4d4236f43 perf(codemode): resume generators on the dispatch loop
A generator now owns its value stack. Resuming it swaps that stack in and
pushes its boxed frame; yielding swaps back. Nothing is copied and run()
is not re-entered when for-of, array destructuring, spread, rest elements,
yield* or a direct next() call drives it. Spread and rest collect yields
without leaving the generator.

Closure cells now live in local slots and exception handlers on one VM
stack, so a frame carries no per-call vectors. Comparisons fuse with the
following conditional jump, a discarded yield skips its pop, and a TDZ
marker that is overwritten at once is dropped.

Array destructuring closes its iterator when a binding or default throws,
and a failed step no longer closes it.

generator iteration: 4.4 ms -> 2.7 ms median (reference 5.3 ms).
2026-11-18 18:56:09 +01:00
kommander
b43925d720 fix(codemode): match JavaScriptCore's Math.hypot
Every argument converts before infinities and NaN decide the result, so a
later argument's throw is not skipped, and the sum follows
JavaScriptCore's algorithm (libm for two values, a scaled sum for three,
a scaled fused running sum beyond), giving the reference's last bits.
2026-11-18 18:56:09 +01:00
kommander
bb78f2372a perf(codemode): install the larger built-in groups only when a run uses them
RegExp, Date, the byte types, the Map/Set additions, the URI functions,
URL/URLSearchParams/Headers and crypto/structuredClone are set up when the
program names one of their globals, imports a module that maps to them, or
makes one of their values (a regex literal, a String regex method), so a
run that uses none of them starts as fast as before they existed.

Touches vm.rs (load installs the groups its globals need) and host.rs
(module imports install a group before falling back to host globals).
2026-11-18 18:56:09 +01:00
kommander
aa0cd870b4 feat(codemode): add URL, URLSearchParams, Headers, crypto and structuredClone
URL with its readable and writable fields and a linked searchParams,
URL.canParse/parse; URLSearchParams from strings, records, pairs and
other params, with live iterators; Headers with name and value
validation, combined values and set-cookie kept apart in the host's
order; crypto.randomUUID and getRandomValues from /dev/urandom; and
structuredClone over the data kinds, rejecting the rest with
DataCloneError. Writing a read-only accessor (RegExp flags, Uint8Array
length, size, TextDecoder fields, URL origin) throws the reference's
TypeError.

Adds the url crate (pure Rust WHATWG URL parser) with idna_adapter pinned
to 1.1, which maps IDNA with the unicode-rs crates instead of ICU4X; the
stripped embed example grows from 3512936 to 3879376 bytes.

Built-in iterators over URLSearchParams and Headers report the reference's tags.
2026-11-18 18:56:09 +01:00
kommander
ebb15aeb19 feat(codemode): add URI functions, toExponential, Math.sumPrecise, f16round and copyWithin
- encodeURI/encodeURIComponent/decodeURI/decodeURIComponent with the
  reference's URIError messages.
- Number formatting follows JavaScriptCore: toString(radix) ports its exact
  integer digits and shortest-fraction algorithm, toExponential and
  toPrecision round half up on the exact value, toFixed keeps the sign of
  a negative that rounds to zero, and number-to-string picks the even
  digit when two shortest forms tie. Range errors use the host messages.
- Math.sumPrecise sums exactly and rounds once; Math.f16round rounds
  straight from the double; Array.prototype.copyWithin.

Number-to-string and its tie rule live in value.rs, so integers from 2^53
up print their shortest digits instead of every digit.

copyWithin converts its arguments through ToPrimitive like the other Array methods. Number-to-string decides ties in 128-bit integer arithmetic. test262: the reference's skipped.txt drops three copyWithin files the reference passes.
2026-11-18 18:56:09 +01:00