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 GlobalPromise; | 16 var GlobalPromise; |
17 var IsPromise; | 17 var IsPromise; |
18 var NewPromiseCapability; | 18 var NewPromiseCapabilityWithoutCallbacks; |
19 var PerformPromiseThen; | 19 var PerformPromiseThen; |
20 var PromiseCreate; | 20 var PromiseCreate; |
21 var PromiseNextMicrotaskID; | 21 var PromiseNextMicrotaskID; |
22 var RejectPromise; | 22 var RejectPromise; |
23 var ResolvePromise; | 23 var ResolvePromise; |
24 | 24 |
25 utils.Import(function(from) { | 25 utils.Import(function(from) { |
26 AsyncFunctionNext = from.AsyncFunctionNext; | 26 AsyncFunctionNext = from.AsyncFunctionNext; |
27 AsyncFunctionThrow = from.AsyncFunctionThrow; | 27 AsyncFunctionThrow = from.AsyncFunctionThrow; |
28 GlobalPromise = from.GlobalPromise; | 28 GlobalPromise = from.GlobalPromise; |
29 IsPromise = from.IsPromise; | 29 IsPromise = from.IsPromise; |
30 NewPromiseCapability = from.NewPromiseCapability; | 30 NewPromiseCapabilityWithoutCallbacks = |
| 31 from.NewPromiseCapabilityWithoutCallbacks; |
31 PerformPromiseThen = from.PerformPromiseThen; | 32 PerformPromiseThen = from.PerformPromiseThen; |
32 PromiseCreate = from.PromiseCreate; | 33 PromiseCreate = from.PromiseCreate; |
33 RejectPromise = from.RejectPromise; | 34 RejectPromise = from.RejectPromise; |
34 ResolvePromise = from.ResolvePromise; | 35 ResolvePromise = from.ResolvePromise; |
35 }); | 36 }); |
36 | 37 |
37 var promiseAsyncStackIDSymbol = | 38 var promiseAsyncStackIDSymbol = |
38 utils.ImportNow("promise_async_stack_id_symbol"); | 39 utils.ImportNow("promise_async_stack_id_symbol"); |
39 var promiseHandledBySymbol = | 40 var promiseHandledBySymbol = |
40 utils.ImportNow("promise_handled_by_symbol"); | 41 utils.ImportNow("promise_handled_by_symbol"); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 }; | 84 }; |
84 var onRejected = sentError => { | 85 var onRejected = sentError => { |
85 %_Call(AsyncFunctionThrow, generator, sentError); | 86 %_Call(AsyncFunctionThrow, generator, sentError); |
86 // Similarly, returning the huge Promise here would cause a long | 87 // Similarly, returning the huge Promise here would cause a long |
87 // resolution chain to find what the exception to throw is, and | 88 // resolution chain to find what the exception to throw is, and |
88 // create a similar memory leak, and it does not matter what | 89 // create a similar memory leak, and it does not matter what |
89 // sort of rejection this intermediate Promise becomes. | 90 // sort of rejection this intermediate Promise becomes. |
90 return; | 91 return; |
91 } | 92 } |
92 | 93 |
93 // Just forwarding the exception, so no debugEvent for throwawayCapability | 94 // Just forwarding the exception, so no debugEvent for throwawayCapability. |
94 var throwawayCapability = NewPromiseCapability(GlobalPromise, false); | 95 var throwawayCapability = NewPromiseCapabilityWithoutCallbacks(); |
95 | 96 |
96 // The Promise will be thrown away and not handled, but it shouldn't trigger | 97 // The Promise will be thrown away and not handled, but it shouldn't trigger |
97 // unhandled reject events as its work is done | 98 // unhandled reject events as its work is done |
98 SET_PRIVATE(throwawayCapability.promise, promiseHasHandlerSymbol, true); | 99 SET_PRIVATE(throwawayCapability.promise, promiseHasHandlerSymbol, true); |
99 | 100 |
100 if (DEBUG_IS_ACTIVE) { | 101 if (DEBUG_IS_ACTIVE) { |
101 if (IsPromise(awaited)) { | 102 if (IsPromise(awaited)) { |
102 // Mark the reject handler callback to be a forwarding edge, rather | 103 // Mark the reject handler callback to be a forwarding edge, rather |
103 // than a meaningful catch handler | 104 // than a meaningful catch handler |
104 SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true); | 105 SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 168 |
168 %InstallToContext([ | 169 %InstallToContext([ |
169 "async_function_await_caught", AsyncFunctionAwaitCaught, | 170 "async_function_await_caught", AsyncFunctionAwaitCaught, |
170 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, | 171 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, |
171 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent, | 172 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent, |
172 "async_function_promise_create", AsyncFunctionPromiseCreate, | 173 "async_function_promise_create", AsyncFunctionPromiseCreate, |
173 "async_function_promise_release", AsyncFunctionPromiseRelease, | 174 "async_function_promise_release", AsyncFunctionPromiseRelease, |
174 ]); | 175 ]); |
175 | 176 |
176 }) | 177 }) |
OLD | NEW |