Skip to content

Commit 15f1371

Browse files
author
Jim Blandy
committed
Bug 1592427: Correct comment for ReactionRecordSlots::ReactionRecordSlot_Promise. DONTBUILD r=arai
Differential Revision: https://phabricator.services.mozilla.com/D56158 --HG-- extra : moz-landing-system : lando
1 parent a89b63b commit 15f1371

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

js/src/builtin/Promise.cpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,13 +616,32 @@ static bool AbruptRejectPromise(JSContext* cx, CallArgs& args,
616616
}
617617

618618
enum ReactionRecordSlots {
619-
// The promise for which this record provides a reaction handler.
620-
// Matches the [[Capability]].[[Promise]] field from the spec.
619+
// This is the promise-like object that gets resolved with the result of this
620+
// reaction, if any. If this reaction record was created with .then or .catch,
621+
// this is the promise that .then or .catch returned.
621622
//
622-
// The slot value is either an object, but not necessarily a built-in
623-
// Promise object, or null. The latter case is only possible for async
624-
// generator functions, in which case the REACTION_FLAG_ASYNC_GENERATOR
625-
// flag must be set.
623+
// The spec says that a PromiseReaction record has a [[Capability]] field
624+
// whose value is either undefined or a PromiseCapability record, but we just
625+
// store the PromiseCapability's fields directly in this object. This is the
626+
// capability's [[Promise]] field; its [[Resolve]] and [[Reject]] fields are
627+
// stored in ReactionRecordSlot_Resolve and ReactionRecordSlot_Reject.
628+
//
629+
// This can be 'null' in reaction records created for a few situations:
630+
//
631+
// - When you resolve one promise to another. When you pass a promise P1 to
632+
// the 'fulfill' function of a promise P2, so that resolving P1 resolves P2
633+
// in the same way, P1 gets a reaction record with the
634+
// REACTION_FLAG_DEFAULT_RESOLVING_HANDLER flag set and whose
635+
// ReactionRecordSlot_GeneratorOrPromiseToResolve slot holds P2.
636+
//
637+
// - When you await a promise. When an async function or generator awaits a
638+
// value V, then the await expression generates an internal promise P,
639+
// resolves it to V, and then gives P a reaction record with the
640+
// REACTION_FLAG_ASYNC_FUNCTION or REACTION_FLAG_ASYNC_GENERATOR flag set
641+
// and whose ReactionRecordSlot_GeneratorOrPromiseToResolve slot holds the
642+
// generator object. (Typically V is a promise, so resolving P to V gives V
643+
// a REACTION_FLAGS_DEFAULT_RESOLVING_HANDLER reaction record as described
644+
// above.)
626645
ReactionRecordSlot_Promise = 0,
627646

628647
// The [[Handler]] field(s) of a PromiseReaction record. We create a

0 commit comments

Comments
 (0)