Commit a7a35001 authored by gsathya's avatar gsathya Committed by Commit bot

[promises] remove kPending check in RejectPromise

RejectPromise is always called on a pending promise making this a redundant check.

BUG=v8:5343

Review-Url: https://codereview.chromium.org/2446113007
Cr-Commit-Position: refs/heads/master@{#40591}
parent 2ab2ec22
...@@ -302,19 +302,16 @@ function ResolvePromise(promise, resolution) { ...@@ -302,19 +302,16 @@ function ResolvePromise(promise, resolution) {
// ES#sec-rejectpromise // ES#sec-rejectpromise
// RejectPromise ( promise, reason ) // RejectPromise ( promise, reason )
function RejectPromise(promise, reason, debugEvent) { function RejectPromise(promise, reason, debugEvent) {
// Check promise status to confirm that this reject has an effect.
// Call runtime for callbacks to the debugger or for unhandled reject. // Call runtime for callbacks to the debugger or for unhandled reject.
// The debugEvent parameter sets whether a debug ExceptionEvent should // The debugEvent parameter sets whether a debug ExceptionEvent should
// be triggered. It should be set to false when forwarding a rejection // be triggered. It should be set to false when forwarding a rejection
// rather than creating a new one. // rather than creating a new one.
if (GET_PRIVATE(promise, promiseStateSymbol) === kPending) {
// This check is redundant with checks in the runtime, but it may help // This check is redundant with checks in the runtime, but it may help
// avoid unnecessary runtime calls. // avoid unnecessary runtime calls.
if ((debugEvent && DEBUG_IS_ACTIVE) || if ((debugEvent && DEBUG_IS_ACTIVE) ||
!HAS_DEFINED_PRIVATE(promise, promiseHasHandlerSymbol)) { !HAS_DEFINED_PRIVATE(promise, promiseHasHandlerSymbol)) {
%PromiseRejectEvent(promise, reason, debugEvent); %PromiseRejectEvent(promise, reason, debugEvent);
} }
}
%PromiseFulfill(promise, kRejected, reason, promiseRejectReactionsSymbol) %PromiseFulfill(promise, kRejected, reason, promiseRejectReactionsSymbol)
PromiseSet(promise, kRejected, reason); PromiseSet(promise, kRejected, reason);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment