GeezerVison is showing github.com — Port WeakRef and FinalizationRegistry record/replay from Chromium by Andarist · Pull Request #162 · replayio/node
Conversation
Andarist
commented
Oct 1, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
ports:
replayio/chromium-v8#279
replayio/chromium-v8#334
replayio/chromium-v8#335
This is needed in preparation for #161 . Without this landing #161 would start crashing for a bunch of recorded journeys etc because FinalizationRegistry is much more prevalent in node code than it is in browser code. For example, undici is using it
Node-specific behaviour worth knowing (no changes made):
- Node also calls
ClearKeptObjects on every top-level callback exit (src/api/callback.cc:129), so the poll runs more often than in Chromium. Those points happen identically when recording and replaying, so it only adds recorded values.
- Node core creates FinalizationRegistries and WeakRefs itself (
event_target.js, abort_controller.js, iterable_weak_map.js). Once one of them registers a cell or creates a WeakRef, every recording records a poll value at each checkpoint from then on. The fork's comments already acknowledge these flags are never reset.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Andarist
changed the title
Port WeakRef and FinalizationRegistry record/replay from the Chromium…
Port WeakRef and FinalizationRegistry record/replay from Chromium
Oct 2, 2026
… fork
Port replayio/chromium-v8#279, #334 and #335, ending at the state of #335:
- WeakRef.prototype.deref() records/replays whether the target is alive.
When replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field.
- FinalizationRegistry cleanup of registries constructed at a point that
replays ("tracked", behind the "finalization-registry" feature) is
driven by the recording: the GC no longer schedules the cleanup task for
them, ReplayFinalizationRegistries::Poll records the decision at every
microtask checkpoint, and the cleanup loop records which cell each
callback is called for. When replaying, the targets of tracked cells are
marked strongly, and the recorded cells are cleared right before their
callbacks run. Registries the recording's GC collected are released.
- unregister() and register() of a tracked cell while events are
disallowed crash, since they would change the registry on one side only.
- Per-isolate replay state lives in ReplayIsolateData, reset in
Isolate::Deinit before the global handles go away.
V8 9.4 adaptations: JSFinalizationRegistry accessors are hand-written, the
unregister bookkeeping hooks into Unregister's match callback, and
recordreplay::AreEventsPassedThrough is added (chromium-v8 f6f61489066).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Bring the port in line with the latest replayio/chromium-v8#334 and #335
(up to 609b71dddca):
- Rename the added fields and runtime functions with the record_replay /
RecordReplay prefix, and pass Heap::RecordReplayTracking to the dirty
registry helpers and the cleanup task. Heap::DequeueDirtyJSFinalizationRegistry
loses its last caller and is removed.
- Record what the GC did to tracked registries and WeakRefs in a single
ReplayGCPoll::Poll at every microtask checkpoint.
- Track WeakRefs constructed at a deterministic point ("weak-ref-collection"
feature): the recording notes which ones its GC cleared, and the replay
clears the same targets instead of keeping them alive until the WeakRef
goes away. The list of tracked WeakRefs lives in old space.
- Give a WeakCell its id before it is linked into the registry, cache
IsReplaying() in the marking visitor, and crash when a replayed deref()
or a delivered cell disagrees with the recording.
V8 9.4 adaptations: src/replay/replayio.{h,cc} only carry
AreEventsAvailable(), global-handles.h replaces global-handles-inl.h, and
the Torque constructor uses assert where the fork uses dcheck.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A FinalizationRegistry gets its record/replay id when it is
constructed. One deserialized from the startup snapshot, like the
registry AbortSignal.timeout() uses, was constructed when the snapshot
was built and so has none, and its cleanup task was posted from inside
the GC and run at a point which depends on when the GC ran.
Give a registry without an id one on its first register() call, when
it has no cells yet, so that it is tracked like any other from then
on.
When the GC still finds cleared cells of a registry without an id
(the feature is off, or the registry was populated before it could be
adopted), leave them uncollected instead of running the cleanup at a
GC-dependent point, and report it as a diagnostic once.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit cf7518182391241161b1981647add940da5c7e9b)
Isolate::Deinit reset it before debug()->Unload() and the wasm compile
job cleanup, which can still allocate and so run a GC. A mark-compact
in that window which cleared a tracked WeakRef's target called
ReplayWeakRefs::OnTargetCleared on the reset data.
Reset it after Heap::StartTearDown, after which no GC runs and before
the global handles its v8::Globals need are destroyed, and have
OnTargetCleared tolerate missing data like ReplayGCPoll::Poll does.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit ba9caeffae56707d94b22e2b1b174845e5da4bca)
…rding or replaying
Port of replayio/chromium-v8#343, first commit.
WeakRef.prototype.deref(), the WeakRef constructor, the
FinalizationRegistry constructor and register() each called a
RecordReplay* runtime function unconditionally. Outside record/replay
those functions do nothing, but the builtin-to-runtime transition costs
every caller: deref() went from an inline field load to a runtime call.
The process-wide recording flag is now readable by generated code through
ExternalReference::record_replay_is_recording_or_replaying, and the
builtins only call the runtime when it is set. When it is clear, deref()
loads the target inline as upstream does and the record/replay ids stay 0,
which the runtime side already treats as untracked. The flag is set by
recordreplay::SetRecordingOrReplaying before any isolate exists and never
changes, and it is per process like recordreplay::IsRecordingOrReplaying().
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Port of replayio/chromium-v8#343, second commit.
Runtime_RecordReplayWeakRefDeref recorded the target's liveness even
where the driver cannot record or replay a value, e.g. while a pause
evaluates an expression which calls deref(). The driver passed the
value through, so the result was the current target either way, but it
added a recording warning on every call.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
What the record/replay bookkeeping needs is a point whose behaviour is
semantically deterministic between recording and replay, where the same
state is reached and the same decisions are made, so that a value recorded
or cleanup run there reproduces. "A point which replays" named it badly:
GC points replay too, at other places. Comments and diagnostics only.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
bhackett1024
pushed a commit
that referenced
this pull request
Nov 5, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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
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
added a commit
that referenced
this pull request
Nov 6, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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
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
added a commit
that referenced
this pull request
Nov 6, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
nodejs#343). WeakRef.prototype.deref() records whether its target is alive;
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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
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
added a commit
that referenced
this pull request
Nov 6, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
nodejs#343). WeakRef.prototype.deref() records whether its target is alive;
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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
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
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
added a commit
that referenced
this pull request
Nov 6, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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
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
added a commit
that referenced
this pull request
Nov 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 10, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.
The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.
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
added a commit
that referenced
this pull request
Nov 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Node 24's V8 drives the FinalizationRegistry cleanup loop from Torque, so the
gate that keeps the loop from running user callbacks at a point the replay
does not reach moves into C++ where the loop now lives.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 10, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.
The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.
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
added a commit
that referenced
this pull request
Nov 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Node 24's V8 drives the FinalizationRegistry cleanup loop from Torque, so the
gate that keeps the loop from running user callbacks at a point the replay
does not reach moves into C++ where the loop now lives.
Node 26 moves the weak-reference accessors behind new names, so the fork's
calls follow them.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 10, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
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 10, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.
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 10, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.
The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.
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
added a commit
that referenced
this pull request
Nov 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 10, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.
The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.
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
added a commit
that referenced
this pull request
Nov 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Node 24's V8 drives the FinalizationRegistry cleanup loop from Torque, so the
gate that keeps the loop from running user callbacks at a point the replay
does not reach moves into C++ where the loop now lives.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Node 24's V8 drives the FinalizationRegistry cleanup loop from Torque, so the
gate that keeps the loop from running user callbacks at a point the replay
does not reach moves into C++ where the loop now lives.
Node 26 moves the weak-reference accessors behind new names, so the fork's
calls follow them.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 10, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.
The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.
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
added a commit
that referenced
this pull request
Nov 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Node 24's V8 drives the FinalizationRegistry cleanup loop from Torque, so the
gate that keeps the loop from running user callbacks at a point the replay
does not reach moves into C++ where the loop now lives.
Node 26 moves the weak-reference accessors behind new names, so the fork's
calls follow them.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 10, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.
The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.
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
added a commit
that referenced
this pull request
Nov 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Node 24's V8 drives the FinalizationRegistry cleanup loop from Torque, so the
gate that keeps the loop from running user callbacks at a point the replay
does not reach moves into C++ where the loop now lives.
Node 26 moves the weak-reference accessors behind new names, so the fork's
calls follow them.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 10, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.
The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.
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
added a commit
that referenced
this pull request
Nov 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Node 24's V8 drives the FinalizationRegistry cleanup loop from Torque, so the
gate that keeps the loop from running user callbacks at a point the replay
does not reach moves into C++ where the loop now lives.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 10, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
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 10, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.
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
added a commit
that referenced
this pull request
Nov 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 10, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 11, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.
The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.
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
added a commit
that referenced
this pull request
Nov 11, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Node 24's V8 drives the FinalizationRegistry cleanup loop from Torque, so the
gate that keeps the loop from running user callbacks at a point the replay
does not reach moves into C++ where the loop now lives.
Node 26 moves the weak-reference accessors behind new names, so the fork's
calls follow them.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 11, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.
The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.
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
added a commit
that referenced
this pull request
Nov 11, 2026
Ported from the Chromium fork (replayio/chromium-v8#279, #334, #335 and
when replaying, marking treats JSWeakRef::target as strong and a deref()
the recording saw as dead clears the field. WeakRefs constructed at a
deterministic point are tracked ("weak-ref-collection"), so the replay
clears the targets the recording's GC cleared instead of keeping them
alive.
Cleanup of tracked FinalizationRegistries ("finalization-registry") is
driven by the recording too: the GC no longer schedules their cleanup
task, ReplayGCPoll::Poll records at every microtask checkpoint what the
GC did (cleanup task wanted, registries collected, WeakRefs cleared),
and the cleanup loop records which cell each callback runs for. A
registry deserialized from the snapshot gets its id on its first
register(). register() or unregister() of a tracked cell while events
are disallowed crashes, since it would change the registry on one side
only. Per-isolate state lives in ReplayIsolateData, released after
Heap::StartTearDown.
Node 24's V8 drives the FinalizationRegistry cleanup loop from Torque, so the
gate that keeps the loop from running user callbacks at a point the replay
does not reach moves into C++ where the loop now lives.
Node 26 moves the weak-reference accessors behind new names, so the fork's
calls follow them.
Rebase note: a GC must never decide by itself when a WeakRef reads empty
or when a cleanup callback runs; new upstream paths that clear cells or
post the cleanup task need the same recording. The builtins only call
the RecordReplay runtime functions when the process-wide recording flag
is set, and a record/replay id of 0 means untracked.
From #162.
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 11, 2026
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.
V8 11.3 gives Code::OptimizedCodeIterator a SafepointScope, and entering a
safepoint samples the time to reach it, so walking the optimized code reads
the clock where V8 10.2 walked the native contexts list and read nothing.
RecordReplayChangeInstrument walks that code to deoptimize it and the driver
only changes the instrumentation while replaying, so the walk runs with
events disallowed, as Debug::DiscardBaselineCode already does for its own.
Moving a pending exception aside to report it leaves any TryCatch the embedder
installed alone: node 22's V8 reports through the embedder's handler, so
clearing it there swallowed exceptions the embedder was waiting for.
The progress counter's external reference is kept out of the nullptr slot:
V8 13.6 CHECKs that external references are deduplicated when the snapshot is
loaded, so a driver-filled pointer that is still null at that point collides
with every other null one.
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]>
Reviewers
Domiii
Domiii approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
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.
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.
|