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 {
MaybeHandle<Object>* exception_out, bool reschedule_terminate);
static InvokeParams SetUpForRunMicrotasks(Isolate* isolate,
MicrotaskQueue* microtask_queue,
MaybeHandle<Object>* exception_out);
MicrotaskQueue* microtask_queue);
bool IsScript() const {
if (!target->IsJSFunction()) return false;
......@@ -152,8 +151,7 @@ InvokeParams InvokeParams::SetUpForTryCall(
// static
InvokeParams InvokeParams::SetUpForRunMicrotasks(
Isolate* isolate, MicrotaskQueue* microtask_queue,
MaybeHandle<Object>* exception_out) {
Isolate* isolate, MicrotaskQueue* microtask_queue) {
auto undefined = isolate->factory()->undefined_value();
InvokeParams params;
params.target = undefined;
......@@ -163,7 +161,7 @@ InvokeParams InvokeParams::SetUpForRunMicrotasks(
params.new_target = undefined;
params.microtask_queue = microtask_queue;
params.message_handling = Execution::MessageHandling::kReport;
params.exception_out = exception_out;
params.exception_out = nullptr;
params.is_construct = false;
params.execution_target = Execution::Target::kRunMicrotasks;
params.reschedule_terminate = true;
......@@ -503,6 +501,8 @@ MaybeHandle<Object> InvokeWithTryCatch(Isolate* isolate,
isolate->OptionalRescheduleException(true);
}
}
} else {
DCHECK(!isolate->has_pending_exception());
}
}
......@@ -594,11 +594,9 @@ MaybeHandle<Object> Execution::TryCall(
// static
MaybeHandle<Object> Execution::TryRunMicrotasks(
Isolate* isolate, MicrotaskQueue* microtask_queue,
MaybeHandle<Object>* exception_out) {
Isolate* isolate, MicrotaskQueue* microtask_queue) {
return InvokeWithTryCatch(
isolate, InvokeParams::SetUpForRunMicrotasks(isolate, microtask_queue,
exception_out));
isolate, InvokeParams::SetUpForRunMicrotasks(isolate, microtask_queue));
}
struct StackHandlerMarker {
......
......@@ -68,9 +68,8 @@ class Execution final : public AllStatic {
bool reschedule_terminate = true);
// Convenience method for performing RunMicrotasks
static MaybeHandle<Object> TryRunMicrotasks(
Isolate* isolate, MicrotaskQueue* microtask_queue,
MaybeHandle<Object>* exception_out);
static MaybeHandle<Object> TryRunMicrotasks(Isolate* isolate,
MicrotaskQueue* microtask_queue);
#if V8_ENABLE_WEBASSEMBLY
// Call a Wasm function identified by {wasm_call_target} through the
......
......@@ -156,7 +156,6 @@ int MicrotaskQueue::RunMicrotasks(Isolate* isolate) {
intptr_t base_count = finished_microtask_count_;
HandleScope handle_scope(isolate);
MaybeHandle<Object> maybe_exception;
MaybeHandle<Object> maybe_result;
......@@ -170,8 +169,7 @@ int MicrotaskQueue::RunMicrotasks(Isolate* isolate) {
TRACE_EVENT_BEGIN0("v8.execute", "RunMicrotasks");
{
TRACE_EVENT_CALL_STATS_SCOPED(isolate, "v8", "V8.RunMicrotasks");
maybe_result = Execution::TryRunMicrotasks(isolate, this,
&maybe_exception);
maybe_result = Execution::TryRunMicrotasks(isolate, this);
processed_microtask_count =
static_cast<int>(finished_microtask_count_ - base_count);
}
......@@ -179,16 +177,14 @@ int MicrotaskQueue::RunMicrotasks(Isolate* isolate) {
processed_microtask_count);
}
DCHECK_IMPLIES(isolate->has_scheduled_exception(),
maybe_result.is_null() && maybe_exception.is_null());
// If execution is terminating, clean up and propagate that to TryCatch scope.
if (maybe_result.is_null() && maybe_exception.is_null()) {
if (isolate->is_execution_terminating()) {
DCHECK(isolate->has_scheduled_exception());
DCHECK(maybe_result.is_null());
delete[] ring_buffer_;
ring_buffer_ = nullptr;
capacity_ = 0;
size_ = 0;
start_ = 0;
DCHECK(isolate->has_scheduled_exception());
isolate->OnTerminationDuringRunMicrotasks();
OnCompleted(isolate);
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