Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(434)

Unified Diff: src/js/promise.js

Issue 2403163002: [promises] update comment about deferred reactions symbol state (Closed)
Patch Set: fmt Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap-symbols.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/promise.js
diff --git a/src/js/promise.js b/src/js/promise.js
index 86be06018ce7230dd54a9d7179db9dbd5fa365fa..f92102a46d228aa35a6e355f692d5f81cbdc53fc 100644
--- a/src/js/promise.js
+++ b/src/js/promise.js
@@ -24,8 +24,8 @@ var promiseRejectReactionsSymbol =
utils.ImportNow("promise_reject_reactions_symbol");
var promiseFulfillReactionsSymbol =
utils.ImportNow("promise_fulfill_reactions_symbol");
-var promiseDeferredReactionsSymbol =
- utils.ImportNow("promise_deferred_reactions_symbol");
+var promiseDeferredReactionSymbol =
+ utils.ImportNow("promise_deferred_reaction_symbol");
var promiseHandledHintSymbol =
utils.ImportNow("promise_handled_hint_symbol");
var promiseRawSymbol = utils.ImportNow("promise_raw_symbol");
@@ -128,16 +128,11 @@ function PromiseSet(promise, status, value) {
SET_PRIVATE(promise, promiseFulfillReactionsSymbol, UNDEFINED);
SET_PRIVATE(promise, promiseRejectReactionsSymbol, UNDEFINED);
- // There are 2 possible states for this symbol --
- // 1) UNDEFINED -- This is the zero state, no deferred object is
- // attached to this symbol. When we want to add a new deferred we
- // directly attach it to this symbol.
- // 2) symbol with attached deferred object -- New deferred objects
- // are not attached to this symbol, but instead they are directly
- // attached to the resolve, reject callback arrays. At this point,
- // the deferred symbol's state is stale, and the deferreds should be
- // read from the reject, resolve callbacks.
- SET_PRIVATE(promise, promiseDeferredReactionsSymbol, UNDEFINED);
+ // This symbol is used only when one deferred needs to be attached. When more
+ // than one deferred need to be attached the promise, we attach them directly
+ // to the promiseFulfillReactionsSymbol and promiseRejectReactionsSymbol and
+ // reset this back to UNDEFINED.
+ SET_PRIVATE(promise, promiseDeferredReactionSymbol, UNDEFINED);
return promise;
}
@@ -157,8 +152,8 @@ function FulfillPromise(promise, status, value, promiseQueue) {
if (GET_PRIVATE(promise, promiseStateSymbol) === kPending) {
var tasks = GET_PRIVATE(promise, promiseQueue);
if (!IS_UNDEFINED(tasks)) {
- var deferreds = GET_PRIVATE(promise, promiseDeferredReactionsSymbol);
- PromiseEnqueue(value, tasks, deferreds, status);
+ var deferred = GET_PRIVATE(promise, promiseDeferredReactionSymbol);
+ PromiseEnqueue(value, tasks, deferred, status);
}
PromiseSet(promise, status, value);
}
@@ -234,11 +229,11 @@ function PromiseAttachCallbacks(promise, deferred, onResolve, onReject) {
if (IS_UNDEFINED(maybeResolveCallbacks)) {
SET_PRIVATE(promise, promiseFulfillReactionsSymbol, onResolve);
SET_PRIVATE(promise, promiseRejectReactionsSymbol, onReject);
- SET_PRIVATE(promise, promiseDeferredReactionsSymbol, deferred);
+ SET_PRIVATE(promise, promiseDeferredReactionSymbol, deferred);
} else if (!IS_ARRAY(maybeResolveCallbacks)) {
var resolveCallbacks = new InternalArray();
var rejectCallbacks = new InternalArray();
- var existingDeferred = GET_PRIVATE(promise, promiseDeferredReactionsSymbol);
+ var existingDeferred = GET_PRIVATE(promise, promiseDeferredReactionSymbol);
resolveCallbacks.push(
maybeResolveCallbacks, existingDeferred, onResolve, deferred);
@@ -249,7 +244,7 @@ function PromiseAttachCallbacks(promise, deferred, onResolve, onReject) {
SET_PRIVATE(promise, promiseFulfillReactionsSymbol, resolveCallbacks);
SET_PRIVATE(promise, promiseRejectReactionsSymbol, rejectCallbacks);
- SET_PRIVATE(promise, promiseDeferredReactionsSymbol, UNDEFINED);
+ SET_PRIVATE(promise, promiseDeferredReactionSymbol, UNDEFINED);
} else {
maybeResolveCallbacks.push(onResolve, deferred);
GET_PRIVATE(promise, promiseRejectReactionsSymbol).push(onReject, deferred);
@@ -646,12 +641,12 @@ function PromiseHasUserDefinedRejectHandlerRecursive(promise) {
}
var queue = GET_PRIVATE(promise, promiseRejectReactionsSymbol);
- var deferreds = GET_PRIVATE(promise, promiseDeferredReactionsSymbol);
+ var deferred = GET_PRIVATE(promise, promiseDeferredReactionSymbol);
if (IS_UNDEFINED(queue)) return false;
if (!IS_ARRAY(queue)) {
- return PromiseHasUserDefinedRejectHandlerCheck(queue, deferreds);
+ return PromiseHasUserDefinedRejectHandlerCheck(queue, deferred);
}
for (var i = 0; i < queue.length; i += 2) {
« no previous file with comments | « src/heap-symbols.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698