| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 14 matching lines...) Expand all Loading... |
| 25 PromiseCreate = from.PromiseCreate; | 25 PromiseCreate = from.PromiseCreate; |
| 26 RejectPromise = from.RejectPromise; | 26 RejectPromise = from.RejectPromise; |
| 27 }); | 27 }); |
| 28 | 28 |
| 29 var promiseAsyncStackIDSymbol = | 29 var promiseAsyncStackIDSymbol = |
| 30 utils.ImportNow("promise_async_stack_id_symbol"); | 30 utils.ImportNow("promise_async_stack_id_symbol"); |
| 31 var promiseHandledBySymbol = | 31 var promiseHandledBySymbol = |
| 32 utils.ImportNow("promise_handled_by_symbol"); | 32 utils.ImportNow("promise_handled_by_symbol"); |
| 33 var promiseForwardingHandlerSymbol = | 33 var promiseForwardingHandlerSymbol = |
| 34 utils.ImportNow("promise_forwarding_handler_symbol"); | 34 utils.ImportNow("promise_forwarding_handler_symbol"); |
| 35 var promiseHandledHintSymbol = | |
| 36 utils.ImportNow("promise_handled_hint_symbol"); | |
| 37 | 35 |
| 38 // ------------------------------------------------------------------- | 36 // ------------------------------------------------------------------- |
| 39 | 37 |
| 40 function PromiseCastResolved(value) { | 38 function PromiseCastResolved(value) { |
| 41 // TODO(caitp): This is non spec compliant. See v8:5694. | 39 // TODO(caitp): This is non spec compliant. See v8:5694. |
| 42 if (%is_promise(value)) { | 40 if (%is_promise(value)) { |
| 43 return value; | 41 return value; |
| 44 } else { | 42 } else { |
| 45 var promise = PromiseCreate(); | 43 var promise = PromiseCreate(); |
| 46 %promise_resolve(promise, value); | 44 %promise_resolve(promise, value); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 // Called by the parser from the desugaring of 'await' when catch | 105 // Called by the parser from the desugaring of 'await' when catch |
| 108 // prediction indicates no locally surrounding catch block | 106 // prediction indicates no locally surrounding catch block |
| 109 function AsyncFunctionAwaitUncaught(generator, awaited, outerPromise) { | 107 function AsyncFunctionAwaitUncaught(generator, awaited, outerPromise) { |
| 110 AsyncFunctionAwait(generator, awaited, outerPromise); | 108 AsyncFunctionAwait(generator, awaited, outerPromise); |
| 111 } | 109 } |
| 112 | 110 |
| 113 // Called by the parser from the desugaring of 'await' when catch | 111 // Called by the parser from the desugaring of 'await' when catch |
| 114 // prediction indicates that there is a locally surrounding catch block | 112 // prediction indicates that there is a locally surrounding catch block |
| 115 function AsyncFunctionAwaitCaught(generator, awaited, outerPromise) { | 113 function AsyncFunctionAwaitCaught(generator, awaited, outerPromise) { |
| 116 if (DEBUG_IS_ACTIVE && %is_promise(awaited)) { | 114 if (DEBUG_IS_ACTIVE && %is_promise(awaited)) { |
| 117 SET_PRIVATE(awaited, promiseHandledHintSymbol, true); | 115 %PromiseMarkHandledHint(awaited); |
| 118 } | 116 } |
| 119 AsyncFunctionAwait(generator, awaited, outerPromise); | 117 AsyncFunctionAwait(generator, awaited, outerPromise); |
| 120 } | 118 } |
| 121 | 119 |
| 122 // How the parser rejects promises from async/await desugaring | 120 // How the parser rejects promises from async/await desugaring |
| 123 function RejectPromiseNoDebugEvent(promise, reason) { | 121 function RejectPromiseNoDebugEvent(promise, reason) { |
| 124 return RejectPromise(promise, reason, false); | 122 return RejectPromise(promise, reason, false); |
| 125 } | 123 } |
| 126 | 124 |
| 127 function AsyncFunctionPromiseCreate() { | 125 function AsyncFunctionPromiseCreate() { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 158 | 156 |
| 159 %InstallToContext([ | 157 %InstallToContext([ |
| 160 "async_function_await_caught", AsyncFunctionAwaitCaught, | 158 "async_function_await_caught", AsyncFunctionAwaitCaught, |
| 161 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, | 159 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, |
| 162 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent, | 160 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent, |
| 163 "async_function_promise_create", AsyncFunctionPromiseCreate, | 161 "async_function_promise_create", AsyncFunctionPromiseCreate, |
| 164 "async_function_promise_release", AsyncFunctionPromiseRelease, | 162 "async_function_promise_release", AsyncFunctionPromiseRelease, |
| 165 ]); | 163 ]); |
| 166 | 164 |
| 167 }) | 165 }) |
| OLD | NEW |