From fbfc50a0d555b2913fe43027725209814352b05e 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 Backport-PR-URL: https://github.com/nodejs/node/pull/38577 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 bb3a78dd74ef00..05153616f29096 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.79', + 'v8_embedder_string': '-node.80', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/builtins/promise-jobs.tq b/deps/v8/src/builtins/promise-jobs.tq index 50bcd395288051..d0d88b30d6b7d3 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 = nativeContext[NativeContextSlot::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 e330d99f0389d9..843d1e39ac984f 100644 --- a/deps/v8/src/codegen/code-stub-assembler.cc +++ b/deps/v8/src/codegen/code-stub-assembler.cc @@ -12781,11 +12781,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 bcb88afe0ca804..499b26e0bf0a21 100644 --- a/deps/v8/src/codegen/code-stub-assembler.h +++ b/deps/v8/src/codegen/code-stub-assembler.h @@ -3747,12 +3747,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