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 function AsyncFunctionPromiseCreate() { | |
110 var promise = %promise_internal_constructor(UNDEFINED); | |
111 if (DEBUG_IS_ACTIVE) { | |
112 // Push the Promise under construction in an async function on | |
113 // the catch prediction stack to handle exceptions thrown before | |
114 // the first await. | |
115 // Assign ID and create a recurring task to save stack for future | |
116 // resumptions from await. | |
117 %DebugAsyncFunctionPromiseCreated(promise); | |
118 } | |
119 return promise; | |
120 } | |
121 | |
122 function AsyncFunctionPromiseRelease(promise) { | |
123 if (DEBUG_IS_ACTIVE) { | |
124 // Pop the Promise under construction in an async function on | |
125 // from catch prediction stack. | |
126 %DebugPopPromise(); | |
127 } | |
128 } | |
129 | |
130 %InstallToContext([ | 109 %InstallToContext([ |
131 "async_function_await_caught", AsyncFunctionAwaitCaught, | 110 "async_function_await_caught", AsyncFunctionAwaitCaught, |
132 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, | 111 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, |
133 "async_function_promise_create", AsyncFunctionPromiseCreate, | |
134 "async_function_promise_release", AsyncFunctionPromiseRelease, | |
135 ]); | 112 ]); |
136 | 113 |
137 }) | 114 }) |
OLD | NEW |