GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com (truncated) — Don't run user code while the inspector describes values with events disallowed by Andarist · Pull Request #224 · replayio/node Conversation
Member
Port replayio/chromium-v8#317 (crash-0074) and replayio/chromium-v8#320 The ConvertToString gate is only needed because this V8 converts Dates with Without events disallowed, or once the replay has diverged (pauses, Not ported: replayio/chromium-v8#309 (crash-0043, addBinding with a
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactionsThe checks that keep user JS from running while Replay's own code runs (the JSInvoke gate, the progress warning, descriptionForError, ConvertToString) all test the same condition. Name it MustNotRunUserJS and document there why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. The comment also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Same helper as replayio/chromium-v8@27b55d29518. Add a TODO to install Replay's session only when replaying, as Chromium does, with what that needs: the session makes console calls run V8's console method, whose message text runs user ToString. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Andarist
force-pushed
the
andarist/inspector-user-js-gates
branch
from
6a93eb9 to
b36a21c
Compare
Uh oh!
There was an error while loading. Please reload this page.
bhackett1024
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
bhackett1024
added a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
added a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
added a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
added a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
added a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
added a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
added a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
added a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
added a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
added a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
added a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Describing an Error for the inspector does not read its name either, for the same reason it does not read its message: both can run a getter the recording did not. Reading a property's descriptor can run user code too: node defines its lazy globals (FormData, Headers, Request, Response, WebSocket, ...) with SetLazyDataProperty, whose replace-on-access getter loads the module, and on the global proxy the inspector does not report them as native accessors. Replay's own session describes the global object for every pause's scope chain with events disallowed, where loading undici needs recorded calls the recording does not have. Report a lazy data property that has not loaded yet as a native getter instead, as the inspector does for other native accessors; a session a user or the program attached runs with events allowed and still loads it. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathered only when replaying, so user JS run from there would change the program's state where the recording didn't. It also describes the alternative of recording the session's work on both sides, and why recordings would then show the program as if a debugger were attached. Execution::Invoke refuses to call such functions and logs a NonDeterministicUserJSBlocked warning with the trigger, the progress, the function's location and the JS stack. Invoke and the API callback entry points (HandleApiCallHelper, InvokeApiFunction, HandleApiCallAsFunctionOrConstructor) rewind any progress (and progress assert data) made on such paths through RecordReplayScrubDivergentProgressScope, the progress runtime function warns once with the JS stack when it happens (NonDeterministicUserJSUngated), and Error.prepareStackTrace is skipped while events are disallowed. The Invoke gate doesn't catch the program's code called from a builtin or called through a bound function or a proxy, so the inspector's value descriptions gate on the same condition: describing an Error returns a placeholder instead of reading its stack and message, and Object::ConvertToString returns the default [object Object] string instead of running ToPrimitive, which this V8 reaches when it describes a logged Date. Upstream V8 made Date descriptions side-effect free (25c69ecbc14), after which the ConvertToString gate can go. Previews gate on it as well: to show a value instead of an accessor, V8 reads a getter that reports no script id, which is every callable the Invoke gate misses, so Replay's own session leaves the property an accessor for the viewer to call. V8 9.4 read it with CallFunctionOn() and throw_on_side_effect, where a getter that did anything was skipped; 10.2 replaced that with a plain Get() guarded only by a list of DOM attribute names. The Chromium fork gates the same site with an allow-list of those names (replayio/chromium-v8@91c06b051a5). Discard a function's baseline code with events disallowed: the heap walk enters a safepoint whose GC tracer scope reads the clock, and whether the function has baseline code when a breakpoint is set can differ between recording and replaying. Register as Replay sources exactly the scripts whose bytecode is instrumented, and announce them to the recorder from a separate RecordReplayAnnounceScript: queued until the first checkpoint, since the recorder only takes sources from there on, and skipped with a warning if events are disallowed, which announcing would record an event in. A script is also registered as soon as a main-thread compile finishes it (RecordReplayRegisterCompiledScript), not only when its function is instantiated. When listing a script's possible breakpoints, recompile a top-level function the GC collected, so the functions only its bytecode referenced have their breakpoints again. The baseline JIT's progress and instrumentation runtime calls take the accumulator as their last argument and return it (Runtime_RecordReplayBaselineExecutionProgress, Runtime_RecordReplayBaselineInstrumentation and its generator variant): the calling frame's baseline code can be discarded while the call is on the stack, and the frame then resumes in the interpreter with the call's result as its accumulator. Runtime_RecordReplayBaselineTargetProgressReached is called once the counter that baseline code increments inline reaches the target progress. Instrumentation sites are reported to the recorder by function index rather than by bytecode offset. Reading a property's descriptor can run user code too: node defines its lazy globals (FormData, Headers, Request, Response, WebSocket, ...) with SetLazyDataProperty, whose replace-on-access getter loads the module, and on the global proxy the inspector does not report them as native accessors. Replay's own session describes the global object for every pause's scope chain with events disallowed, where loading undici needs recorded calls the recording does not have. Report a lazy data property that has not loaded yet as a native getter instead, as the inspector does for other native accessors; a session a user or the program attached runs with events allowed and still loads it. Rebase note: new C++-to-JS entry points need a RecordReplayScrubDivergentProgressScope, and user callbacks invoked from V8 internals need the same MustNotRunUserJS() gating. The invariant is about the program's state, not about one entry point: anything Replay's own session can reach that would run user JS (an accessor, a toString, a Symbol.toPrimitive) has to be gated, not just the paths that go through Execution::Invoke. Upstream keeps reworking how a preview decides to read a getter; whatever that condition becomes, it has to keep the gate ahead of it, since the side-effect helper it calls can run user JS itself. From #128, #132, #159, #202, #203, #206, #207, #211, #217 and #224. Co-authored-by: Mateusz Burzyński <[email protected]> Co-authored-by: Brian Hackett <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
Add the lib/internal/recordreplay/ module with main entry point,
message handling, object inspection, console preview generation,
source map support, and utilities for the recording/replay system.
Add the internal/recordreplay modules to the expected list in
test-bootstrap-modules.
Report a console message's level from the type of its
Runtime.consoleAPICalled event ("log", "warning", "error", ...),
mapped the way Chromium's replay command handlers do, since the event
carries no level field and every message was reported as "info".
Describe a scope binding CDP gives no value for as an unavailable
value: Runtime.getProperties omits the value of a binding the
inspector can't describe, such as a register that was dead at an await
and holds V8's stale_register marker after the function's optimized
code was deoptimized, and passing the missing value on threw, so
Pause.getScope returned no scope at all.
Record next to the session setup why Replay's session is installed on
both sides here, unlike Chromium, which installs it only when
replaying: connecting it makes the inspector agent active, so console
calls run V8's console method, whose message text converts Dates,
Errors, functions and RegExps with ToString, i.e. user JS, and that
has to stay the same when recording and replaying.
Rebase note: this is new code under lib/internal/recordreplay/, so
conflicts should only come from the list in test-bootstrap-modules
(the bootstrap hook that loads it is a separate commit). The commands
implemented here must keep matching the driver's expectations and the
process.recordreplay methods they call, and anything this code runs
that touches the program's own objects must stay inside a pause, where
the replay has diverged, rather than running while Replay's session
describes a value.
Includes later changes from #152, #204 and #224.
Co-authored-by: Holger Benl <[email protected]>
Co-authored-by: Mateusz Burzyński <[email protected]>
Co-authored-by: Logan Smyth <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Andarist
pushed a commit
that referenced
this pull request
While events are disallowed (GC, compilation, driver commands) and the replay has not diverged, user JS from registered scripts must not run: it would advance the progress counter differently than when recording. That condition is v8::replayio::MustNotRunUserJS(). Its comment documents why it exists: Replay's inspector session work runs with events disallowed and console message data is gathe |
| 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. |