[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ä <marja@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74267}
This commit is contained in:
Camillo Bruni 2021-04-26 20:04:14 +02:00 committed by Commit Bot
parent c85723a6f1
commit 4c07451639
3 changed files with 9 additions and 10 deletions

View File

@ -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

View File

@ -13900,11 +13900,11 @@ TNode<BoolT> CodeStubAssembler::
return Word32NotEqual(flags, Int32Constant(0));
}
TNode<BoolT> CodeStubAssembler::
IsAnyPromiseHookEnabledOrHasAsyncEventDelegate(TNode<Uint32T> flags) {
TNode<BoolT> CodeStubAssembler::NeedsAnyPromiseHooks(TNode<Uint32T> 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);
}

View File

@ -3565,12 +3565,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
return IsAnyPromiseHookEnabledOrDebugIsActiveOrHasAsyncEventDelegate(
PromiseHookFlags());
}
TNode<BoolT> IsAnyPromiseHookEnabledOrHasAsyncEventDelegate(
TNode<Uint32T> flags);
TNode<BoolT>
IsAnyPromiseHookEnabledOrHasAsyncEventDelegate() {
return IsAnyPromiseHookEnabledOrHasAsyncEventDelegate(
PromiseHookFlags());
TNode<BoolT> NeedsAnyPromiseHooks(TNode<Uint32T> flags);
TNode<BoolT> NeedsAnyPromiseHooks() {
return NeedsAnyPromiseHooks(PromiseHookFlags());
}
// for..in helpers