diff options
author | Michaël Zasso <targos@protonmail.com> | 2021-05-17 20:56:24 +0300 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2021-06-14 09:12:20 +0300 |
commit | 3433559a55db150b6dbd95dc4a6aa1588d24aa81 (patch) | |
tree | 84fb1d4cb9be6a26ce848b4552b7abcde3ff4611 /deps | |
parent | f56c78574ef740ab5e47a8acc60db7dbf653a43d (diff) |
deps: V8: cherry-pick 272445f10927
Original commit message:
[runtime] Fix promise hooks
promiseCapability can be undefined.
Bug: v8:11025
Bug: chromium:1201113
Change-Id: I9da8764820cee0db1f0c38ed2fff0e3afeb9a80e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2844649
Reviewed-by: Marja Hölttä <marja@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74117}
Refs: https://github.com/v8/v8/commit/272445f109273dcdf81d37b1f91f146cfd78ec41
PR-URL: https://github.com/nodejs/node/pull/38273
Backport-PR-URL: https://github.com/nodejs/node/pull/38991
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Mary Marchini <oss@mmarchini.me>
Diffstat (limited to 'deps')
-rw-r--r-- | deps/v8/src/builtins/promise-misc.tq | 13 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/promise-hooks.js | 12 |
2 files changed, 19 insertions, 6 deletions
diff --git a/deps/v8/src/builtins/promise-misc.tq b/deps/v8/src/builtins/promise-misc.tq index c6661e37173..50e2c8f0de1 100644 --- a/deps/v8/src/builtins/promise-misc.tq +++ b/deps/v8/src/builtins/promise-misc.tq @@ -134,7 +134,7 @@ transitioning macro RunContextPromiseHookResolve(implicit context: Context)( @export transitioning macro RunContextPromiseHookBefore(implicit context: Context)( - promiseOrCapability: JSPromise|PromiseCapability) { + promiseOrCapability: JSPromise|PromiseCapability|Undefined) { RunContextPromiseHook( ContextSlot::PROMISE_HOOK_BEFORE_FUNCTION_INDEX, promiseOrCapability, PromiseHookFlags()); @@ -142,7 +142,7 @@ transitioning macro RunContextPromiseHookBefore(implicit context: Context)( @export transitioning macro RunContextPromiseHookBefore(implicit context: Context)( - promiseOrCapability: JSPromise|PromiseCapability, flags: uint32) { + promiseOrCapability: JSPromise|PromiseCapability|Undefined, flags: uint32) { RunContextPromiseHook( ContextSlot::PROMISE_HOOK_BEFORE_FUNCTION_INDEX, promiseOrCapability, flags); @@ -150,7 +150,7 @@ transitioning macro RunContextPromiseHookBefore(implicit context: Context)( @export transitioning macro RunContextPromiseHookAfter(implicit context: Context)( - promiseOrCapability: JSPromise|PromiseCapability) { + promiseOrCapability: JSPromise|PromiseCapability|Undefined) { RunContextPromiseHook( ContextSlot::PROMISE_HOOK_AFTER_FUNCTION_INDEX, promiseOrCapability, PromiseHookFlags()); @@ -158,7 +158,7 @@ transitioning macro RunContextPromiseHookAfter(implicit context: Context)( @export transitioning macro RunContextPromiseHookAfter(implicit context: Context)( - promiseOrCapability: JSPromise|PromiseCapability, flags: uint32) { + promiseOrCapability: JSPromise|PromiseCapability|Undefined, flags: uint32) { RunContextPromiseHook( ContextSlot::PROMISE_HOOK_AFTER_FUNCTION_INDEX, promiseOrCapability, flags); @@ -166,7 +166,7 @@ transitioning macro RunContextPromiseHookAfter(implicit context: Context)( transitioning macro RunContextPromiseHook(implicit context: Context)( slot: Slot<NativeContext, Undefined|JSFunction>, - promiseOrCapability: JSPromise|PromiseCapability, flags: uint32) { + promiseOrCapability: JSPromise|PromiseCapability|Undefined, flags: uint32) { if (!IsContextPromiseHookEnabled(flags)) return; const maybeHook = *NativeContextSlot(slot); if (IsUndefined(maybeHook)) return; @@ -181,6 +181,9 @@ transitioning macro RunContextPromiseHook(implicit context: Context)( case (capability: PromiseCapability): { promise = Cast<JSPromise>(capability.promise) otherwise return; } + case (Undefined): { + return; + } } try { diff --git a/deps/v8/test/mjsunit/promise-hooks.js b/deps/v8/test/mjsunit/promise-hooks.js index 9e13206a525..db7041a8f5d 100644 --- a/deps/v8/test/mjsunit/promise-hooks.js +++ b/deps/v8/test/mjsunit/promise-hooks.js @@ -1,7 +1,7 @@ // Copyright 2020 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// + // Flags: --allow-natives-syntax --opt --no-always-opt --no-stress-opt --deopt-every-n-times=0 --ignore-unhandled-promises let log = []; @@ -242,3 +242,13 @@ optimizerBailout(async () => { }); basicTest(); exceptions(); + +(function regress1126309() { + function __f_16(test) { + test(); + d8.promise.setHooks( undefined, () => {}); + %PerformMicrotaskCheckpoint(); + d8.promise.setHooks(); + } + __f_16(async () => { await Promise.resolve()}); +})(); |