From d9b58a02626f23b6215822a1b8a0f21901399760 Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Mon, 3 May 2021 10:43:25 -0700 Subject: [PATCH] deps: V8: cherry-pick fa4cb172cde2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: Camillo Bruni Cr-Commit-Position: refs/heads/master@{#74326} Refs: https://github.com/v8/v8/commit/fa4cb172cde256a1e71d675d81fbb4b85d1e5f66 PR-URL: https://github.com/nodejs/node/pull/38577 Reviewed-By: Gerhard Stöbich Reviewed-By: Vladimir de Turckheim Reviewed-By: Bryan English Reviewed-By: Matteo Collina --- common.gypi | 2 +- deps/v8/src/builtins/promise-all.tq | 3 +-- deps/v8/test/mjsunit/promise-hooks.js | 13 ++++++++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/common.gypi b/common.gypi index 05153616f29096..c7a26fb673997b 100644 --- a/common.gypi +++ b/common.gypi @@ -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.80', + 'v8_embedder_string': '-node.81', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/builtins/promise-all.tq b/deps/v8/src/builtins/promise-all.tq index 0e914aef4057b4..77596c4787a097 100644 --- a/deps/v8/src/builtins/promise-all.tq +++ b/deps/v8/src/builtins/promise-all.tq @@ -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(nextValue) || !IsPromiseThenLookupChainIntact( nativeContext, UnsafeCast(nextValue).map)) { diff --git a/deps/v8/test/mjsunit/promise-hooks.js b/deps/v8/test/mjsunit/promise-hooks.js index bf51777dcecd8d..f7c1558c1d2e20 100644 --- a/deps/v8/test/mjsunit/promise-hooks.js +++ b/deps/v8/test/mjsunit/promise-hooks.js @@ -246,7 +246,7 @@ exceptions(); (function regress1126309() { function __f_16(test) { test(); - d8.promise.setHooks( undefined, () => {}); + d8.promise.setHooks(undefined, () => {}); %PerformMicrotaskCheckpoint(); d8.promise.setHooks(); } @@ -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(); +})();