[Atomics.waitAsync] Fix: enter a context when resolving promises

Bug: v8:10239, chromium:1115354
Change-Id: Ifcb28b4f83e729107b6cbf090cd57be466495177
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2351663
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69393}
This commit is contained in:
Marja Hölttä 2020-08-13 19:38:15 +02:00 committed by Commit Bot
parent 6962221295
commit e70e56f8dd
3 changed files with 8 additions and 0 deletions

View File

@ -128,6 +128,7 @@ void AsyncHooks::ShellPromiseHook(PromiseHookType type, Local<Promise> promise,
HandleScope handle_scope(hooks->isolate_);
Local<Context> currentContext = hooks->isolate_->GetCurrentContext();
DCHECK(!currentContext.IsEmpty());
if (type == PromiseHookType::kInit) {
++hooks->current_async_id;

View File

@ -749,6 +749,9 @@ void FutexEmulation::ResolveAsyncWaiterPromise(FutexWaitListNode* node) {
USE(success);
if (!node->promise_.IsEmpty()) {
DCHECK(!node->native_context_.IsEmpty());
Local<v8::Context> native_context = node->native_context_.Get(v8_isolate);
v8::Context::Scope contextScope(native_context);
Handle<JSPromise> promise = Handle<JSPromise>::cast(
Utils::OpenHandle(*node->promise_.Get(v8_isolate)));
Handle<String> result_string;

View File

@ -5331,6 +5331,8 @@ static void MoveMessageToPromise(Isolate* isolate, Handle<JSPromise> promise) {
Handle<Object> JSPromise::Reject(Handle<JSPromise> promise,
Handle<Object> reason, bool debug_event) {
Isolate* const isolate = promise->GetIsolate();
DCHECK(
!reinterpret_cast<v8::Isolate*>(isolate)->GetCurrentContext().IsEmpty());
if (isolate->debug()->is_active()) MoveMessageToPromise(isolate, promise);
@ -5368,6 +5370,8 @@ Handle<Object> JSPromise::Reject(Handle<JSPromise> promise,
MaybeHandle<Object> JSPromise::Resolve(Handle<JSPromise> promise,
Handle<Object> resolution) {
Isolate* const isolate = promise->GetIsolate();
DCHECK(
!reinterpret_cast<v8::Isolate*>(isolate)->GetCurrentContext().IsEmpty());
isolate->RunPromiseHook(PromiseHookType::kResolve, promise,
isolate->factory()->undefined_value());