From 3c6c28b0a1e33066987d5f615a8c156f176f6ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Mon, 17 May 2021 19:56:48 +0200 Subject: [PATCH] deps: V8: cherry-pick 4c074516397b MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: [promises] Fix slow path when context promise hooks are present Bug: chromium:1201936 Change-Id: I1ee545e33587ddf4a5c7e1cbd64b53d36c75a146 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2850936 Reviewed-by: Marja Hölttä Reviewed-by: Jakob Gruber Commit-Queue: Camillo Bruni Cr-Commit-Position: refs/heads/master@{#74267} Refs: https://github.com/v8/v8/commit/4c074516397b89c5cfe9de9857018484f73445ef PR-URL: https://github.com/nodejs/node/pull/38273 Backport-PR-URL: https://github.com/nodejs/node/pull/38991 Reviewed-By: Jiawen Geng Reviewed-By: Colin Ihrig Reviewed-By: Antoine du Hamel Reviewed-By: Michael Dawson Reviewed-By: Mary Marchini --- common.gypi | 2 +- deps/v8/src/builtins/promise-jobs.tq | 3 ++- deps/v8/src/codegen/code-stub-assembler.cc | 6 +++--- deps/v8/src/codegen/code-stub-assembler.h | 10 ++++------ 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/common.gypi b/common.gypi index 4c584060e66852..b5c0a18c594af4 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.11', + 'v8_embedder_string': '-node.12', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/builtins/promise-jobs.tq b/deps/v8/src/builtins/promise-jobs.tq index 6fa81dcd28634a..77d2e7cf9c4813 100644 --- a/deps/v8/src/builtins/promise-jobs.tq +++ b/deps/v8/src/builtins/promise-jobs.tq @@ -7,6 +7,7 @@ // https://tc39.es/ecma262/#sec-promise-jobs namespace promise { extern macro IsJSPromiseMap(Map): bool; +extern macro NeedsAnyPromiseHooks(): bool; // https://tc39.es/ecma262/#sec-promiseresolvethenablejob transitioning builtin @@ -25,7 +26,7 @@ PromiseResolveThenableJob(implicit context: Context)( const promiseThen = *NativeContextSlot(ContextSlot::PROMISE_THEN_INDEX); const thenableMap = thenable.map; if (TaggedEqual(then, promiseThen) && IsJSPromiseMap(thenableMap) && - !IsIsolatePromiseHookEnabledOrDebugIsActiveOrHasAsyncEventDelegate() && + !NeedsAnyPromiseHooks() && IsPromiseSpeciesLookupChainIntact(nativeContext, thenableMap)) { // We know that the {thenable} is a JSPromise, which doesn't require // any special treatment and that {then} corresponds to the initial diff --git a/deps/v8/src/codegen/code-stub-assembler.cc b/deps/v8/src/codegen/code-stub-assembler.cc index 81c503cd90e935..492e6aaf3713bc 100644 --- a/deps/v8/src/codegen/code-stub-assembler.cc +++ b/deps/v8/src/codegen/code-stub-assembler.cc @@ -13843,11 +13843,11 @@ TNode CodeStubAssembler:: return Word32NotEqual(flags, Int32Constant(0)); } -TNode CodeStubAssembler:: - IsAnyPromiseHookEnabledOrHasAsyncEventDelegate(TNode flags) { +TNode CodeStubAssembler::NeedsAnyPromiseHooks(TNode flags) { uint32_t mask = Isolate::PromiseHookFields::HasContextPromiseHook::kMask | Isolate::PromiseHookFields::HasIsolatePromiseHook::kMask | - Isolate::PromiseHookFields::HasAsyncEventDelegate::kMask; + Isolate::PromiseHookFields::HasAsyncEventDelegate::kMask | + Isolate::PromiseHookFields::IsDebugActive::kMask; return IsSetWord32(flags, mask); } diff --git a/deps/v8/src/codegen/code-stub-assembler.h b/deps/v8/src/codegen/code-stub-assembler.h index 5faacd9d1bff0c..24204d82f88b3b 100644 --- a/deps/v8/src/codegen/code-stub-assembler.h +++ b/deps/v8/src/codegen/code-stub-assembler.h @@ -3535,12 +3535,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler return IsAnyPromiseHookEnabledOrDebugIsActiveOrHasAsyncEventDelegate( PromiseHookFlags()); } - TNode IsAnyPromiseHookEnabledOrHasAsyncEventDelegate( - TNode flags); - TNode - IsAnyPromiseHookEnabledOrHasAsyncEventDelegate() { - return IsAnyPromiseHookEnabledOrHasAsyncEventDelegate( - PromiseHookFlags()); + + TNode NeedsAnyPromiseHooks(TNode flags); + TNode NeedsAnyPromiseHooks() { + return NeedsAnyPromiseHooks(PromiseHookFlags()); } // for..in helpers