From b06cca35005717557b42540417c2fd7cf1282bb6 Mon Sep 17 00:00:00 2001 From: "D. Seifert" Date: Wed, 16 Apr 2025 00:11:24 +0800 Subject: [PATCH 01/20] Replay the error message building i `MessageFormatter::Format` --- include/v8.h | 1 + src/api/api.cc | 8 ++++++++ src/execution/messages.cc | 10 +++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/v8.h b/include/v8.h index 990466212b3c..b2575a731140 100644 --- a/include/v8.h +++ b/include/v8.h @@ -121,6 +121,7 @@ static bool AreAssertsDisabled(); static uintptr_t RecordReplayValue(const char* why, uintptr_t v); static void RecordReplayBytes(const char* why, void* buf, size_t size); +static void RecordReplayString(const char* why, std::string& str); static size_t CreateOrderedLock(const char* name); static void OrderedLock(int lock); diff --git a/src/api/api.cc b/src/api/api.cc index 33a5574d7dc1..da477c87bb6c 100644 --- a/src/api/api.cc +++ b/src/api/api.cc @@ -11550,6 +11550,14 @@ extern "C" DLLEXPORT void V8RecordReplayBytes(const char* why, void* buf, size_t recordreplay::RecordReplayBytes(why, buf, size); } +void recordreplay::RecordReplayString(const char* why, std::string& str) { + size_t length = RecordReplayValue(why, str.length()); + str.resize(length); + if (length) { + RecordReplayBytes(why, &str[0], length); + } +} + bool recordreplay::AreEventsDisallowed(const char* why) { if (IsRecordingOrReplaying("disallow-events", why)) { return gRecordReplayAreEventsDisallowed(); diff --git a/src/execution/messages.cc b/src/execution/messages.cc index 25a6cba3bf55..d0387927ae4b 100644 --- a/src/execution/messages.cc +++ b/src/execution/messages.cc @@ -518,7 +518,15 @@ MaybeHandle MessageFormatter::Format(Isolate* isolate, } } - return builder.Finish(); + + MaybeHandle rv = builder.Finish(); + if (recordreplay::IsRecordingOrReplEaying("MessageFormatter::Format")) { + // [PRO-1150] Replay error messages. + std::string str = rv.ToHandleChecked()->ToCString(); + recordreplay::RecordReplayString("MessageFormatter::Format", str); + rv = isolate->factory()->NewStringFromUtf8(base::CStrVector(str.c_str())); + } + return rv; } MaybeHandle ErrorUtils::Construct(Isolate* isolate, From 4a42d95883bbbe97f614f884e636322c60ae03bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 15 Apr 2025 18:22:14 +0200 Subject: [PATCH 02/20] Remove error suppression in unregistered scripts --- src/api/api.cc | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/api/api.cc b/src/api/api.cc index 33a5574d7dc1..24da84c68515 100644 --- a/src/api/api.cc +++ b/src/api/api.cc @@ -10969,30 +10969,6 @@ void RecordReplayOnExceptionUnwind(Isolate* isolate) { if (!isolate->is_catchable_by_javascript(*exception)) return; - { - // Note: Most of this is copied from |ComputeLocation| in messages.cc. - JavaScriptFrameIterator it(isolate); - if (!it.done()) { - // Compute the location from the function and the relocation info of the - // baseline code. For optimized code this will use the deoptimization - // information to get canonical location information. - std::vector frames; - it.frame()->Summarize(&frames); - if (!frames.empty()) { // There might not always be a frame due to RUN-1920. - auto& summary = frames.back().AsJavaScript(); - Handle shared(summary.function()->shared(), isolate); - Handle script(shared->script(), isolate); - if (script->IsScript()) { - Handle