| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 // Called by the parser from the desugaring of 'await' when catch | 100 // Called by the parser from the desugaring of 'await' when catch |
| 101 // prediction indicates that there is a locally surrounding catch block | 101 // prediction indicates that there is a locally surrounding catch block |
| 102 function AsyncFunctionAwaitCaught(generator, awaited, outerPromise) { | 102 function AsyncFunctionAwaitCaught(generator, awaited, outerPromise) { |
| 103 if (DEBUG_IS_ACTIVE && %is_promise(awaited)) { | 103 if (DEBUG_IS_ACTIVE && %is_promise(awaited)) { |
| 104 %PromiseMarkHandledHint(awaited); | 104 %PromiseMarkHandledHint(awaited); |
| 105 } | 105 } |
| 106 AsyncFunctionAwait(generator, awaited, outerPromise); | 106 AsyncFunctionAwait(generator, awaited, outerPromise); |
| 107 } | 107 } |
| 108 | 108 |
| 109 // How the parser rejects promises from async/await desugaring | |
| 110 function RejectPromiseNoDebugEvent(promise, reason) { | |
| 111 return %promise_internal_reject(promise, reason, false); | |
| 112 } | |
| 113 | |
| 114 function AsyncFunctionPromiseCreate() { | 109 function AsyncFunctionPromiseCreate() { |
| 115 var promise = %promise_internal_constructor(UNDEFINED); | 110 var promise = %promise_internal_constructor(UNDEFINED); |
| 116 if (DEBUG_IS_ACTIVE) { | 111 if (DEBUG_IS_ACTIVE) { |
| 117 // Push the Promise under construction in an async function on | 112 // Push the Promise under construction in an async function on |
| 118 // the catch prediction stack to handle exceptions thrown before | 113 // the catch prediction stack to handle exceptions thrown before |
| 119 // the first await. | 114 // the first await. |
| 120 // Assign ID and create a recurring task to save stack for future | 115 // Assign ID and create a recurring task to save stack for future |
| 121 // resumptions from await. | 116 // resumptions from await. |
| 122 %DebugAsyncFunctionPromiseCreated(promise); | 117 %DebugAsyncFunctionPromiseCreated(promise); |
| 123 } | 118 } |
| 124 return promise; | 119 return promise; |
| 125 } | 120 } |
| 126 | 121 |
| 127 function AsyncFunctionPromiseRelease(promise) { | 122 function AsyncFunctionPromiseRelease(promise) { |
| 128 if (DEBUG_IS_ACTIVE) { | 123 if (DEBUG_IS_ACTIVE) { |
| 129 // Pop the Promise under construction in an async function on | 124 // Pop the Promise under construction in an async function on |
| 130 // from catch prediction stack. | 125 // from catch prediction stack. |
| 131 %DebugPopPromise(); | 126 %DebugPopPromise(); |
| 132 } | 127 } |
| 133 } | 128 } |
| 134 | 129 |
| 135 %InstallToContext([ | 130 %InstallToContext([ |
| 136 "async_function_await_caught", AsyncFunctionAwaitCaught, | 131 "async_function_await_caught", AsyncFunctionAwaitCaught, |
| 137 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, | 132 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, |
| 138 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent, | |
| 139 "async_function_promise_create", AsyncFunctionPromiseCreate, | 133 "async_function_promise_create", AsyncFunctionPromiseCreate, |
| 140 "async_function_promise_release", AsyncFunctionPromiseRelease, | 134 "async_function_promise_release", AsyncFunctionPromiseRelease, |
| 141 ]); | 135 ]); |
| 142 | 136 |
| 143 }) | 137 }) |
| OLD | NEW |