GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Save Sparkplug Progress accumulator; force CallRuntime (RUN-744) by Domiii · Pull Request #132 · replayio/node

Conversation

@Domiii

@Domiii Domiii commented Sep 20, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Summary

  • Sparkplug Progress CallRuntime clobbers live accumulator (rest-params etc.).
  • Master #129 already forces CallRuntime (RUN-744); this PR adds SaveAccumulatorScope to match neighboring Sparkplug handlers.
  • Paired with backend#13372 via REPLAY_BACKEND_REV.
  • Absorbed CI wiring from #131 (superseded).
  • Mute POST_WORK / POST_WORK_DONE asserts when events are disallowed (GC FileHandle close under unlabeled DisallowEvents).
  • REPLAY_ASSERT* macros are now plain C (single implementation; no recordreplay:: / C++ dual path). Call site uses REPLAY_ASSERT_MAYBE_EVENTS_DISALLOWED.

Causal chain

  • Inline ScratchRegister Progress path diverged from interpreter / asserted Progress.
    • RUN-744: progress-counter mismatch under Sparkplug.
    • Chromium hard-disabled the inline path: if ((true)/*gRecordReplayAssertProgress*/).
    • Node master now matches that force-CallRuntime (Align Node V8 progress handling with Chromium #129).
  • Forcing CallRuntime alone is insufficient.
    • CallRuntime clobbers the accumulator.
    • Neighboring handlers (VisitIncBlockCounter, VisitRecordReplayInstrumentation) already wrap CallRuntime in SaveAccumulatorScope.
    • Progress handler did not.
  • GC FileHandle close hit libuv POST_WORK under unlabeled DisallowEvents.
    • Hard Assert warned: Recording assertion with events disallowed: POST_WORK 2 [EventsDisallowed:NONE].
    • Soft-assert via REPLAY_ASSERT_MAYBE_EVENTS_DISALLOWED → V8RecordReplayAssertMaybeEventsDisallowed when events are disallowed.

Change

  • VisitRecordReplayIncExecutionProgressCounter: wrap body in SaveAccumulatorScope.
  • BK test-node / test-jest (from pin REPLAY_BACKEND_REV for backend#13372 #131):
    • npx [email protected] install --frozen-lockfile (pnpm-era pin; no global npm on can_replay).
    • Inject RECORD_REPLAY_API_KEY for LocalReplay uploads.
  • REPLAY_BACKEND_REV → tip of backend#13372.
  • Wipe shared NodeRepo/out/ when linux_node_build.Dockerfile FROM (glibc base) changes — not on every pin bump (BK Replay not pausing at correct position in call stack for breakpoint #81 __libc_single_threaded).
  • POST_WORK mute (events-disallowed):
    • Add C V8RecordReplayAssertMaybeEventsDisallowed in deps/v8/src/api/api.cc.
    • Rewrite replayio-macros.h as plain C (forward-declare C APIs; HasAsserts gate; ((void)0) semicolon); no #ifdef __cplusplus dual bodies.
    • deps/uv/src/unix/fs.c includes macros header; POST_WORK / POST_WORK_DONE use REPLAY_ASSERT_MAYBE_EVENTS_DISALLOWED.

V8 Chromium gates

  • Align Node V8 w/ Chromium emit/BLOCKED/registered-script gates (3361eac7ce7).
  • SetRecordReplayFlags: Disallow/ReplayCode → record_replay_ignore.
  • RecordReplayShouldEmitOpcodes: freeze first emit per (isolate, script_id).
  • gRegisteredScripts / RecordReplayHasRegisteredScript (parse-info ignore gate).
  • JSInvoke:BLOCKED:NonDeterministicUserJS for divergent registered UserJS.
  • Replaces thinner !RecordReplayIgnoreScript BLOCKED path previously on this PR.

Test plan

  • Existing Sparkplug Progress / RUN-744 coverage still green.
  • Repro GC FileHandle close path: no hard Assert warn for POST_WORK under unlabeled DisallowEvents.
  • BK test-node / test-jest green on this branch tip.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Domiii @cursoragent
Save Sparkplug Progress accumulator; force CallRuntime (RUN-744).
773a870
CallRuntime clobbers accum (rest params); inline ScratchRegister path caused progress-counter mismatch.

Co-authored-by: Cursor <[email protected]>
@Domiii Domiii self-assigned this Sep 20, 2026
@Domiii
Domiii requested review from Andarist and bhackett1024 September 20, 2026 10:08
@Domiii
Wipe NodeRepo out/ when builder PIN changes (glibc ABI).
d8c1819
Shared cache reused ubuntu:22.04 api.o under ubuntu:20.04 linker →
undefined __libc_single_threaded on mksnapshot.
bhackett1024
bhackett1024 approved these changes Sep 20, 2026
View reviewed changes
Domiii and others added 2 commits September 20, 2026 23:13
@Domiii @cursoragent
Merge branch 'master' into dominik/sparkplug-progress-save-accum
5f11891
Keep SaveAccumulatorScope on Progress; master already has RUN-744 CallRuntime force.

Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Absorb #131 CI wiring; pin backend#13372; key out/ wipe on Dockerfile…
2e8a849
… FROM.

- pnpm install + RECORD_REPLAY_API_KEY for LocalReplay on test-node/test-jest
- REPLAY_BACKEND_REV → backend#13372 tip
- Replace PIN stamp with linux_node_build Dockerfile FROM key (glibc ABI)

Co-authored-by: Cursor <[email protected]>
@Domiii Domiii mentioned this pull request Sep 20, 2026
pin REPLAY_BACKEND_REV for backend#13372 #131
Closed
Domiii and others added 18 commits September 21, 2026 01:42
@Domiii @cursoragent
Bump REPLAY_BACKEND_REV to backend#13372 tip (tz COPY sync).
14ded61
721bbe88936d15e04bb31c7f847f06029f9222cb — seed gTime_* before ApplyBindings + SyncCopiedSymbols after Op_tzset.

Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Port chromium exception save/restore around NewBookmark (crash-0003).
5791c5d
Promise-hook throws leave a pending exception; MakeMessageObject's
V8RecordReplayNewBookmark must clear/restore it so GetAllFrames JsonParser
can parse "{}". Match chromium messages.cc + non-static gCurrentException.

Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Port Chromium NonDeterministicUserJS UNGATED/BLOCKED warnings into No…
8edb1b4
…de V8.

Rename RUN-1919 progress warning to NonDeterministicUserJS:UNGATED:JSProgress and add JSInvoke:BLOCKED:NonDeterministicUserJS gate via RecordReplayIsDivergentUserJSWithoutPause (crash-0004 warning parity).

Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Bump REPLAY_BACKEND_REV to backend#13372 tip (SYS_close Disallow).
5fecf6b
0b178814d7cdaa9da0382d12c643fb6adba39b2a — Ignore SYS_close under Disallow like libc close (node-ci crash-0005).

Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Mute POST_WORK asserts when events are disallowed.
9f92915
GC FileHandle close hits libuv POST under unlabeled DisallowEvents; hard Assert warned instead of being skipped.

Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Bump REPLAY_BACKEND_REV to backend#13372 tip (process.exit after test…
16268e3
…-jest).

Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Gate worker→main inspector Connect when recording/replaying.
ffc3730
ConnectToMainThread / ParentInspectorHandle::Connect posted CrossThread
sessions that hit CHECK(IsMainThread) in MainThreadInterface::Post.
Match the existing WorkerStarted/Finished NYI early-return.

Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Bump REPLAY_BACKEND_REV for node CI recorder-crash upload.
d1851a2
Pin e810f009583bd731fd1990e0e154acebc7086a0a (backend#13372 tip).

Co-authored-by: Cursor <[email protected]>
@Domiii
Make REPLAY_ASSERT* macros plain C; use at POST_WORK.
9ab7031
Drop C++ recordreplay:: / static_assert dual path; gate via V8 C APIs
and call V8RecordReplayAssertMaybeEventsDisallowed from fs.c POST.
@Domiii @cursoragent
Bump REPLAY_BACKEND_REV for inspector-connect ignore.
08454ff
Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Bump REPLAY_BACKEND_REV for test-node ~40min budget (N=680).
1e9fec7
Also raise test-node BK timeout 60→90 for headroom under the longer wall.

Co-authored-by: Cursor <[email protected]>
@Domiii
Bump REPLAY_BACKEND_REV for test-node bail-on-first-failure.
7dbed45
@Domiii @cursoragent
Bump REPLAY_BACKEND_REV for test-jest ~40min (N=250) + algorithms seed.
640394c
Pin backend db056b8de4. Seed javascript-algorithms alongside immer; BK timeout 60→90.

Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Drop test step BK timeouts; clarify out/ wipe; pin backend worker-ign…
bbf03bc
…ore + jest errors.

Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Skip rewriting node_record_replay_driver.cc when unchanged.
23357d8
Chromium build.js already uses writeFileSyncIfChanged so make does not
rebuild the embedded-driver TU on content-identical retries.

Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Bump REPLAY_BACKEND_REV for spawn abort clarity + Jest spam fix.
d3083b4
Pin backend 778eb43928 (truncate spawn errors, AbortSignal.timeout detail, quiet passes, jest 180s/test).

Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Align Node V8 with Chromium emit/BLOCKED/registered-script gates.
3361eac
Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
CI: agent-lost auto-retry; pin algorithms to Jest 29; bump backend.
7eb0709
- build-node retries exit_status:-1 (BK #102 AgentLost)
- javascript-algorithms @ 0248845 (Jest 29; Jest 30 circus fails under record)
- REPLAY_BACKEND_REV → 50eff6e763 (wpt ignore)

Co-authored-by: Cursor <[email protected]>
@Andarist Andarist mentioned this pull request Sep 21, 2026
Wipe node out on toolchain change #134
Merged
Domiii and others added 2 commits September 21, 2026 17:03
@Domiii @cursoragent
Bump REPLAY_BACKEND_REV for test-vm-timeout ignore.
283ff9d
Co-authored-by: Cursor <[email protected]>
@Domiii @cursoragent
Bump REPLAY_BACKEND_REV: skip immer base.js; jest 300s wall.
38c7547
Co-authored-by: Cursor <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Domiii
@Andarist Gideon Redelinghuys @jazzdan @hbenl @claude
Add Replay CI/CD workflows and GitHub Actions
0c68047
Add build/test, release, and branch-test workflows, along with
approveman and SOC2 compliance config for the Replay fork. Add the
Buildkite pipeline (.buildkite/runtime-node-build-and-test.yml) that
builds node and runs the backend test suites against it, and
replay_build_scripts/build-pipeline.py, which pins REPLAY_BACKEND_REV
into the pipeline for `buildkite-agent pipeline upload`. The GitHub
build-test workflow is kept for manual dispatch only.

The test steps call the backend's buildNode.ts suites under the names
it uses now: the node test step runs test-node-core only, no longer
the test/node-recording suite as well, and the jest step runs
test-jest-repos.

Rebase note: the pipeline's step names have to follow the backend's
buildNode.ts subcommands (test-node-recording, test-node-core,
test-jest-repos); a suite renamed there fails the step until the
pipeline follows. Every backend revision the pipeline triggers, clones
or tests against comes from REPLAY_BACKEND_REV through
build-pipeline.py's __REPLAY_BACKEND_REV__ placeholders, never a
hard-coded sha.

Includes later changes from #127, #128, #132, #134, #154 and #156.

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Gideon Redelinghuys <[email protected]>
Co-authored-by: Dan Miller <[email protected]>
Co-authored-by: Holger Benl <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Domiii
@Andarist @claude
Add build system for Replay fork
ea96dda
Add build.js script for downloading the Replay driver and compiling
Node.js, REPLAY_BACKEND_REV for version tracking, .gitignore updates,
and node.gyp change to include node_record_replay_driver.cc. build.js
can use a local driver (REPLAY_LOCAL_DRIVER_DIR), builds into out/,
strips Nix paths from the build environment, and only rewrites
node_record_replay_driver.cc when its contents change, so make does not
rebuild the embedded driver needlessly.

Includes later changes from #123, #124, #125, #127, #128, #132, #136,
#147, #172, #185, #186, #198, #200, #219, #221, #225 and #227.

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Domiii
@Andarist @claude
Add core V8 record/replay API surface
d90615a
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,
#170, #173, #190, #191 and #202.

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Domiii
@claude @Andarist
Add record_replay_bookmark to V8 JSMessageObject
a0f753e
Add record_replay_bookmark Smi field to JSMessageObject (object layout
change) and set it during message creation to track the recording
position at which the exception was created. Modifies the
NewJSMessageObject factory signature. Creating the bookmark can run
Replay's own JS, so the pending exception, pending message and
scheduled exception are saved and restored around it.

Includes later changes from #132.

Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
@Domiii @claude
Add V8 AST/parser instrumentation for recording
d2ba90e
Track call head token positions on AST nodes, add AstRawString
to_string(), and add parse-info record_replay_ignore flag. Modify
parser and preparser to propagate positions for replay breakpoint
placement. Set record_replay_ignore for scripts whose URL the recorder
asks to ignore, and for any script or eval compiled off the main
thread, while events are disallowed, or from replay code.

While replaying, force parameters and declared variables into the
context, so frames inspected in a replay see their real values instead
of registers the bytecode no longer keeps alive (RUN-2604, Chromium
feature: force-variable-context-allocation). Sloppy block function
bindings are forced too: one could still sit in a register, where an
async function optimized at one await and resumed unoptimized after
the next restored V8's stale register marker into the binding, which
inspecting the frame then saw. V8 already context-allocates these
bindings whenever a sloppy direct eval is in scope, so forcing them
changes no semantics.

Rebase note: forced context allocation has to cover every variable
kind a replay can inspect, so check DeclareVariable's kinds when
upstream adds one, and it has to stay replay-only, since it changes
the bytecode a function compiles to. record_replay_ignore must be set
for every compile the recorded main thread does not drive.

Includes later changes from #128, #132 and #205.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Domiii
@Andarist @claude
Add V8 bytecodes for record/replay instrumentation
4d8eb22
Add RecordReplayIncExecutionProgressCounter, Instrumentation,
InstrumentationGenerator, and AssertValue bytecodes with interpreter
handlers, baseline compiler visitors, and bytecode builder/generator
integration for tracking execution progress during recording. Add the
runtime functions backing them (assertions, instrumentation callbacks
and the instrumentation site registry).

With JS progress asserts enabled, each main-thread progress step
(script ID and function position) is buffered as recorder assert data,
so a mismatch names the functions where recording and replay diverged;
progress CHECKs can be enabled separately. Baseline code always calls
the runtime for progress and saves the accumulator around the call
(RUN-744). Exception unwinds while events are disallowed are not
reported.

The runtime function table also declares the baseline JIT's variants
of the progress, target-progress and instrumentation calls, which take
the accumulator as their last argument and return it, for the baseline
code that calls them instead of saving the accumulator itself.

Rebase note: record/replay opcodes are only emitted for a script the
recorder knows, on the main thread, and the bytecode a function
compiles to has to come out the same when recording and when
replaying, since an instrumentation site is identified by the index
embedded in its bytecode. The accumulator is live at progress and
instrumentation sites (after ResumeGenerator and at the start of a
catch block), so any JIT path that calls out there must preserve it.

Includes later changes from #128, #129, #132 and #207.

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @hbenl
@Domiii @Andarist @claude
Add V8 replay command handler and debug hooks
fd58a8d
Add the main replay command handler in debug.cc with script management,
breakpoint info, object ID tracking, value assertion helpers, and
ProcessCompileEvent wrapper. Hook debugger statement in runtime-debug.

Includes later changes from #128 and #132.

Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@Domiii @Andarist @claude
Freeze record/replay opcode emission per script
8363723
Decide once per script whether its bytecode carries record/replay
instrumentation, so recompiles caused by bytecode flushing or cache
ageing get the same instrumentation as the first compile. The decision
is stored on the Script itself (a new record_replay_instrumented flag,
set in ParseInfo::CreateScript from the compile that creates the script)
and every later compile of that script inherits it through
RecordReplayInheritCompileFlags. The FinalizeBytecode CHECK that the
ignore flag matched the script is dropped, as it no longer holds.

Register a script as a Replay source as soon as its main-thread
compile finishes: ScriptCompiler::CompileUnboundInternal and the
streamed-source compile call RecordReplayRegisterCompiledScript,
instead of waiting for the script's function to be instantiated, which
never happens for an ES module whose import graph failed to load, so
the recording had no source for it. At the first checkpoint, the
progress counter is reset (with a ProgressBeforeFirstCheckpoint
warning if anything advanced it) and the sources registered until then
are announced, since the recorder only takes sources from the first
checkpoint on.

Invalidate the recording when --lazy-compile-dispatcher or
--parallel-compile-tasks is on: the dispatcher compiles functions on
worker threads whose timing decides when the main thread installs a
function's bytecode, or whether it waits for a worker, so such a
recording doesn't replay reliably. The flags are left as requested.

Also count the background compile tasks currently running, for
checking that record/replay opcodes are only emitted on the main
thread. Nothing reads the counter yet.

Rebase note: the invariant is that one script's bytecode is either
always instrumented or never, and that only main-thread compiles
instrument, so the decision belongs to ParseInfo::CreateScript and
every other path that builds UnoptimizedCompileFlags for an existing
script must take the flags from that script. A new Script flag bit
also needs its Torque bitfield (script.tq) kept in sync.

From #128, #132, #143 and #217.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@Domiii @Andarist
@bhackett1024 @claude
Block non-deterministic user JS while events are disallowed
01cc91e
While events are disallowed (GC, compilation, driver commands) and the
replay has not diverged, user JS from registered scripts must not run:
it would advance the progress counter differently than when recording.
That condition is v8::replayio::MustNotRunUserJS(). Its comment
documents why it exists: Replay's inspector session work runs with
events disallowed and console message data is gathered only when
replaying, so user JS run from there would change the program's state
where the recording didn't. It also describes the alternative of
recording the session's work on both sides, and why recordings would
then show the program as if a debugger were attached.

Execution::Invoke refuses to call such functions and logs a
NonDeterministicUserJSBlocked warning with the trigger, the progress,
the function's location and the JS stack. Invoke and the API callback
entry points (HandleApiCallHelper, InvokeApiFunction,
HandleApiCallAsFunctionOrConstructor) rewind any progress (and
progress assert data) made on such paths through
RecordReplayScrubDivergentProgressScope, the progress runtime function
warns once with the JS stack when it happens
(NonDeterministicUserJSUngated), and Error.prepareStackTrace is
skipped while events are disallowed.

The Invoke gate doesn't catch the program's code called from a builtin
or called through a bound function or a proxy, so the inspector's
value descriptions gate on the same condition: describing an Error
returns a placeholder instead of reading its stack and message, and
Object::ConvertToString returns the default [object Object] string
instead of running ToPrimitive, which this V8 reaches when it
describes a logged Date. Upstream V8 made Date descriptions
side-effect free (25c69ecbc14), after which the ConvertToString gate
can go.

Discard a function's baseline code with events disallowed: the heap
walk enters a safepoint whose GC tracer scope reads the clock, and
whether the function has baseline code when a breakpoint is set can
differ between recording and replaying.

Register as Replay sources exactly the scripts whose bytecode is
instrumented, and announce them to the recorder from a separate
RecordReplayAnnounceScript: queued until the first checkpoint, since the
recorder only takes sources from there on, and skipped with a warning if
events are disallowed, which announcing would record an event in. A
script is also registered as soon as a main-thread compile finishes it
(RecordReplayRegisterCompiledScript), not only when its function is
instantiated. When listing a script's possible breakpoints, recompile a
top-level function the GC collected, so the functions only its bytecode
referenced have their breakpoints again.

The baseline JIT's progress and instrumentation runtime calls take the
accumulator as their last argument and return it
(Runtime_RecordReplayBaselineExecutionProgress,
Runtime_RecordReplayBaselineInstrumentation and its generator
variant): the calling frame's baseline code can be discarded while the
call is on the stack, and the frame then resumes in the interpreter
with the call's result as its accumulator.
Runtime_RecordReplayBaselineTargetProgressReached is called once the
counter that baseline code increments inline reaches the target
progress. Instrumentation sites are reported to the recorder by
function index rather than by bytecode offset.

Rebase note: new C++-to-JS entry points need a
RecordReplayScrubDivergentProgressScope, and user callbacks invoked
from V8 internals need the same MustNotRunUserJS() gating. The
invariant is about the program's state, not about one entry point:
anything Replay's own session can reach that would run user JS (an
accessor, a toString, a Symbol.toPrimitive) has to be gated, not just
the paths that go through Execution::Invoke.

From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Brian Hackett <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
@Domiii @claude
Patch libuv for recording/replay determinism
5ed9ec5
Add ordered lock/unlock around async operations, assertions in
filesystem, signal, stream, process, and kqueue code paths. Implement
uv_mutex_mark_ordered API for recording, disable uv_set_process_title
during replay, and add diagnostic logging for spawn operations.
The fs POST asserts are skipped while events are disallowed, since a
GC-driven FileHandle close can reach them there.

Rebase note: the invariants are (1) mutexes and async handles used
across threads (threadpool mutex, loop wq_mutex, uv_async_t) must be
ordered, and uv_async_send/uv__async_spin must release the handle's
ordered lock on every return path; (2) signal handles are mapped
through RegisterPointer/PointerId because the signal pipe's contents
are replayed verbatim; (3) on macOS, uv_cpu_info's CPU speed is
recorded manually because the underlying system calls are not
supported while recording. The V8RecordReplayAssert/Diagnostic calls in
fs.c, stream.c, process.c and kqueue.c only detect divergence; if
upstream reshapes those functions, re-add them next to the equivalent
syscalls.

Includes later changes from #132.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
@Domiii @claude
Patch Node.js inspector for recording
280f5e4
Deliver inspector requests at points the replay reproduces. Requests
from the IO thread are queued and dispatched from V8's interrupt, which
runs where the progress counter next advances, while requests the main
thread makes keep a queue of their own and are dispatched right away:
Replay's own session makes those with events disallowed, where locks are
not taken in the recorded order, so going through the shared queue
deadlocked the replay. Order every lock the IO thread shares with the
main thread, as Blink orders its InspectorTaskRunner lock, so both sides
see the same hand-offs; unordered, whether a post found the queue empty,
and so requested an interrupt, differed from the recording.

Worker inspector start and finish notifications and
worker-to-main-thread connections are refused while recording or
replaying, and toDouble uses strtod because istringstream misbehaves
when replaying.

Rebase note: every lock the inspector shares between the IO thread and
the main thread must be ordered, and no request from another thread may
be dispatched where it arrives. Keep the main thread's own requests out
of the shared queue and its locks.

Includes later changes from #132 and #196.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add build system for Replay fork
e7f2f49
Add build.js script for downloading the Replay driver and compiling
Node.js, REPLAY_BACKEND_REV for version tracking, .gitignore updates,
and node.gyp change to include node_record_replay_driver.cc. build.js
can use a local driver (REPLAY_LOCAL_DRIVER_DIR), builds into out/,
strips Nix paths from the build environment, and only rewrites
node_record_replay_driver.cc when its contents change, so make does not
rebuild the embedded driver needlessly.

Includes later changes from #123, #124, #125, #127, #128, #132, #136,
#147, #172, #185, #186, #198, #200, #219, #221, #225 and #227.

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add core V8 record/replay API surface
9c06ecf
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add build system for Replay fork
be78ef7
Add build.js script for downloading the Replay driver and compiling
Node.js, REPLAY_BACKEND_REV for version tracking, .gitignore updates,
and node.gyp change to include node_record_replay_driver.cc. build.js
can use a local driver (REPLAY_LOCAL_DRIVER_DIR), builds into out/,
strips Nix paths from the build environment, and only rewrites
node_record_replay_driver.cc when its contents change, so make does not
rebuild the embedded driver needlessly.

Includes later changes from #123, #124, #125, #127, #128, #132, #136,
#147, #172, #185, #186, #198, #200, #219, #221, #225 and #227.

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add build system for Replay fork
974cae7
Add build.js script for downloading the Replay driver and compiling
Node.js, REPLAY_BACKEND_REV for version tracking, .gitignore updates,
and node.gyp change to include node_record_replay_driver.cc. build.js
can use a local driver (REPLAY_LOCAL_DRIVER_DIR), builds into out/,
strips Nix paths from the build environment, and only rewrites
node_record_replay_driver.cc when its contents change, so make does not
rebuild the embedded driver needlessly.

Includes later changes from #123, #124, #125, #127, #128, #132, #136,
#147, #172, #185, #186, #198, #200, #219, #221, #225 and #227.

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add record_replay_bookmark to V8 JSMessageObject
784a4c6
Add record_replay_bookmark Smi field to JSMessageObject (object layout
change) and set it during message creation to track the recording
position at which the exception was created. Modifies the
NewJSMessageObject factory signature. Creating the bookmark can run
Replay's own JS, so the pending exception, pending message and
scheduled exception are saved and restored around it.

Includes later changes from #132.

Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add core V8 record/replay API surface
438e7c5
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,
#170, #173, #190, #191 and #202.

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add V8 AST/parser instrumentation for recording
52f3e2c
Track call head token positions on AST nodes, add AstRawString
to_string(), and add parse-info record_replay_ignore flag. Modify
parser and preparser to propagate positions for replay breakpoint
placement. Set record_replay_ignore for scripts whose URL the recorder
asks to ignore, and for any script or eval compiled off the main
thread, while events are disallowed, or from replay code.

While replaying, force parameters and declared variables into the
context, so frames inspected in a replay see their real values instead
of registers the bytecode no longer keeps alive (RUN-2604, Chromium
feature: force-variable-context-allocation). Sloppy block function
bindings are forced too: one could still sit in a register, where an
async function optimized at one await and resumed unoptimized after
the next restored V8's stale register marker into the binding, which
inspecting the frame then saw. V8 already context-allocates these
bindings whenever a sloppy direct eval is in scope, so forcing them
changes no semantics.

Rebase note: forced context allocation has to cover every variable
kind a replay can inspect, so check DeclareVariable's kinds when
upstream adds one, and it has to stay replay-only, since it changes
the bytecode a function compiles to. record_replay_ignore must be set
for every compile the recorded main thread does not drive.

Includes later changes from #128, #132 and #205.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add V8 bytecodes for record/replay instrumentation
a94802b
Add RecordReplayIncExecutionProgressCounter, Instrumentation,
InstrumentationGenerator, and AssertValue bytecodes with interpreter
handlers, baseline compiler visitors, and bytecode builder/generator
integration for tracking execution progress during recording. Add the
runtime functions backing them (assertions, instrumentation callbacks
and the instrumentation site registry).

With JS progress asserts enabled, each main-thread progress step
(script ID and function position) is buffered as recorder assert data,
so a mismatch names the functions where recording and replay diverged;
progress CHECKs can be enabled separately. Baseline code always calls
the runtime for progress and saves the accumulator around the call
(RUN-744). Exception unwinds while events are disallowed are not
reported.

The runtime function table also declares the baseline JIT's variants
of the progress, target-progress and instrumentation calls, which take
the accumulator as their last argument and return it, for the baseline
code that calls them instead of saving the accumulator itself.

The property-store asserts are named after the bytecodes they follow, so
they track V8 10.2's renames of StoreNamedProperty to SetNamedProperty,
StoreNamedOwnProperty to DefineNamedOwnProperty and StoreKeyedProperty to
SetKeyedProperty. Nothing reads these strings.

Rebase note: record/replay opcodes are only emitted for a script the
recorder knows, on the main thread, and the bytecode a function
compiles to has to come out the same when recording and when
replaying, since an instrumentation site is identified by the index
embedded in its bytecode. The accumulator is live at progress and
instrumentation sites (after ResumeGenerator and at the start of a
catch block), so any JIT path that calls out there must preserve it.

Includes later changes from #128, #129, #132 and #207.

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add core V8 record/replay API surface
3d615e5
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

Add include/replayio.h with RAII helpers (AutoPassThroughEvents,
AutoDisallowEvents with an optional label, AutoMarkReplayCode) and
include/replayio-macros.h with REPLAY_ASSERT macros usable from C.
Asserts are skipped when the driver disables them, warnings go through
RecordReplayWarning, and progress notifications are ignored while
events are disallowed. When JS progress asserts are enabled, progress
data is handed to the recorder through its assert data callbacks.

The driver can disable individual features at runtime, so
IsRecordingOrReplaying() takes an optional feature name and
FeatureEnabled() asks the driver, with the check skipped entirely when
nothing is disabled.

replayio-macros.h also declares RecordReplayWarningField, the driver's
layout for one typed detail of a warning (a string, integer, double or
bool under a key), and the V8RecordReplayWarning entry point that takes
a warning kind plus an array of those fields.

The scope helpers and the rest of the C++ surface live here too:
AutoAssertMaybeEventsDisallowed, which asserts its message on entry and
exit so the recording orders the scope unless events are disallowed,
AutoOrderedLock, and AreEventsPassedThrough(), each defined next to the
driver symbol it calls.

Rebase note: these headers mirror the driver's ABI. Every driver
function is looked up by name in api.cc, so a new recordreplay::
method needs its symbol loaded there, and RecordReplayWarningField's
layout and the V8RecordReplay* signatures have to match the driver
that REPLAY_BACKEND_REV pins.

Includes later changes from #128, #129, #132, #137, #159, #161, #162,
#170, #173, #190, #191 and #202.

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add V8 replay command handler and debug hooks
96e4ca0
Add the main replay command handler in debug.cc with script management,
breakpoint info, object ID tracking, value assertion helpers, and
ProcessCompileEvent wrapper. Hook debugger statement in runtime-debug.

Includes later changes from #128 and #132.

Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add record_replay_bookmark to V8 JSMessageObject
4197c82
Add record_replay_bookmark Smi field to JSMessageObject (object layout
change) and set it during message creation to track the recording
position at which the exception was created. Modifies the
NewJSMessageObject factory signature. Creating the bookmark can run
Replay's own JS, so the pending exception, pending message and
scheduled exception are saved and restored around it.

Includes later changes from #132.

Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@Domiii @Andarist
Freeze record/replay opcode emission per script
6e04270
Decide once per script whether its bytecode carries record/replay
instrumentation, so recompiles caused by bytecode flushing or cache
ageing get the same instrumentation as the first compile. The decision
is stored on the Script itself (a new record_replay_instrumented flag,
set in ParseInfo::CreateScript from the compile that creates the script)
and every later compile of that script inherits it through
RecordReplayInheritCompileFlags. The FinalizeBytecode CHECK that the
ignore flag matched the script is dropped, as it no longer holds.

Register a script as a Replay source as soon as its main-thread
compile finishes: ScriptCompiler::CompileUnboundInternal and the
streamed-source compile call RecordReplayRegisterCompiledScript,
instead of waiting for the script's function to be instantiated, which
never happens for an ES module whose import graph failed to load, so
the recording had no source for it. At the first checkpoint, the
progress counter is reset (with a ProgressBeforeFirstCheckpoint
warning if anything advanced it) and the sources registered until then
are announced, since the recorder only takes sources from the first
checkpoint on.

Invalidate the recording when --lazy-compile-dispatcher or
--parallel-compile-tasks is on: the dispatcher compiles functions on
worker threads whose timing decides when the main thread installs a
function's bytecode, or whether it waits for a worker, so such a
recording doesn't replay reliably. The flags are left as requested.

Also count the background compile tasks currently running, for
checking that record/replay opcodes are only emitted on the main
thread. Nothing reads the counter yet.

Rebase note: the invariant is that one script's bytecode is either
always instrumented or never, and that only main-thread compiles
instrument, so the decision belongs to ParseInfo::CreateScript and
every other path that builds UnoptimizedCompileFlags for an existing
script must take the flags from that script. A new Script flag bit
also needs its Torque bitfield (script.tq) kept in sync.

From #128, #132, #143 and #217.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add V8 AST/parser instrumentation for recording
ff9e412
Track call head token positions on AST nodes, add AstRawString
to_string(), and add parse-info record_replay_ignore flag. Modify
parser and preparser to propagate positions for replay breakpoint
placement. Set record_replay_ignore for scripts whose URL the recorder
asks to ignore, and for any script or eval compiled off the main
thread, while events are disallowed, or from replay code.

While replaying, force parameters and declared variables into the
context, so frames inspected in a replay see their real values instead
of registers the bytecode no longer keeps alive (RUN-2604, Chromium
feature: force-variable-context-allocation). Sloppy block function
bindings are forced too: one could still sit in a register, where an
async function optimized at one await and resumed unoptimized after
the next restored V8's stale register marker into the binding, which
inspecting the frame then saw. V8 already context-allocates these
bindings whenever a sloppy direct eval is in scope, so forcing them
changes no semantics.

Rebase note: forced context allocation has to cover every variable
kind a replay can inspect, so check DeclareVariable's kinds when
upstream adds one, and it has to stay replay-only, since it changes
the bytecode a function compiles to. record_replay_ignore must be set
for every compile the recorded main thread does not drive.

Includes later changes from #128, #132 and #205.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add V8 bytecodes for record/replay instrumentation
a584545
Add RecordReplayIncExecutionProgressCounter, Instrumentation,
InstrumentationGenerator, and AssertValue bytecodes with interpreter
handlers, baseline compiler visitors, and bytecode builder/generator
integration for tracking execution progress during recording. Add the
runtime functions backing them (assertions, instrumentation callbacks
and the instrumentation site registry).

With JS progress asserts enabled, each main-thread progress step
(script ID and function position) is buffered as recorder assert data,
so a mismatch names the functions where recording and replay diverged;
progress CHECKs can be enabled separately. Baseline code always calls
the runtime for progress and saves the accumulator around the call
(RUN-744). Exception unwinds while events are disallowed are not
reported.

The runtime function table also declares the baseline JIT's variants
of the progress, target-progress and instrumentation calls, which take
the accumulator as their last argument and return it, for the baseline
code that calls them instead of saving the accumulator itself.

Rebase note: record/replay opcodes are only emitted for a script the
recorder knows, on the main thread, and the bytecode a function
compiles to has to come out the same when recording and when
replaying, since an instrumentation site is identified by the index
embedded in its bytecode. The accumulator is live at progress and
instrumentation sites (after ResumeGenerator and at the start of a
catch block), so any JIT path that calls out there must preserve it.

Includes later changes from #128, #129, #132 and #207.

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add record_replay_bookmark to V8 JSMessageObject
7639023
Add record_replay_bookmark Smi field to JSMessageObject (object layout
change) and set it during message creation to track the recording
position at which the exception was created. Modifies the
NewJSMessageObject factory signature. Creating the bookmark can run
Replay's own JS, so the pending exception, pending message and
scheduled exception are saved and restored around it.

Includes later changes from #132.

Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@Domiii @Andarist
Block non-deterministic user JS while events are disallowed
52d4519
While events are disallowed (GC, compilation, driver commands) and the
replay has not diverged, user JS from registered scripts must not run:
it would advance the progress counter differently than when recording.
That condition is v8::replayio::MustNotRunUserJS(). Its comment
documents why it exists: Replay's inspector session work runs with
events disallowed and console message data is gathered only when
replaying, so user JS run from there would change the program's state
where the recording didn't. It also describes the alternative of
recording the session's work on both sides, and why recordings would
then show the program as if a debugger were attached.

Execution::Invoke refuses to call such functions and logs a
NonDeterministicUserJSBlocked warning with the trigger, the progress,
the function's location and the JS stack. Invoke and the API callback
entry points (HandleApiCallHelper, InvokeApiFunction,
HandleApiCallAsFunctionOrConstructor) rewind any progress (and
progress assert data) made on such paths through
RecordReplayScrubDivergentProgressScope, the progress runtime function
warns once with the JS stack when it happens
(NonDeterministicUserJSUngated), and Error.prepareStackTrace is
skipped while events are disallowed.

The Invoke gate doesn't catch the program's code called from a builtin
or called through a bound function or a proxy, so the inspector's
value descriptions gate on the same condition: describing an Error
returns a placeholder instead of reading its stack and message, and
Object::ConvertToString returns the default [object Object] string
instead of running ToPrimitive, which this V8 reaches when it
describes a logged Date. Upstream V8 made Date descriptions
side-effect free (25c69ecbc14), after which the ConvertToString gate
can go.

Discard a function's baseline code with events disallowed: the heap
walk enters a safepoint whose GC tracer scope reads the clock, and
whether the function has baseline code when a breakpoint is set can
differ between recording and replaying.

Register as Replay sources exactly the scripts whose bytecode is
instrumented, and announce them to the recorder from a separate
RecordReplayAnnounceScript: queued until the first checkpoint, since the
recorder only takes sources from there on, and skipped with a warning if
events are disallowed, which announcing would record an event in. A
script is also registered as soon as a main-thread compile finishes it
(RecordReplayRegisterCompiledScript), not only when its function is
instantiated. When listing a script's possible breakpoints, recompile a
top-level function the GC collected, so the functions only its bytecode
referenced have their breakpoints again.

The baseline JIT's progress and instrumentation runtime calls take the
accumulator as their last argument and return it
(Runtime_RecordReplayBaselineExecutionProgress,
Runtime_RecordReplayBaselineInstrumentation and its generator
variant): the calling frame's baseline code can be discarded while the
call is on the stack, and the frame then resumes in the interpreter
with the call's result as its accumulator.
Runtime_RecordReplayBaselineTargetProgressReached is called once the
counter that baseline code increments inline reaches the target
progress. Instrumentation sites are reported to the recorder by
function index rather than by bytecode offset.

Rebase note: new C++-to-JS entry points need a
RecordReplayScrubDivergentProgressScope, and user callbacks invoked
from V8 internals need the same MustNotRunUserJS() gating. The
invariant is about the program's state, not about one entry point:
anything Replay's own session can reach that would run user JS (an
accessor, a toString, a Symbol.toPrimitive) has to be gated, not just
the paths that go through Execution::Invoke.

From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Brian Hackett <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add V8 AST/parser instrumentation for recording
0b72667
Track call head token positions on AST nodes, add AstRawString
to_string(), and add parse-info record_replay_ignore flag. Modify
parser and preparser to propagate positions for replay breakpoint
placement. Set record_replay_ignore for scripts whose URL the recorder
asks to ignore, and for any script or eval compiled off the main
thread, while events are disallowed, or from replay code.

While replaying, force parameters and declared variables into the
context, so frames inspected in a replay see their real values instead
of registers the bytecode no longer keeps alive (RUN-2604, Chromium
feature: force-variable-context-allocation). Sloppy block function
bindings are forced too: one could still sit in a register, where an
async function optimized at one await and resumed unoptimized after
the next restored V8's stale register marker into the binding, which
inspecting the frame then saw. V8 already context-allocates these
bindings whenever a sloppy direct eval is in scope, so forcing them
changes no semantics.

Rebase note: forced context allocation has to cover every variable
kind a replay can inspect, so check DeclareVariable's kinds when
upstream adds one, and it has to stay replay-only, since it changes
the bytecode a function compiles to. record_replay_ignore must be set
for every compile the recorded main thread does not drive.

Includes later changes from #128, #132 and #205.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Add V8 bytecodes for record/replay instrumentation
f96ab82
Add RecordReplayIncExecutionProgressCounter, Instrumentation,
InstrumentationGenerator, and AssertValue bytecodes with interpreter
handlers, baseline compiler visitors, and bytecode builder/generator
integration for tracking execution progress during recording. Add the
runtime functions backing them (assertions, instrumentation callbacks
and the instrumentation site registry).

With JS progress asserts enabled, each main-thread progress step
(script ID and function position) is buffered as recorder assert data,
so a mismatch names the functions where recording and replay diverged;
progress CHECKs can be enabled separately. Baseline code always calls
the runtime for progress and saves the accumulator around the call
(RUN-744). Exception unwinds while events are disallowed are not
reported.

The runtime function table also declares the baseline JIT's variants
of the progress, target-progress and instrumentation calls, which take
the accumulator as their last argument and return it, for the baseline
code that calls them instead of saving the accumulator itself.

Rebase note: record/replay opcodes are only emitted for a script the
recorder knows, on the main thread, and the bytecode a function
compiles to has to come out the same when recording and when
replaying, since an instrumentation site is identified by the index
embedded in its bytecode. The accumulator is live at progress and
instrumentation sites (after ResumeGenerator and at the start of a
catch block), so any JIT path that calls out there must preserve it.

Includes later changes from #128, #129, #132 and #207.

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist pushed a commit that referenced this pull request Nov 6, 2026
@bhackett1024 @Andarist
Patch libuv for recording/replay determinism
d88e372
Add ordered lock/unlock around async operations, assertions in
filesystem, signal, stream, process, and kqueue code paths. Implement
uv_mutex_mark_ordered API for recording, disable uv_set_process_title
during replay, and add diagnostic logging for spawn operations.
The fs POST asserts are skipped while events are disallowed, since a
GC-driven FileHandle close can reach them there.

Rebase note: the invariants are (1) mutexes and async handles used
across threads (threadpool mutex, loop wq_mutex, uv_async_t) must be
ordered, and uv_async_send/uv__async_spin must release the handle's
ordered lock on every return path; (2) signal handles are mapped
through RegisterPointer/PointerId because the signal pipe's contents
are replayed verbatim; (3) on macOS, uv_cpu_info's CPU speed is
recorded manually because the underlying system calls are not
supported while recording. The V8RecordReplayAssert/Diagnostic calls in
fs.c, stream.c, process.c and kqueue.c only detect divergence; if
upstream reshapes those functions, re-add them next to the equivalent
syscalls.

Includes later changes from #132.

Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Domi <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bhackett1024 bhackett1024 bhackett1024 approved these changes
@Andarist Andarist Awaiting requested review from Andarist

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@Domiii Domiii

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@Domiii @bhackett1024
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.