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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 }; | 83 }; |
84 var onRejected = sentError => { | 84 var onRejected = sentError => { |
85 %_Call(AsyncFunctionThrow, generator, sentError); | 85 %_Call(AsyncFunctionThrow, generator, sentError); |
86 // Similarly, returning the huge Promise here would cause a long | 86 // Similarly, returning the huge Promise here would cause a long |
87 // resolution chain to find what the exception to throw is, and | 87 // resolution chain to find what the exception to throw is, and |
88 // create a similar memory leak, and it does not matter what | 88 // create a similar memory leak, and it does not matter what |
89 // sort of rejection this intermediate Promise becomes. | 89 // sort of rejection this intermediate Promise becomes. |
90 return; | 90 return; |
91 } | 91 } |
92 | 92 |
93 // Just forwarding the exception, so no debugEvent for throwawayCapability | 93 // Just forwarding the exception, so no debugEvent for throwawayCapability. |
94 var throwawayCapability = NewPromiseCapability(GlobalPromise, false); | 94 // The resultCapability.promise is only ever fulfilled internally, |
| 95 // so we don't need the closures to protect against accidentally |
| 96 // calling them multiple times. |
| 97 var throwawayCapability = NewPromiseCapability(GlobalPromise, false, true); |
95 | 98 |
96 // The Promise will be thrown away and not handled, but it shouldn't trigger | 99 // The Promise will be thrown away and not handled, but it shouldn't trigger |
97 // unhandled reject events as its work is done | 100 // unhandled reject events as its work is done |
98 SET_PRIVATE(throwawayCapability.promise, promiseHasHandlerSymbol, true); | 101 SET_PRIVATE(throwawayCapability.promise, promiseHasHandlerSymbol, true); |
99 | 102 |
100 if (DEBUG_IS_ACTIVE) { | 103 if (DEBUG_IS_ACTIVE) { |
101 if (IsPromise(awaited)) { | 104 if (IsPromise(awaited)) { |
102 // Mark the reject handler callback to be a forwarding edge, rather | 105 // Mark the reject handler callback to be a forwarding edge, rather |
103 // than a meaningful catch handler | 106 // than a meaningful catch handler |
104 SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true); | 107 SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 170 |
168 %InstallToContext([ | 171 %InstallToContext([ |
169 "async_function_await_caught", AsyncFunctionAwaitCaught, | 172 "async_function_await_caught", AsyncFunctionAwaitCaught, |
170 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, | 173 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, |
171 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent, | 174 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent, |
172 "async_function_promise_create", AsyncFunctionPromiseCreate, | 175 "async_function_promise_create", AsyncFunctionPromiseCreate, |
173 "async_function_promise_release", AsyncFunctionPromiseRelease, | 176 "async_function_promise_release", AsyncFunctionPromiseRelease, |
174 ]); | 177 ]); |
175 | 178 |
176 }) | 179 }) |
OLD | NEW |