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 |
11 // ------------------------------------------------------------------- | 11 // ------------------------------------------------------------------- |
12 // Imports | 12 // Imports |
13 | 13 |
14 var AsyncFunctionNext; | 14 var AsyncFunctionNext; |
15 var AsyncFunctionThrow; | 15 var AsyncFunctionThrow; |
16 var CreateInternalPromiseCapability; | |
17 var PromiseCreate; | 16 var PromiseCreate; |
18 var PromiseNextMicrotaskID; | 17 var PromiseNextMicrotaskID; |
19 var RejectPromise; | 18 var RejectPromise; |
20 | 19 |
21 utils.Import(function(from) { | 20 utils.Import(function(from) { |
22 AsyncFunctionNext = from.AsyncFunctionNext; | 21 AsyncFunctionNext = from.AsyncFunctionNext; |
23 AsyncFunctionThrow = from.AsyncFunctionThrow; | 22 AsyncFunctionThrow = from.AsyncFunctionThrow; |
24 CreateInternalPromiseCapability = from.CreateInternalPromiseCapability; | |
25 PromiseCreate = from.PromiseCreate; | 23 PromiseCreate = from.PromiseCreate; |
26 RejectPromise = from.RejectPromise; | 24 RejectPromise = from.RejectPromise; |
27 }); | 25 }); |
28 | 26 |
29 var promiseAsyncStackIDSymbol = | 27 var promiseAsyncStackIDSymbol = |
30 utils.ImportNow("promise_async_stack_id_symbol"); | 28 utils.ImportNow("promise_async_stack_id_symbol"); |
31 var promiseHandledBySymbol = | 29 var promiseHandledBySymbol = |
32 utils.ImportNow("promise_handled_by_symbol"); | 30 utils.ImportNow("promise_handled_by_symbol"); |
33 var promiseForwardingHandlerSymbol = | 31 var promiseForwardingHandlerSymbol = |
34 utils.ImportNow("promise_forwarding_handler_symbol"); | 32 utils.ImportNow("promise_forwarding_handler_symbol"); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 var onRejected = sentError => { | 73 var onRejected = sentError => { |
76 %_Call(AsyncFunctionThrow, generator, sentError); | 74 %_Call(AsyncFunctionThrow, generator, sentError); |
77 // Similarly, returning the huge Promise here would cause a long | 75 // Similarly, returning the huge Promise here would cause a long |
78 // resolution chain to find what the exception to throw is, and | 76 // resolution chain to find what the exception to throw is, and |
79 // create a similar memory leak, and it does not matter what | 77 // create a similar memory leak, and it does not matter what |
80 // sort of rejection this intermediate Promise becomes. | 78 // sort of rejection this intermediate Promise becomes. |
81 return; | 79 return; |
82 } | 80 } |
83 | 81 |
84 // Just forwarding the exception, so no debugEvent for throwawayCapability. | 82 // Just forwarding the exception, so no debugEvent for throwawayCapability. |
85 var throwawayCapability = CreateInternalPromiseCapability(promise); | 83 var throwawayCapability = %new_internal_promise_capability(promise); |
86 | 84 |
87 // The Promise will be thrown away and not handled, but it shouldn't trigger | 85 // The Promise will be thrown away and not handled, but it shouldn't trigger |
88 // unhandled reject events as its work is done | 86 // unhandled reject events as its work is done |
89 %PromiseMarkAsHandled(throwawayCapability.promise); | 87 %PromiseMarkAsHandled(throwawayCapability.promise); |
90 | 88 |
91 if (DEBUG_IS_ACTIVE) { | 89 if (DEBUG_IS_ACTIVE) { |
92 if (%is_promise(awaited)) { | 90 if (%is_promise(awaited)) { |
93 // Mark the reject handler callback to be a forwarding edge, rather | 91 // Mark the reject handler callback to be a forwarding edge, rather |
94 // than a meaningful catch handler | 92 // than a meaningful catch handler |
95 SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true); | 93 SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |