Commit 09479110 authored by Jochen Eisinger's avatar Jochen Eisinger Committed by V8 LUCI CQ

Add microtasks scope to FinalizationRegistryCleanupTask

This task calls through the V8 API, so it needs to create a microtasks
scope.

Bug: chromium:728583
Change-Id: I47108a64575f1bd670eaea6c8a06720dd4d5552c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2865605Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74318}
parent 7134d7f6
......@@ -59,8 +59,21 @@ void FinalizationRegistryCleanupTask::RunInternal() {
Context::cast(finalization_registry->native_context()), isolate);
Handle<Object> callback(finalization_registry->cleanup(), isolate);
v8::Context::Scope context_scope(v8::Utils::ToLocal(context));
v8::TryCatch catcher(reinterpret_cast<v8::Isolate*>(isolate));
v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
v8::TryCatch catcher(v8_isolate);
catcher.SetVerbose(true);
std::unique_ptr<MicrotasksScope> microtasks_scope;
MicrotaskQueue* microtask_queue =
finalization_registry->native_context().microtask_queue();
if (!microtask_queue) microtask_queue = isolate->default_microtask_queue();
if (microtask_queue &&
microtask_queue->microtasks_policy() == v8::MicrotasksPolicy::kScoped) {
// InvokeFinalizationRegistryCleanupFromTask will call into V8 API methods,
// so we need a valid microtasks scope on the stack to avoid running into
// the CallDepthScope check.
microtasks_scope.reset(new v8::MicrotasksScope(
v8_isolate, microtask_queue, v8::MicrotasksScope::kDoNotRunMicrotasks));
}
// Exceptions are reported via the message handler. This is ensured by the
// verbose TryCatch.
......
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