From a84e9b3e7d2ac9504bdf8f8e2375af42afe97363 Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Thu, 29 Apr 2021 09:18:17 -0700 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/36394 Reviewed-By: Bryan English Reviewed-By: Gus Caplan Reviewed-By: Vladimir de Turckheim Reviewed-By: Gerhard Stöbich Reviewed-By: James M Snell --- 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 c789d6a24b71be..8df463082ac30f 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.14', + 'v8_embedder_string': '-node.15', ##### 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 415291dd736f20..90e34d4dbdcbf0 100644 --- a/deps/v8/src/codegen/code-stub-assembler.cc +++ b/deps/v8/src/codegen/code-stub-assembler.cc @@ -13435,11 +13435,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 702792d7888aad..ba331624c6fecf 100644 --- a/deps/v8/src/codegen/code-stub-assembler.h +++ b/deps/v8/src/codegen/code-stub-assembler.h @@ -3528,12 +3528,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