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: Toon Verwaest <verwaest@chromium.org> Cr-Commit-Position: refs/heads/master@{#74248}
This commit is contained in:
parent
e9db173bc7
commit
786d486172
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user