Create a MicrotasksScope for async GC

When running the async version of window.gc()
(e.g. window.gc({type: 'major', execution: 'async'})),
the promise is resolved without a MicrotasksScope, causing us to hit a
DCHECK.

Change-Id: I10f72c96605263afacc01afbfcc56d1134d84b43
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4220146
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Kevin McNee <mcnee@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85698}
This commit is contained in:
Kevin McNee 2023-02-03 20:05:20 -05:00 committed by V8 LUCI CQ
parent fa73edeb1e
commit 46a5dd0256

View File

@ -5,6 +5,7 @@
#include "src/extensions/gc-extension.h" #include "src/extensions/gc-extension.h"
#include "include/v8-isolate.h" #include "include/v8-isolate.h"
#include "include/v8-microtask-queue.h"
#include "include/v8-object.h" #include "include/v8-object.h"
#include "include/v8-persistent-handle.h" #include "include/v8-persistent-handle.h"
#include "include/v8-primitive.h" #include "include/v8-primitive.h"
@ -121,6 +122,8 @@ class AsyncGC final : public CancelableTask {
InvokeGC(isolate_, ExecutionType::kAsync, type_); InvokeGC(isolate_, ExecutionType::kAsync, type_);
auto resolver = v8::Local<v8::Promise::Resolver>::New(isolate_, resolver_); auto resolver = v8::Local<v8::Promise::Resolver>::New(isolate_, resolver_);
auto ctx = Local<v8::Context>::New(isolate_, ctx_); auto ctx = Local<v8::Context>::New(isolate_, ctx_);
v8::MicrotasksScope microtasks_scope(
ctx, v8::MicrotasksScope::kDoNotRunMicrotasks);
resolver->Resolve(ctx, v8::Undefined(isolate_)).ToChecked(); resolver->Resolve(ctx, v8::Undefined(isolate_)).ToChecked();
} }