Skip to content

Commit fa4cb17

Browse files
camillobruniV8 LUCI CQ
authored andcommitted
[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}
1 parent ca7f285 commit fa4cb17

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/builtins/promise-all.tq

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,7 @@ Reject(Object) {
231231
// the PromiseReaction (aka we can pass undefined to
232232
// PerformPromiseThen), since this is only necessary for DevTools and
233233
// PromiseHooks.
234-
if (promiseResolveFunction != Undefined ||
235-
IsIsolatePromiseHookEnabledOrDebugIsActiveOrHasAsyncEventDelegate() ||
234+
if (promiseResolveFunction != Undefined || NeedsAnyPromiseHooks() ||
236235
IsPromiseSpeciesProtectorCellInvalid() || Is<Smi>(nextValue) ||
237236
!IsPromiseThenLookupChainIntact(
238237
nativeContext, UnsafeCast<HeapObject>(nextValue).map)) {

test/mjsunit/promise-hooks.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ exceptions();
246246
(function regress1126309() {
247247
function __f_16(test) {
248248
test();
249-
d8.promise.setHooks( undefined, () => {});
249+
d8.promise.setHooks(undefined, () => {});
250250
%PerformMicrotaskCheckpoint();
251251
d8.promise.setHooks();
252252
}
@@ -262,3 +262,14 @@ exceptions();
262262
%PerformMicrotaskCheckpoint();
263263
d8.promise.setHooks();
264264
})();
265+
266+
267+
(function promiseAll() {
268+
let initCount = 0;
269+
d8.promise.setHooks(() => { initCount++});
270+
Promise.all([Promise.resolve(1)]);
271+
%PerformMicrotaskCheckpoint();
272+
assertEquals(initCount, 3);
273+
274+
d8.promise.setHooks();
275+
})();

0 commit comments

Comments
 (0)