Commit e70e56f8 authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[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/+/2351663Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69393}
parent 69622212
......@@ -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;
......
......@@ -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;
......
......@@ -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());
......
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