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

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

Issue 2554943002: Reland Create JSPromise (patchset #16 id:300001 of https://codereview.chromium.org/2536463002/ )" (Closed)
Patch Set: fix test 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/isolate.cc ('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 CreateInternalPromiseCapability; 16 var CreateInternalPromiseCapability;
17 var PerformPromiseThen;
18 var PromiseCreate; 17 var PromiseCreate;
19 var PromiseNextMicrotaskID; 18 var PromiseNextMicrotaskID;
20 var RejectPromise; 19 var RejectPromise;
21 var ResolvePromise; 20 var ResolvePromise;
22 21
23 utils.Import(function(from) { 22 utils.Import(function(from) {
24 AsyncFunctionNext = from.AsyncFunctionNext; 23 AsyncFunctionNext = from.AsyncFunctionNext;
25 AsyncFunctionThrow = from.AsyncFunctionThrow; 24 AsyncFunctionThrow = from.AsyncFunctionThrow;
26 CreateInternalPromiseCapability = from.CreateInternalPromiseCapability; 25 CreateInternalPromiseCapability = from.CreateInternalPromiseCapability;
27 PerformPromiseThen = from.PerformPromiseThen;
28 PromiseCreate = from.PromiseCreate; 26 PromiseCreate = from.PromiseCreate;
29 RejectPromise = from.RejectPromise; 27 RejectPromise = from.RejectPromise;
30 ResolvePromise = from.ResolvePromise; 28 ResolvePromise = from.ResolvePromise;
31 }); 29 });
32 30
33 var promiseAsyncStackIDSymbol = 31 var promiseAsyncStackIDSymbol =
34 utils.ImportNow("promise_async_stack_id_symbol"); 32 utils.ImportNow("promise_async_stack_id_symbol");
35 var promiseHandledBySymbol = 33 var promiseHandledBySymbol =
36 utils.ImportNow("promise_handled_by_symbol"); 34 utils.ImportNow("promise_handled_by_symbol");
37 var promiseForwardingHandlerSymbol = 35 var promiseForwardingHandlerSymbol =
38 utils.ImportNow("promise_forwarding_handler_symbol"); 36 utils.ImportNow("promise_forwarding_handler_symbol");
39 var promiseHandledHintSymbol = 37 var promiseHandledHintSymbol =
40 utils.ImportNow("promise_handled_hint_symbol"); 38 utils.ImportNow("promise_handled_hint_symbol");
41 var promiseHasHandlerSymbol = 39 var promiseHasHandlerSymbol =
42 utils.ImportNow("promise_has_handler_symbol"); 40 utils.ImportNow("promise_has_handler_symbol");
43 41
44 // ------------------------------------------------------------------- 42 // -------------------------------------------------------------------
45 43
46 function PromiseCastResolved(value) { 44 function PromiseCastResolved(value) {
45 // TODO(caitp): This is non spec compliant. See v8:5694.
47 if (%is_promise(value)) { 46 if (%is_promise(value)) {
48 return value; 47 return value;
49 } else { 48 } else {
50 var promise = PromiseCreate(); 49 var promise = PromiseCreate();
51 ResolvePromise(promise, value); 50 ResolvePromise(promise, value);
52 return promise; 51 return promise;
53 } 52 }
54 } 53 }
55 54
56 // ES#abstract-ops-async-function-await 55 // ES#abstract-ops-async-function-await
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 // than a meaningful catch handler 98 // than a meaningful catch handler
100 SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true); 99 SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true);
101 } 100 }
102 101
103 // Mark the dependency to outerPromise in case the throwaway Promise is 102 // Mark the dependency to outerPromise in case the throwaway Promise is
104 // found on the Promise stack 103 // found on the Promise stack
105 SET_PRIVATE(throwawayCapability.promise, promiseHandledBySymbol, 104 SET_PRIVATE(throwawayCapability.promise, promiseHandledBySymbol,
106 outerPromise); 105 outerPromise);
107 } 106 }
108 107
109 PerformPromiseThen(promise, onFulfilled, onRejected, throwawayCapability); 108 %perform_promise_then(promise, onFulfilled, onRejected, throwawayCapability);
110 } 109 }
111 110
112 // Called by the parser from the desugaring of 'await' when catch 111 // Called by the parser from the desugaring of 'await' when catch
113 // prediction indicates no locally surrounding catch block 112 // prediction indicates no locally surrounding catch block
114 function AsyncFunctionAwaitUncaught(generator, awaited, outerPromise) { 113 function AsyncFunctionAwaitUncaught(generator, awaited, outerPromise) {
115 AsyncFunctionAwait(generator, awaited, outerPromise); 114 AsyncFunctionAwait(generator, awaited, outerPromise);
116 } 115 }
117 116
118 // Called by the parser from the desugaring of 'await' when catch 117 // Called by the parser from the desugaring of 'await' when catch
119 // prediction indicates that there is a locally surrounding catch block 118 // prediction indicates that there is a locally surrounding catch block
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 162
164 %InstallToContext([ 163 %InstallToContext([
165 "async_function_await_caught", AsyncFunctionAwaitCaught, 164 "async_function_await_caught", AsyncFunctionAwaitCaught,
166 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, 165 "async_function_await_uncaught", AsyncFunctionAwaitUncaught,
167 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent, 166 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent,
168 "async_function_promise_create", AsyncFunctionPromiseCreate, 167 "async_function_promise_create", AsyncFunctionPromiseCreate,
169 "async_function_promise_release", AsyncFunctionPromiseRelease, 168 "async_function_promise_release", AsyncFunctionPromiseRelease,
170 ]); 169 ]);
171 170
172 }) 171 })
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/js/promise.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698