Commit graph

29 commits

Author SHA1 Message Date
Sebastian Herrlinger
d7829cc4d9 chore(codemode): format the streaming generator and its array frames 2026-11-19 02:24:27 +01:00
Sebastian Herrlinger
8943a0a540 test(codemode): bound the streaming busy loops by wall-clock time, so a resumed run leaves them at once 2026-11-19 02:17:01 +01:00
Sebastian Herrlinger
5208cfd308 test(codemode): record streaming and crossings 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
790c34e5f6 test(codemode): record destructured promises, error locations and checked member writes from the reference
Uncaught failures in conformance/frames/core.ts programs record their message with its location, for each site the
Rust compiler now places where the reference does, and the destructuring and member-write behaviour fixed with them.
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
71a99f6d7e test(codemode): record host-call argument cases from the reference
conformance/frames/hostargs.ts adds streaming programs for what tools, search
and extension functions receive: functions left out at every position,
promises fulfilled, pending and rejected at every position, nested promises, a
promise fulfilling with a function, cycles through promises, built-in objects
and errors in tool arguments with toJSON never called, Uint8Array failures,
when a waiting call starts and the jobs its waits take, search and extension
calls that wait, a function from a host result handed back to an extension
function, and an unknown tool's call rejecting its promise (caught with .catch,
try/await, Promise.allSettled, unawaited), plus suspensions while a call waits.

catalog.ts gains a separate block of boundary programs at the end of its list
for the host values an extension function receives under the same rules.
streaming.json and catalog.json are regenerated at integration.
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
ff703af7d0 test(codemode): keep one busy-loop fuel case per cost rule 2026-11-18 18:56:14 +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
7c7c332639 test(codemode): record conversions with no primitive to give 2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
b9037a236c feat(codemode): convert Object.fromEntries keys and URLSearchParams and Headers pair parts from their frames 2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
77e31369f5 feat(codemode): convert Object.groupBy keys from its frame, each after its callback 2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
e73f2595a0 feat(codemode): resume a sync generator's throw and return from the async adapter's frame
for await and an async generator's yield* over a sync generator called
its own throw and return from Rust, through call_counted: the adapter's
frame now calls them, counted as before, and closes a generator without a
throw through its return for nothing, so a search in the generator's
catch or finally parks.

Recorded: search parking in a sync generator's finally and catch under for
await and an async generator's yield*.
2026-11-18 18:56:14 +01:00
Sebastian Herrlinger
161cc82bb4 test(codemode): record fuel of abrupt requests through yield* and for await closes 2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
64be1f3c2d feat(codemode): park a search inside the program result's toJSON
The program result's crossing runs in a native frame at the base of the
run, which a search(...) inside a toJSON there now parks with a fresh
coroutine, as a promise job's frame does.

Recorded: search parking inside a toJSON in tool arguments, in search
input and in the program's result.
2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
4faf34382c feat(codemode): call a crossing's toJSON from a native frame
The walk that crosses tool arguments, search input and the program's result to the host now calls each toJSON from a native frame it pushes, as bytecode calls it, so a toJSON can park for search(...), suspend and be saved in a snapshot. A search's walk runs in its frame and parks it with the search's frames when it awaits. The fast path makes a Date's or URL's JSON itself instead of calling the prototype's toJSON, as the reference does.
2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
e077d7a261 feat(codemode): park a search inside an async generator's frame
An async generator runs from native code, so its frame is a run's base: a
search(...) inside it, or in what its yield* or for await calls, now parks
the generator's frame and those above it with a fresh coroutine, the VM
going back to the resumer's stack as the generator's await does, and the
generator taking the resumer's stack again when they are restored.

Recorded: search parking under yield* over the program's iterator, in a
delegated generator's return() and throw(), in for await over a
generator, and in async generators.
2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
31a124de02 test(codemode): record yield* and for await over the program's iterators 2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
a7d43a320a feat(codemode): convert with the program's valueOf and toString in native frames
A conversion that would call the program's valueOf or toString no longer
calls it from Rust, as the reference converts in its internal bytecode:

- A built-in called from bytecode converts with conversions restartable: one
  that calls the program records its request instead, and a convert frame
  runs ToPrimitive as calls, then runs the built-in again with the answers
  replayed in order ($vmConvert). A built-in's list of conversions is one
  request answered with the whole list, so state it kept in the list (a
  Date setter's time) is the one read before the conversions.
- An instruction whose operand converts by calling the program hands the
  operation to a convert frame, which runs its slow path the same way and
  gives the result back as the instruction would, a jump included.
- A sort comparator's, a replace callback's and toLocaleString's result is
  converted from their frames.

A replay rewinds the fuel it spends until it takes its last answer, and
starts no queued host calls meanwhile, so the fuel and its order are those
of the conversions made inline. A message that converts a value and
ignores a failure converts it inline, never leaving a request behind.

Recorded: search parking in each kind of conversion, a Date setter whose
argument changes the date, a suspension inside valueOf, and busy loops
through converting operators and built-ins.
2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
1c9b6f58d3 feat(codemode): run JSON.stringify's internal walk in a native frame
A replacer, a property list or a toJSON of the program's makes JSON.stringify run the reference's internal walk. That walk now runs in a native frame (NativeOp::Callbacks) with its containers on the frame's slots and what it wrote before each call kept in an internal byte buffer, so a toJSON or replacer can suspend there and be saved. Output, indentation, depth limits and fuel are unchanged; the native walk, which calls no program code, stays as it was. As in the reference, the walk now reads holder[key] when it reaches it, throws its own error for an un-awaited promise it reads, writes a promise a callback returns and a symbol as {}, and words the circular error with a period.
2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
4398e5b51d feat(codemode): read the iterables of fromEntries, AggregateError, sumPrecise and the web constructors in native frames
Object.fromEntries, AggregateError, Math.sumPrecise, and new URLSearchParams(...) and new Headers(...) over iterable pairs now step their iterators from native frames (NativeOp::Callbacks), so a next() or toString() of the program's can park for search(...), suspend, or be saved. Each pair of the web constructors is read by a frame of its own, pushed through a native the constructors keep as their data, so a throw there closes both iterators. Object.prototype.toLocaleString hands on to toString through the frame call and apply use, with the reference's fuel. A value that is not iterable now fails as the reference words it.
2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
1372ed929f fix(codemode): run then, catch and finally of search results as the promise's own
A search result's then, catch and finally act on a settled copy. They looked the method up on the copy's promise, so a program that replaced Promise.prototype.then had its function called from Rust; the reference runs the promise's own method, which only registers reactions. Now the reactions are registered directly.
2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
f0eaf2cd64 feat(codemode): run collection built-ins that call the program in native frames 2026-11-18 18:56:13 +01:00
Sebastian Herrlinger
c1db342831 feat(codemode): run iterator helpers' next and return in native frames 2026-11-18 18:56:12 +01:00
Sebastian Herrlinger
95847e86fe refactor(codemode): collect Uint8Array sources the VM iterates itself without a frame 2026-11-18 18:56:12 +01:00
Sebastian Herrlinger
c18a830583 feat(codemode): run Uint8Array callbacks and iterable sources in native frames 2026-11-18 18:56:12 +01:00
Sebastian Herrlinger
90a252f339 feat(codemode): iterate the program's iterators in native frames
for...of, destructuring, rest elements and spread over an iterator the VM
does not step itself (one whose [Symbol.iterator], next or return is the
program's, a helper's or the host's) now open, step and close it from a
native frame: the instruction pushes the frame, which makes the call and
hands the result back as the instruction would, a finished for...of
jumping to its exit. A step that fails forgets the iterator, as before.

native_resume with return or throw pushes a handler first, so what the
generator throws comes back to the frame instead of unwinding past it
while its step runs, and a for-of frame's close throws what closing threw.

Recorded: search parking in each, a generator whose finally throws while
closed, the iterator errors, and a suspension inside a custom next.
2026-11-18 18:56:12 +01:00
Sebastian Herrlinger
2d04847c75 refactor(codemode): give built-in families their own native frame ops
Arrays, iterators, collections and other callbacks each get a native op
whose frames carry a sub-op, dispatched in the family's own file
(family_step), so a family adds steps without touching native.rs; a
snapshot saves the sub-op with the frame. enter_native_sub,
enter_for_of_sub and enter_for_of_record_sub push them.

Each family keeps its streaming cases in conformance/frames/, which
conformance/streaming.ts loads.
2026-11-18 18:56:12 +01:00