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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // If debug is active, notify about the newly created promise first. | 136 // If debug is active, notify about the newly created promise first. |
137 if (DEBUG_IS_ACTIVE) PromiseSet(promise, kPending, UNDEFINED); | 137 if (DEBUG_IS_ACTIVE) PromiseSet(promise, kPending, UNDEFINED); |
138 return PromiseSet(promise, status, value); | 138 return PromiseSet(promise, status, value); |
139 } | 139 } |
140 | 140 |
141 function PromiseInit(promise) { | 141 function PromiseInit(promise) { |
142 return PromiseSet(promise, kPending, UNDEFINED); | 142 return PromiseSet(promise, kPending, UNDEFINED); |
143 } | 143 } |
144 | 144 |
145 function FulfillPromise(promise, status, value, promiseQueue) { | 145 function FulfillPromise(promise, status, value, promiseQueue) { |
146 if (GET_PRIVATE(promise, promiseStateSymbol) === kPending) { | 146 var tasks = GET_PRIVATE(promise, promiseQueue); |
147 var tasks = GET_PRIVATE(promise, promiseQueue); | 147 if (!IS_UNDEFINED(tasks)) { |
148 if (!IS_UNDEFINED(tasks)) { | 148 var deferred = GET_PRIVATE(promise, promiseDeferredReactionSymbol); |
149 var deferred = GET_PRIVATE(promise, promiseDeferredReactionSymbol); | 149 PromiseEnqueue(value, tasks, deferred, status); |
150 PromiseEnqueue(value, tasks, deferred, status); | |
151 } | |
152 PromiseSet(promise, status, value); | |
153 } | 150 } |
| 151 PromiseSet(promise, status, value); |
154 } | 152 } |
155 | 153 |
156 function PromiseHandle(value, handler, deferred) { | 154 function PromiseHandle(value, handler, deferred) { |
157 var debug_is_active = DEBUG_IS_ACTIVE; | 155 var debug_is_active = DEBUG_IS_ACTIVE; |
158 try { | 156 try { |
159 if (debug_is_active) %DebugPushPromise(deferred.promise); | 157 if (debug_is_active) %DebugPushPromise(deferred.promise); |
160 var result = handler(value); | 158 var result = handler(value); |
161 if (IS_UNDEFINED(deferred.resolve)) { | 159 if (IS_UNDEFINED(deferred.resolve)) { |
162 ResolvePromise(deferred.promise, result); | 160 ResolvePromise(deferred.promise, result); |
163 } else { | 161 } else { |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 to.PromiseThen = PromiseThen; | 675 to.PromiseThen = PromiseThen; |
678 | 676 |
679 to.GlobalPromise = GlobalPromise; | 677 to.GlobalPromise = GlobalPromise; |
680 to.NewPromiseCapability = NewPromiseCapability; | 678 to.NewPromiseCapability = NewPromiseCapability; |
681 to.PerformPromiseThen = PerformPromiseThen; | 679 to.PerformPromiseThen = PerformPromiseThen; |
682 to.ResolvePromise = ResolvePromise; | 680 to.ResolvePromise = ResolvePromise; |
683 to.RejectPromise = RejectPromise; | 681 to.RejectPromise = RejectPromise; |
684 }); | 682 }); |
685 | 683 |
686 }) | 684 }) |
OLD | NEW |