GV

GeezerVison

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

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

On this site

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

This view

  • Original page
  • New address

GeezerVison is showing github.com — Port WeakRef and FinalizationRegistry record/replay from Chromium by Andarist · Pull Request #162 · replayio/node

Conversation

@Andarist

@Andarist Andarist commented Oct 1, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

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.

All reactions
@Andarist
Andarist added this pull request to stack #165 October 2, 2026 11:56
@Andarist Andarist changed the title Port WeakRef and FinalizationRegistry record/replay from the Chromium… Port WeakRef and FinalizationRegistry record/replay from Chromium Oct 2, 2026
@Andarist
Andarist force-pushed the claude/weakrefs-finalization-registry-port-193ca2 branch 5 times, most recently from 67a090c to e911ed0 Compare October 6, 2026 10:51
@Andarist
Andarist requested a review from Domiii October 7, 2026 09:11
Domiii
Domiii approved these changes Oct 7, 2026
View reviewed changes
@Andarist
Andarist force-pushed the claude/weakrefs-finalization-registry-port-193ca2 branch from e911ed0 to 2f60df2 Compare October 7, 2026 09:52
Andarist and others added 7 commits October 7, 2026 10:21
@Andarist @claude
Port WeakRef and FinalizationRegistry record/replay from the Chromium…
0a6ac08
… 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]>
@Andarist @claude
Update the WeakRef/FinalizationRegistry port to the current fork PRs
73327e9
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]>
@Andarist @claude
Track FinalizationRegistries deserialized from a snapshot
67537df
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)
@Andarist @claude
Keep the replay isolate data until the heap tear down has started
8d52fa5
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)
@Andarist @claude
Skip the WeakRef and FinalizationRegistry runtime calls when not reco…
e36c327
…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]>
@Andarist @claude
Return a WeakRef target as it is when events are unavailable
53c5543
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]>
@Andarist @claude
Say "deterministic point", not "point which replays"
72bddbe
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]>
@Andarist
Andarist force-pushed the claude/weakrefs-finalization-registry-port-193ca2 branch from 2f60df2 to 72bddbe Compare October 7, 2026 10:43
@Andarist
Andarist merged commit 0ea7a6e into master Oct 7, 2026
2 of 3 checks passed

Uh oh!

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

bhackett1024 pushed a commit that referenced this pull request Nov 5, 2026
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
2461e6a
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
@bhackett1024 @Domiii
@Andarist @claude
Add core V8 record/replay API surface
a094313
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
@Andarist @bhackett1024 @claude
Drive WeakRef and FinalizationRegistry from the recording
5772a01
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
@bhackett1024 @Domiii
@Andarist @claude
Add core V8 record/replay API surface
32a0ac1
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
@Andarist @bhackett1024 @claude
Drive WeakRef and FinalizationRegistry from the recording
d410b10
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
@bhackett1024 @Domiii
@Andarist @claude
Add core V8 record/replay API surface
d90615a
Add the v8::recordreplay public API class with methods for recording
state, event control, pointer registration, ordered locks, and the
C API bridge functions and driver symbol loading in api.cc.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Co-authored-by: Domi <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist added a commit that referenced this pull request Nov 10, 2026
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
5fe5004
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
3276389
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
@bhackett1024 @Andarist
Add core V8 record/replay API surface
3015ba1
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
bc89909
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
1107dca
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
@bhackett1024 @Andarist
Add core V8 record/replay API surface
9694169
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
c503bf0
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
@bhackett1024 @Andarist
Add core V8 record/replay API surface
1293d47
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
@bhackett1024 @Andarist
Add core V8 record/replay API surface
e995d76
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
@bhackett1024 @Andarist
Add core V8 record/replay API surface
eac606e
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
5771a08
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
@bhackett1024 @Andarist
Add core V8 record/replay API surface
e8adf39
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
c11b90c
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
dd97e78
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
047b36d
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
@bhackett1024 @Andarist
Add core V8 record/replay API surface
5e94ae9
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
ffd5f60
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
@bhackett1024 @Andarist
Add core V8 record/replay API surface
e05e971
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
60d0602
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
@bhackett1024 @Andarist
Add core V8 record/replay API surface
98815fc
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
825cd5c
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
@bhackett1024 @Andarist
Add core V8 record/replay API surface
eeeeda0
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
@bhackett1024 @Andarist
Add core V8 record/replay API surface
0644dd8
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
d960d1a
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
68184d5
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
@bhackett1024 @Andarist
Add core V8 record/replay API surface
235727c
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
@Andarist
Drive WeakRef and FinalizationRegistry from the recording
f3312bb
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
@bhackett1024 @Domiii
@Andarist @claude
Add core V8 record/replay API surface
28138f2
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
@Andarist @bhackett1024 @claude
Drive WeakRef and FinalizationRegistry from the recording
5fc6670
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
@bhackett1024 @Domiii
@Andarist @claude
Add core V8 record/replay API surface
3e5ca48
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Domiii Domiii Domiii approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

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