Skip to content

Commit

Permalink
deps: V8: cherry-pick fa4cb172cde2
Browse files Browse the repository at this point in the history
Original commit message:

    [runtime] Fix Promise.all context promise hooks

    We have to take the slow path in Promise.all if context promise hooks
    are set. The fast-path doesn't create intermediate promises by default.

    Bug: chromium:1204132, v8:11025
    Change-Id: Ide92de00a4f6df05e0ddbc8814f6673bd667f426
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2866771
    Reviewed-by: Victor Gomes <[email protected]>
    Commit-Queue: Camillo Bruni <[email protected]>
    Cr-Commit-Position: refs/heads/master@{#74326}

Refs: v8/v8@fa4cb17
  • Loading branch information
Stephen Belanger committed Jun 15, 2021
1 parent c224248 commit 5ef9306
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.71',
'v8_embedder_string': '-node.72',

##### V8 defaults for Node.js #####

Expand Down
3 changes: 1 addition & 2 deletions deps/v8/src/builtins/promise-all.tq
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,7 @@ Reject(Object) {
// the PromiseReaction (aka we can pass undefined to
// PerformPromiseThen), since this is only necessary for DevTools and
// PromiseHooks.
if (promiseResolveFunction != Undefined ||
IsIsolatePromiseHookEnabledOrDebugIsActiveOrHasAsyncEventDelegate() ||
if (promiseResolveFunction != Undefined || NeedsAnyPromiseHooks() ||
IsPromiseSpeciesProtectorCellInvalid() || Is<Smi>(nextValue) ||
!IsPromiseThenLookupChainIntact(
nativeContext, UnsafeCast<HeapObject>(nextValue).map)) {
Expand Down
13 changes: 12 additions & 1 deletion deps/v8/test/mjsunit/promise-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ exceptions();
(function regress1126309() {
function __f_16(test) {
test();
d8.promise.setHooks( undefined, () => {});
d8.promise.setHooks(undefined, () => {});
%PerformMicrotaskCheckpoint();
d8.promise.setHooks();
}
Expand All @@ -262,3 +262,14 @@ exceptions();
%PerformMicrotaskCheckpoint();
d8.promise.setHooks();
})();


(function promiseAll() {
let initCount = 0;
d8.promise.setHooks(() => { initCount++});
Promise.all([Promise.resolve(1)]);
%PerformMicrotaskCheckpoint();
assertEquals(initCount, 3);

d8.promise.setHooks();
})();

0 comments on commit 5ef9306

Please sign in to comment.