Commit 786d4861 authored by Jochen Eisinger's avatar Jochen Eisinger Committed by Commit Bot

Create a microtask scope before performing a microtask checkpoint

When the embedder uses microtask scopes to control microtask execution,
we check in the V8 API that there's always a microtask scope on the
stack when entering V8. However, a microtask might call into the
embedder which in turn can call into V8, so we have to put a fake scope
on the stack before executing microtasks to avoid hitting the check.

Bug: chromium:728583
Change-Id: I99bcbcca26eaaac827d0ec09064044f616fb9efc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2853597
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74248}
parent e9db173b
......@@ -113,6 +113,16 @@ void MicrotaskQueue::EnqueueMicrotask(Microtask microtask) {
void MicrotaskQueue::PerformCheckpoint(v8::Isolate* v8_isolate) {
if (!IsRunningMicrotasks() && !GetMicrotasksScopeDepth() &&
!HasMicrotasksSuppressions()) {
std::unique_ptr<MicrotasksScope> microtasks_scope;
if (microtasks_policy_ == v8::MicrotasksPolicy::kScoped) {
// If we're using microtask scopes to schedule microtask execution, V8
// API calls will check that there's always a microtask scope on the
// stack. As the microtasks we're about to execute could invoke embedder
// callbacks which then calls back into V8, we create an artificial
// microtask scope here to avoid running into the CallDepthScope check.
microtasks_scope.reset(new v8::MicrotasksScope(
v8_isolate, this, v8::MicrotasksScope::kDoNotRunMicrotasks));
}
Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
RunMicrotasks(isolate);
isolate->ClearKeptObjects();
......
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