OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function(global, utils, extrasUtils) { | 5 (function(global, utils, extrasUtils) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 // 1) UNDEFINED -- This is the zero state where there is no callback | 121 // 1) UNDEFINED -- This is the zero state where there is no callback |
122 // registered. When we see this state, we directly attach the callbacks to | 122 // registered. When we see this state, we directly attach the callbacks to |
123 // the symbol. | 123 // the symbol. |
124 // 2) !IS_ARRAY -- There is a single callback directly attached to the | 124 // 2) !IS_ARRAY -- There is a single callback directly attached to the |
125 // symbols. We need to create a new array to store additional callbacks. | 125 // symbols. We need to create a new array to store additional callbacks. |
126 // 3) IS_ARRAY -- There are multiple callbacks already registered, | 126 // 3) IS_ARRAY -- There are multiple callbacks already registered, |
127 // therefore we can just push the new callback to the existing array. | 127 // therefore we can just push the new callback to the existing array. |
128 SET_PRIVATE(promise, promiseFulfillReactionsSymbol, UNDEFINED); | 128 SET_PRIVATE(promise, promiseFulfillReactionsSymbol, UNDEFINED); |
129 SET_PRIVATE(promise, promiseRejectReactionsSymbol, UNDEFINED); | 129 SET_PRIVATE(promise, promiseRejectReactionsSymbol, UNDEFINED); |
130 | 130 |
131 // There are 2 possible states for this symbol -- | 131 // This symbol is used only when one deferred needs to be attached. When more |
132 // 1) UNDEFINED -- This is the zero state, no deferred object is | 132 // than one deferred need to be attached the promise, we attach them directly |
133 // attached to this symbol. When we want to add a new deferred we | 133 // to the promiseFulfillReactionsSymbol and promiseRejectReactionsSymbol and |
134 // directly attach it to this symbol. | 134 // reset this back to UNDEFINED. |
135 // 2) symbol with attached deferred object -- New deferred objects | |
136 // are not attached to this symbol, but instead they are directly | |
137 // attached to the resolve, reject callback arrays. At this point, | |
138 // the deferred symbol's state is stale, and the deferreds should be | |
139 // read from the reject, resolve callbacks. | |
140 SET_PRIVATE(promise, promiseDeferredReactionsSymbol, UNDEFINED); | 135 SET_PRIVATE(promise, promiseDeferredReactionsSymbol, UNDEFINED); |
adamk
2016/10/10 19:19:32
Can you rename the symbol to match its usage? And
| |
141 | 136 |
142 return promise; | 137 return promise; |
143 } | 138 } |
144 | 139 |
145 function PromiseCreateAndSet(status, value) { | 140 function PromiseCreateAndSet(status, value) { |
146 var promise = new GlobalPromise(promiseRawSymbol); | 141 var promise = new GlobalPromise(promiseRawSymbol); |
147 // If debug is active, notify about the newly created promise first. | 142 // If debug is active, notify about the newly created promise first. |
148 if (DEBUG_IS_ACTIVE) PromiseSet(promise, kPending, UNDEFINED); | 143 if (DEBUG_IS_ACTIVE) PromiseSet(promise, kPending, UNDEFINED); |
149 return PromiseSet(promise, status, value); | 144 return PromiseSet(promise, status, value); |
150 } | 145 } |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
722 to.PromiseNextMicrotaskID = PromiseNextMicrotaskID; | 717 to.PromiseNextMicrotaskID = PromiseNextMicrotaskID; |
723 | 718 |
724 to.GlobalPromise = GlobalPromise; | 719 to.GlobalPromise = GlobalPromise; |
725 to.NewPromiseCapability = NewPromiseCapability; | 720 to.NewPromiseCapability = NewPromiseCapability; |
726 to.PerformPromiseThen = PerformPromiseThen; | 721 to.PerformPromiseThen = PerformPromiseThen; |
727 to.ResolvePromise = ResolvePromise; | 722 to.ResolvePromise = ResolvePromise; |
728 to.RejectPromise = RejectPromise; | 723 to.RejectPromise = RejectPromise; |
729 }); | 724 }); |
730 | 725 |
731 }) | 726 }) |
OLD | NEW |