summaryrefslogtreecommitdiff
path: root/deps/v8/src/heap/finalization-registry-cleanup-task.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/heap/finalization-registry-cleanup-task.cc')
-rw-r--r--deps/v8/src/heap/finalization-registry-cleanup-task.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/deps/v8/src/heap/finalization-registry-cleanup-task.cc b/deps/v8/src/heap/finalization-registry-cleanup-task.cc
index 2acfa31ffb..18222e783d 100644
--- a/deps/v8/src/heap/finalization-registry-cleanup-task.cc
+++ b/deps/v8/src/heap/finalization-registry-cleanup-task.cc
@@ -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.