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 NewPromiseCapability; |
19 var PerformPromiseThen; | 19 var PerformPromiseThen; |
20 var PromiseCreate; | 20 var PromiseCreate; |
21 var PromiseNextMicrotaskID; | 21 var PromiseNextMicrotaskID; |
22 var RejectPromise; | 22 var PromiseSet; |
23 var ResolvePromise; | 23 var ResolvePromise; |
| 24 var kPromiseRejected; |
24 | 25 |
25 utils.Import(function(from) { | 26 utils.Import(function(from) { |
26 AsyncFunctionNext = from.AsyncFunctionNext; | 27 AsyncFunctionNext = from.AsyncFunctionNext; |
27 AsyncFunctionThrow = from.AsyncFunctionThrow; | 28 AsyncFunctionThrow = from.AsyncFunctionThrow; |
28 GlobalPromise = from.GlobalPromise; | 29 GlobalPromise = from.GlobalPromise; |
29 IsPromise = from.IsPromise; | 30 IsPromise = from.IsPromise; |
30 NewPromiseCapability = from.NewPromiseCapability; | 31 NewPromiseCapability = from.NewPromiseCapability; |
31 PerformPromiseThen = from.PerformPromiseThen; | 32 PerformPromiseThen = from.PerformPromiseThen; |
32 PromiseCreate = from.PromiseCreate; | 33 PromiseCreate = from.PromiseCreate; |
33 RejectPromise = from.RejectPromise; | 34 PromiseSet = from.PromiseSet; |
34 ResolvePromise = from.ResolvePromise; | 35 ResolvePromise = from.ResolvePromise; |
| 36 kPromiseRejected = from.kPromiseRejected; |
35 }); | 37 }); |
36 | 38 |
37 var promiseAsyncStackIDSymbol = | 39 var promiseAsyncStackIDSymbol = |
38 utils.ImportNow("promise_async_stack_id_symbol"); | 40 utils.ImportNow("promise_async_stack_id_symbol"); |
39 var promiseHandledBySymbol = | 41 var promiseHandledBySymbol = |
40 utils.ImportNow("promise_handled_by_symbol"); | 42 utils.ImportNow("promise_handled_by_symbol"); |
41 var promiseForwardingHandlerSymbol = | 43 var promiseForwardingHandlerSymbol = |
42 utils.ImportNow("promise_forwarding_handler_symbol"); | 44 utils.ImportNow("promise_forwarding_handler_symbol"); |
43 var promiseHandledHintSymbol = | 45 var promiseHandledHintSymbol = |
44 utils.ImportNow("promise_handled_hint_symbol"); | 46 utils.ImportNow("promise_handled_hint_symbol"); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // prediction indicates that there is a locally surrounding catch block | 125 // prediction indicates that there is a locally surrounding catch block |
124 function AsyncFunctionAwaitCaught(generator, awaited, outerPromise) { | 126 function AsyncFunctionAwaitCaught(generator, awaited, outerPromise) { |
125 if (DEBUG_IS_ACTIVE && IsPromise(awaited)) { | 127 if (DEBUG_IS_ACTIVE && IsPromise(awaited)) { |
126 SET_PRIVATE(awaited, promiseHandledHintSymbol, true); | 128 SET_PRIVATE(awaited, promiseHandledHintSymbol, true); |
127 } | 129 } |
128 AsyncFunctionAwait(generator, awaited, outerPromise); | 130 AsyncFunctionAwait(generator, awaited, outerPromise); |
129 } | 131 } |
130 | 132 |
131 // How the parser rejects promises from async/await desugaring | 133 // How the parser rejects promises from async/await desugaring |
132 function RejectPromiseNoDebugEvent(promise, reason) { | 134 function RejectPromiseNoDebugEvent(promise, reason) { |
133 return RejectPromise(promise, reason, false); | 135 %PromiseReject(promise, reason, false); |
| 136 PromiseSet(promise, kPromiseRejected, reason); |
134 } | 137 } |
135 | 138 |
136 function AsyncFunctionPromiseCreate() { | 139 function AsyncFunctionPromiseCreate() { |
137 var promise = PromiseCreate(); | 140 var promise = PromiseCreate(); |
138 if (DEBUG_IS_ACTIVE) { | 141 if (DEBUG_IS_ACTIVE) { |
139 // Push the Promise under construction in an async function on | 142 // Push the Promise under construction in an async function on |
140 // the catch prediction stack to handle exceptions thrown before | 143 // the catch prediction stack to handle exceptions thrown before |
141 // the first await. | 144 // the first await. |
142 %DebugPushPromise(promise); | 145 %DebugPushPromise(promise); |
143 // Assign ID and create a recurring task to save stack for future | 146 // Assign ID and create a recurring task to save stack for future |
(...skipping 23 matching lines...) Expand all 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 |