Commit ef9eec04 authored by Camillo's avatar Camillo Committed by V8 LUCI CQ

[execution] Fix microtask error reporting DCHECKs

Previously we've added has_scheduled_exception DCHECKs that were a bit
too strict in some cases.

- Remove unused exception_out param for TryRunMicrotasks
- Simplify overzealous DCHECK and clean up MicrotaskQueue::RunMicrotasks

Change-Id: I3a945a731573b6b3e44e17487fb8bf871b9a6793
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3789504
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarVictor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82131}
parent 814e6b0b
...@@ -49,8 +49,7 @@ struct InvokeParams { ...@@ -49,8 +49,7 @@ struct InvokeParams {
MaybeHandle<Object>* exception_out, bool reschedule_terminate); MaybeHandle<Object>* exception_out, bool reschedule_terminate);
static InvokeParams SetUpForRunMicrotasks(Isolate* isolate, static InvokeParams SetUpForRunMicrotasks(Isolate* isolate,
MicrotaskQueue* microtask_queue, MicrotaskQueue* microtask_queue);
MaybeHandle<Object>* exception_out);
bool IsScript() const { bool IsScript() const {
if (!target->IsJSFunction()) return false; if (!target->IsJSFunction()) return false;
...@@ -152,8 +151,7 @@ InvokeParams InvokeParams::SetUpForTryCall( ...@@ -152,8 +151,7 @@ InvokeParams InvokeParams::SetUpForTryCall(
// static // static
InvokeParams InvokeParams::SetUpForRunMicrotasks( InvokeParams InvokeParams::SetUpForRunMicrotasks(
Isolate* isolate, MicrotaskQueue* microtask_queue, Isolate* isolate, MicrotaskQueue* microtask_queue) {
MaybeHandle<Object>* exception_out) {
auto undefined = isolate->factory()->undefined_value(); auto undefined = isolate->factory()->undefined_value();
InvokeParams params; InvokeParams params;
params.target = undefined; params.target = undefined;
...@@ -163,7 +161,7 @@ InvokeParams InvokeParams::SetUpForRunMicrotasks( ...@@ -163,7 +161,7 @@ InvokeParams InvokeParams::SetUpForRunMicrotasks(
params.new_target = undefined; params.new_target = undefined;
params.microtask_queue = microtask_queue; params.microtask_queue = microtask_queue;
params.message_handling = Execution::MessageHandling::kReport; params.message_handling = Execution::MessageHandling::kReport;
params.exception_out = exception_out; params.exception_out = nullptr;
params.is_construct = false; params.is_construct = false;
params.execution_target = Execution::Target::kRunMicrotasks; params.execution_target = Execution::Target::kRunMicrotasks;
params.reschedule_terminate = true; params.reschedule_terminate = true;
...@@ -503,6 +501,8 @@ MaybeHandle<Object> InvokeWithTryCatch(Isolate* isolate, ...@@ -503,6 +501,8 @@ MaybeHandle<Object> InvokeWithTryCatch(Isolate* isolate,
isolate->OptionalRescheduleException(true); isolate->OptionalRescheduleException(true);
} }
} }
} else {
DCHECK(!isolate->has_pending_exception());
} }
} }
...@@ -594,11 +594,9 @@ MaybeHandle<Object> Execution::TryCall( ...@@ -594,11 +594,9 @@ MaybeHandle<Object> Execution::TryCall(
// static // static
MaybeHandle<Object> Execution::TryRunMicrotasks( MaybeHandle<Object> Execution::TryRunMicrotasks(
Isolate* isolate, MicrotaskQueue* microtask_queue, Isolate* isolate, MicrotaskQueue* microtask_queue) {
MaybeHandle<Object>* exception_out) {
return InvokeWithTryCatch( return InvokeWithTryCatch(
isolate, InvokeParams::SetUpForRunMicrotasks(isolate, microtask_queue, isolate, InvokeParams::SetUpForRunMicrotasks(isolate, microtask_queue));
exception_out));
} }
struct StackHandlerMarker { struct StackHandlerMarker {
......
...@@ -68,9 +68,8 @@ class Execution final : public AllStatic { ...@@ -68,9 +68,8 @@ class Execution final : public AllStatic {
bool reschedule_terminate = true); bool reschedule_terminate = true);
// Convenience method for performing RunMicrotasks // Convenience method for performing RunMicrotasks
static MaybeHandle<Object> TryRunMicrotasks( static MaybeHandle<Object> TryRunMicrotasks(Isolate* isolate,
Isolate* isolate, MicrotaskQueue* microtask_queue, MicrotaskQueue* microtask_queue);
MaybeHandle<Object>* exception_out);
#if V8_ENABLE_WEBASSEMBLY #if V8_ENABLE_WEBASSEMBLY
// Call a Wasm function identified by {wasm_call_target} through the // Call a Wasm function identified by {wasm_call_target} through the
......
...@@ -156,7 +156,6 @@ int MicrotaskQueue::RunMicrotasks(Isolate* isolate) { ...@@ -156,7 +156,6 @@ int MicrotaskQueue::RunMicrotasks(Isolate* isolate) {
intptr_t base_count = finished_microtask_count_; intptr_t base_count = finished_microtask_count_;
HandleScope handle_scope(isolate); HandleScope handle_scope(isolate);
MaybeHandle<Object> maybe_exception;
MaybeHandle<Object> maybe_result; MaybeHandle<Object> maybe_result;
...@@ -170,8 +169,7 @@ int MicrotaskQueue::RunMicrotasks(Isolate* isolate) { ...@@ -170,8 +169,7 @@ int MicrotaskQueue::RunMicrotasks(Isolate* isolate) {
TRACE_EVENT_BEGIN0("v8.execute", "RunMicrotasks"); TRACE_EVENT_BEGIN0("v8.execute", "RunMicrotasks");
{ {
TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.RunMicrotasks"); TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.RunMicrotasks");
maybe_result = Execution::TryRunMicrotasks(isolate, this, maybe_result = Execution::TryRunMicrotasks(isolate, this);
&maybe_exception);
processed_microtask_count = processed_microtask_count =
static_cast<int>(finished_microtask_count_ - base_count); static_cast<int>(finished_microtask_count_ - base_count);
} }
...@@ -179,16 +177,14 @@ int MicrotaskQueue::RunMicrotasks(Isolate* isolate) { ...@@ -179,16 +177,14 @@ int MicrotaskQueue::RunMicrotasks(Isolate* isolate) {
processed_microtask_count); processed_microtask_count);
} }
DCHECK_IMPLIES(isolate->has_scheduled_exception(), if (isolate->is_execution_terminating()) {
maybe_result.is_null() && maybe_exception.is_null()); DCHECK(isolate->has_scheduled_exception());
// If execution is terminating, clean up and propagate that to TryCatch scope. DCHECK(maybe_result.is_null());
if (maybe_result.is_null() && maybe_exception.is_null()) {
delete[] ring_buffer_; delete[] ring_buffer_;
ring_buffer_ = nullptr; ring_buffer_ = nullptr;
capacity_ = 0; capacity_ = 0;
size_ = 0; size_ = 0;
start_ = 0; start_ = 0;
DCHECK(isolate->has_scheduled_exception());
isolate->OnTerminationDuringRunMicrotasks(); isolate->OnTerminationDuringRunMicrotasks();
OnCompleted(isolate); OnCompleted(isolate);
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment