| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 165 } |
| 166 | 166 |
| 167 function PromiseHandle(value, handler, deferred) { | 167 function PromiseHandle(value, handler, deferred) { |
| 168 var debug_is_active = DEBUG_IS_ACTIVE; | 168 var debug_is_active = DEBUG_IS_ACTIVE; |
| 169 try { | 169 try { |
| 170 if (debug_is_active) %DebugPushPromise(deferred.promise); | 170 if (debug_is_active) %DebugPushPromise(deferred.promise); |
| 171 var result = handler(value); | 171 var result = handler(value); |
| 172 if (IS_UNDEFINED(deferred.resolve)) { | 172 if (IS_UNDEFINED(deferred.resolve)) { |
| 173 ResolvePromise(deferred.promise, result); | 173 ResolvePromise(deferred.promise, result); |
| 174 } else { | 174 } else { |
| 175 deferred.resolve(result); | 175 %_Call(deferred.resolve, UNDEFINED, result); |
| 176 } | 176 } |
| 177 } %catch (exception) { // Natives syntax to mark this catch block. | 177 } %catch (exception) { // Natives syntax to mark this catch block. |
| 178 try { | 178 try { |
| 179 if (IS_UNDEFINED(deferred.reject)) { | 179 if (IS_UNDEFINED(deferred.reject)) { |
| 180 // Pass false for debugEvent so .then chaining does not trigger | 180 // Pass false for debugEvent so .then chaining does not trigger |
| 181 // redundant ExceptionEvents. | 181 // redundant ExceptionEvents. |
| 182 RejectPromise(deferred.promise, exception, false); | 182 RejectPromise(deferred.promise, exception, false); |
| 183 } else { | 183 } else { |
| 184 deferred.reject(exception); | 184 %_Call(deferred.reject, UNDEFINED, exception); |
| 185 } | 185 } |
| 186 } catch (e) { } | 186 } catch (e) { } |
| 187 } finally { | 187 } finally { |
| 188 if (debug_is_active) %DebugPopPromise(); | 188 if (debug_is_active) %DebugPopPromise(); |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| 192 function PromiseEnqueue(value, tasks, deferreds, status) { | 192 function PromiseEnqueue(value, tasks, deferreds, status) { |
| 193 var id, name, instrumenting = DEBUG_IS_ACTIVE; | 193 var id, name, instrumenting = DEBUG_IS_ACTIVE; |
| 194 %EnqueueMicrotask(function() { | 194 %EnqueueMicrotask(function() { |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 for (var value of iterable) { | 599 for (var value of iterable) { |
| 600 var throwawayPromise = this.resolve(value).then(deferred.resolve, | 600 var throwawayPromise = this.resolve(value).then(deferred.resolve, |
| 601 deferred.reject); | 601 deferred.reject); |
| 602 // For catch prediction, mark that rejections here are semantically | 602 // For catch prediction, mark that rejections here are semantically |
| 603 // handled by the combined Promise. | 603 // handled by the combined Promise. |
| 604 if (instrumenting && IsPromise(throwawayPromise)) { | 604 if (instrumenting && IsPromise(throwawayPromise)) { |
| 605 SET_PRIVATE(throwawayPromise, promiseHandledBySymbol, deferred.promise); | 605 SET_PRIVATE(throwawayPromise, promiseHandledBySymbol, deferred.promise); |
| 606 } | 606 } |
| 607 } | 607 } |
| 608 } catch (e) { | 608 } catch (e) { |
| 609 deferred.reject(e) | 609 %_Call(deferred.reject, UNDEFINED, e); |
| 610 } | 610 } |
| 611 return deferred.promise; | 611 return deferred.promise; |
| 612 } | 612 } |
| 613 | 613 |
| 614 | 614 |
| 615 // Utility for debugger | 615 // Utility for debugger |
| 616 | 616 |
| 617 function PromiseHasUserDefinedRejectHandlerCheck(handler, deferred) { | 617 function PromiseHasUserDefinedRejectHandlerCheck(handler, deferred) { |
| 618 // Recurse to the forwarding Promise, if any. This may be due to | 618 // Recurse to the forwarding Promise, if any. This may be due to |
| 619 // - await reaction forwarding to the throwaway Promise, which has | 619 // - await reaction forwarding to the throwaway Promise, which has |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 to.PromiseNextMicrotaskID = PromiseNextMicrotaskID; | 722 to.PromiseNextMicrotaskID = PromiseNextMicrotaskID; |
| 723 | 723 |
| 724 to.GlobalPromise = GlobalPromise; | 724 to.GlobalPromise = GlobalPromise; |
| 725 to.NewPromiseCapability = NewPromiseCapability; | 725 to.NewPromiseCapability = NewPromiseCapability; |
| 726 to.PerformPromiseThen = PerformPromiseThen; | 726 to.PerformPromiseThen = PerformPromiseThen; |
| 727 to.ResolvePromise = ResolvePromise; | 727 to.ResolvePromise = ResolvePromise; |
| 728 to.RejectPromise = RejectPromise; | 728 to.RejectPromise = RejectPromise; |
| 729 }); | 729 }); |
| 730 | 730 |
| 731 }) | 731 }) |
| OLD | NEW |