Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: src/js/async-await.js

Issue 2521723003: [promises] Remove IsPromise (Closed)
Patch Set: rebase again Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug/mirrors.js ('k') | src/js/promise.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 IsPromise;
17 var CreateInternalPromiseCapability; 16 var CreateInternalPromiseCapability;
18 var PerformPromiseThen; 17 var PerformPromiseThen;
19 var PromiseCreate; 18 var PromiseCreate;
20 var PromiseNextMicrotaskID; 19 var PromiseNextMicrotaskID;
21 var RejectPromise; 20 var RejectPromise;
22 var ResolvePromise; 21 var ResolvePromise;
23 22
24 utils.Import(function(from) { 23 utils.Import(function(from) {
25 AsyncFunctionNext = from.AsyncFunctionNext; 24 AsyncFunctionNext = from.AsyncFunctionNext;
26 AsyncFunctionThrow = from.AsyncFunctionThrow; 25 AsyncFunctionThrow = from.AsyncFunctionThrow;
27 IsPromise = from.IsPromise;
28 CreateInternalPromiseCapability = from.CreateInternalPromiseCapability; 26 CreateInternalPromiseCapability = from.CreateInternalPromiseCapability;
29 PerformPromiseThen = from.PerformPromiseThen; 27 PerformPromiseThen = from.PerformPromiseThen;
30 PromiseCreate = from.PromiseCreate; 28 PromiseCreate = from.PromiseCreate;
31 RejectPromise = from.RejectPromise; 29 RejectPromise = from.RejectPromise;
32 ResolvePromise = from.ResolvePromise; 30 ResolvePromise = from.ResolvePromise;
33 }); 31 });
34 32
35 var promiseAsyncStackIDSymbol = 33 var promiseAsyncStackIDSymbol =
36 utils.ImportNow("promise_async_stack_id_symbol"); 34 utils.ImportNow("promise_async_stack_id_symbol");
37 var promiseHandledBySymbol = 35 var promiseHandledBySymbol =
38 utils.ImportNow("promise_handled_by_symbol"); 36 utils.ImportNow("promise_handled_by_symbol");
39 var promiseForwardingHandlerSymbol = 37 var promiseForwardingHandlerSymbol =
40 utils.ImportNow("promise_forwarding_handler_symbol"); 38 utils.ImportNow("promise_forwarding_handler_symbol");
41 var promiseHandledHintSymbol = 39 var promiseHandledHintSymbol =
42 utils.ImportNow("promise_handled_hint_symbol"); 40 utils.ImportNow("promise_handled_hint_symbol");
43 var promiseHasHandlerSymbol = 41 var promiseHasHandlerSymbol =
44 utils.ImportNow("promise_has_handler_symbol"); 42 utils.ImportNow("promise_has_handler_symbol");
45 43
46 // ------------------------------------------------------------------- 44 // -------------------------------------------------------------------
47 45
48 function PromiseCastResolved(value) { 46 function PromiseCastResolved(value) {
49 if (IsPromise(value)) { 47 if (%is_promise(value)) {
50 return value; 48 return value;
51 } else { 49 } else {
52 var promise = PromiseCreate(); 50 var promise = PromiseCreate();
53 ResolvePromise(promise, value); 51 ResolvePromise(promise, value);
54 return promise; 52 return promise;
55 } 53 }
56 } 54 }
57 55
58 // ES#abstract-ops-async-function-await 56 // ES#abstract-ops-async-function-await
59 // AsyncFunctionAwait ( value ) 57 // AsyncFunctionAwait ( value )
(...skipping 29 matching lines...) Expand all
89 } 87 }
90 88
91 // Just forwarding the exception, so no debugEvent for throwawayCapability. 89 // Just forwarding the exception, so no debugEvent for throwawayCapability.
92 var throwawayCapability = CreateInternalPromiseCapability(); 90 var throwawayCapability = CreateInternalPromiseCapability();
93 91
94 // The Promise will be thrown away and not handled, but it shouldn't trigger 92 // The Promise will be thrown away and not handled, but it shouldn't trigger
95 // unhandled reject events as its work is done 93 // unhandled reject events as its work is done
96 SET_PRIVATE(throwawayCapability.promise, promiseHasHandlerSymbol, true); 94 SET_PRIVATE(throwawayCapability.promise, promiseHasHandlerSymbol, true);
97 95
98 if (DEBUG_IS_ACTIVE) { 96 if (DEBUG_IS_ACTIVE) {
99 if (IsPromise(awaited)) { 97 if (%is_promise(awaited)) {
100 // Mark the reject handler callback to be a forwarding edge, rather 98 // Mark the reject handler callback to be a forwarding edge, rather
101 // than a meaningful catch handler 99 // than a meaningful catch handler
102 SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true); 100 SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true);
103 } 101 }
104 102
105 // Mark the dependency to outerPromise in case the throwaway Promise is 103 // Mark the dependency to outerPromise in case the throwaway Promise is
106 // found on the Promise stack 104 // found on the Promise stack
107 SET_PRIVATE(throwawayCapability.promise, promiseHandledBySymbol, 105 SET_PRIVATE(throwawayCapability.promise, promiseHandledBySymbol,
108 outerPromise); 106 outerPromise);
109 } 107 }
110 108
111 PerformPromiseThen(promise, onFulfilled, onRejected, throwawayCapability); 109 PerformPromiseThen(promise, onFulfilled, onRejected, throwawayCapability);
112 } 110 }
113 111
114 // Called by the parser from the desugaring of 'await' when catch 112 // Called by the parser from the desugaring of 'await' when catch
115 // prediction indicates no locally surrounding catch block 113 // prediction indicates no locally surrounding catch block
116 function AsyncFunctionAwaitUncaught(generator, awaited, outerPromise) { 114 function AsyncFunctionAwaitUncaught(generator, awaited, outerPromise) {
117 AsyncFunctionAwait(generator, awaited, outerPromise); 115 AsyncFunctionAwait(generator, awaited, outerPromise);
118 } 116 }
119 117
120 // Called by the parser from the desugaring of 'await' when catch 118 // Called by the parser from the desugaring of 'await' when catch
121 // prediction indicates that there is a locally surrounding catch block 119 // prediction indicates that there is a locally surrounding catch block
122 function AsyncFunctionAwaitCaught(generator, awaited, outerPromise) { 120 function AsyncFunctionAwaitCaught(generator, awaited, outerPromise) {
123 if (DEBUG_IS_ACTIVE && IsPromise(awaited)) { 121 if (DEBUG_IS_ACTIVE && %is_promise(awaited)) {
124 SET_PRIVATE(awaited, promiseHandledHintSymbol, true); 122 SET_PRIVATE(awaited, promiseHandledHintSymbol, true);
125 } 123 }
126 AsyncFunctionAwait(generator, awaited, outerPromise); 124 AsyncFunctionAwait(generator, awaited, outerPromise);
127 } 125 }
128 126
129 // How the parser rejects promises from async/await desugaring 127 // How the parser rejects promises from async/await desugaring
130 function RejectPromiseNoDebugEvent(promise, reason) { 128 function RejectPromiseNoDebugEvent(promise, reason) {
131 return RejectPromise(promise, reason, false); 129 return RejectPromise(promise, reason, false);
132 } 130 }
133 131
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 163
166 %InstallToContext([ 164 %InstallToContext([
167 "async_function_await_caught", AsyncFunctionAwaitCaught, 165 "async_function_await_caught", AsyncFunctionAwaitCaught,
168 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, 166 "async_function_await_uncaught", AsyncFunctionAwaitUncaught,
169 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent, 167 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent,
170 "async_function_promise_create", AsyncFunctionPromiseCreate, 168 "async_function_promise_create", AsyncFunctionPromiseCreate,
171 "async_function_promise_release", AsyncFunctionPromiseRelease, 169 "async_function_promise_release", AsyncFunctionPromiseRelease,
172 ]); 170 ]);
173 171
174 }) 172 })
OLDNEW
« no previous file with comments | « src/debug/mirrors.js ('k') | src/js/promise.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698