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

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

Issue 2541283002: [promises] Port ResolvePromise to TF (Closed)
Patch Set: fix nits 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
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 PromiseCreate; 17 var PromiseCreate;
18 var PromiseNextMicrotaskID; 18 var PromiseNextMicrotaskID;
19 var RejectPromise; 19 var RejectPromise;
20 var ResolvePromise;
21 20
22 utils.Import(function(from) { 21 utils.Import(function(from) {
23 AsyncFunctionNext = from.AsyncFunctionNext; 22 AsyncFunctionNext = from.AsyncFunctionNext;
24 AsyncFunctionThrow = from.AsyncFunctionThrow; 23 AsyncFunctionThrow = from.AsyncFunctionThrow;
25 CreateInternalPromiseCapability = from.CreateInternalPromiseCapability; 24 CreateInternalPromiseCapability = from.CreateInternalPromiseCapability;
26 PromiseCreate = from.PromiseCreate; 25 PromiseCreate = from.PromiseCreate;
27 RejectPromise = from.RejectPromise; 26 RejectPromise = from.RejectPromise;
28 ResolvePromise = from.ResolvePromise;
29 }); 27 });
30 28
31 var promiseAsyncStackIDSymbol = 29 var promiseAsyncStackIDSymbol =
32 utils.ImportNow("promise_async_stack_id_symbol"); 30 utils.ImportNow("promise_async_stack_id_symbol");
33 var promiseHandledBySymbol = 31 var promiseHandledBySymbol =
34 utils.ImportNow("promise_handled_by_symbol"); 32 utils.ImportNow("promise_handled_by_symbol");
35 var promiseForwardingHandlerSymbol = 33 var promiseForwardingHandlerSymbol =
36 utils.ImportNow("promise_forwarding_handler_symbol"); 34 utils.ImportNow("promise_forwarding_handler_symbol");
37 var promiseHandledHintSymbol = 35 var promiseHandledHintSymbol =
38 utils.ImportNow("promise_handled_hint_symbol"); 36 utils.ImportNow("promise_handled_hint_symbol");
39 var promiseHasHandlerSymbol =
40 utils.ImportNow("promise_has_handler_symbol");
41 37
42 // ------------------------------------------------------------------- 38 // -------------------------------------------------------------------
43 39
44 function PromiseCastResolved(value) { 40 function PromiseCastResolved(value) {
45 // TODO(caitp): This is non spec compliant. See v8:5694. 41 // TODO(caitp): This is non spec compliant. See v8:5694.
46 if (%is_promise(value)) { 42 if (%is_promise(value)) {
47 return value; 43 return value;
48 } else { 44 } else {
49 var promise = PromiseCreate(); 45 var promise = PromiseCreate();
50 ResolvePromise(promise, value); 46 %promise_resolve(promise, value);
51 return promise; 47 return promise;
52 } 48 }
53 } 49 }
54 50
55 // ES#abstract-ops-async-function-await 51 // ES#abstract-ops-async-function-await
56 // AsyncFunctionAwait ( value ) 52 // AsyncFunctionAwait ( value )
57 // Shared logic for the core of await. The parser desugars 53 // Shared logic for the core of await. The parser desugars
58 // await awaited 54 // await awaited
59 // into 55 // into
60 // yield AsyncFunctionAwait{Caught,Uncaught}(.generator, awaited, .promise) 56 // yield AsyncFunctionAwait{Caught,Uncaught}(.generator, awaited, .promise)
(...skipping 22 matching lines...) Expand all
83 // create a similar memory leak, and it does not matter what 79 // create a similar memory leak, and it does not matter what
84 // sort of rejection this intermediate Promise becomes. 80 // sort of rejection this intermediate Promise becomes.
85 return; 81 return;
86 } 82 }
87 83
88 // Just forwarding the exception, so no debugEvent for throwawayCapability. 84 // Just forwarding the exception, so no debugEvent for throwawayCapability.
89 var throwawayCapability = CreateInternalPromiseCapability(); 85 var throwawayCapability = CreateInternalPromiseCapability();
90 86
91 // The Promise will be thrown away and not handled, but it shouldn't trigger 87 // The Promise will be thrown away and not handled, but it shouldn't trigger
92 // unhandled reject events as its work is done 88 // unhandled reject events as its work is done
93 SET_PRIVATE(throwawayCapability.promise, promiseHasHandlerSymbol, true); 89 %PromiseMarkAsHandled(throwawayCapability.promise);
94 90
95 if (DEBUG_IS_ACTIVE) { 91 if (DEBUG_IS_ACTIVE) {
96 if (%is_promise(awaited)) { 92 if (%is_promise(awaited)) {
97 // Mark the reject handler callback to be a forwarding edge, rather 93 // Mark the reject handler callback to be a forwarding edge, rather
98 // than a meaningful catch handler 94 // than a meaningful catch handler
99 SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true); 95 SET_PRIVATE(onRejected, promiseForwardingHandlerSymbol, true);
100 } 96 }
101 97
102 // Mark the dependency to outerPromise in case the throwaway Promise is 98 // Mark the dependency to outerPromise in case the throwaway Promise is
103 // found on the Promise stack 99 // found on the Promise stack
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 158
163 %InstallToContext([ 159 %InstallToContext([
164 "async_function_await_caught", AsyncFunctionAwaitCaught, 160 "async_function_await_caught", AsyncFunctionAwaitCaught,
165 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, 161 "async_function_await_uncaught", AsyncFunctionAwaitUncaught,
166 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent, 162 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent,
167 "async_function_promise_create", AsyncFunctionPromiseCreate, 163 "async_function_promise_create", AsyncFunctionPromiseCreate,
168 "async_function_promise_release", AsyncFunctionPromiseRelease, 164 "async_function_promise_release", AsyncFunctionPromiseRelease,
169 ]); 165 ]);
170 166
171 }) 167 })
OLDNEW
« no previous file with comments | « src/heap-symbols.h ('k') | src/js/promise.js » ('j') | src/js/promise.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698