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

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

Issue 2209433003: [promise] separate PerformPromiseThen from PromiseThen (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incorporate Dan's debugger fixes, + try to fix windows failures Created 4 years, 4 months 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 | « no previous file | src/js/prologue.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 PromiseReject; 16 var IsPromise;
17 var PromiseResolve; 17 var GlobalPromise;
18 var PromiseThen; 18 var NewPromiseCapability;
19 var PerformPromiseThen;
19 20
20 utils.Import(function(from) { 21 utils.Import(function(from) {
21 AsyncFunctionNext = from.AsyncFunctionNext; 22 AsyncFunctionNext = from.AsyncFunctionNext;
22 AsyncFunctionThrow = from.AsyncFunctionThrow; 23 AsyncFunctionThrow = from.AsyncFunctionThrow;
23 PromiseReject = from.PromiseCreateRejected; 24 IsPromise = from.IsPromise;
24 PromiseResolve = from.PromiseCreateResolved; 25 GlobalPromise = from.GlobalPromise;
25 PromiseThen = from.PromiseThen; 26 NewPromiseCapability = from.NewPromiseCapability;
27 PerformPromiseThen = from.PerformPromiseThen;
26 }); 28 });
27 29
28 // ------------------------------------------------------------------- 30 // -------------------------------------------------------------------
29 31
30 function AsyncFunctionAwait(generator, value) { 32 function AsyncFunctionAwait(generator, value) {
31 return %_Call( 33 // Promise.resolve(value).then(
32 PromiseThen, PromiseResolve(value), 34 // value => AsyncFunctionNext(value),
33 function(sentValue) { 35 // error => AsyncFunctionThrow(error)
34 return %_Call(AsyncFunctionNext, generator, sentValue); 36 // );
35 }, 37 var promise;
36 function(sentError) { 38 if (IsPromise(value)) {
37 return %_Call(AsyncFunctionThrow, generator, sentError); 39 promise = value;
38 }); 40 } else {
41 var promiseCapability = NewPromiseCapability(GlobalPromise);
42 %_Call(promiseCapability.resolve, UNDEFINED, value);
43 promise = promiseCapability.promise;
44 }
45
46 var onFulfilled =
47 (sentValue) => %_Call(AsyncFunctionNext, generator, sentValue);
48 var onRejected =
49 (sentError) => %_Call(AsyncFunctionThrow, generator, sentError);
50
51 var throwawayCapability = NewPromiseCapability(GlobalPromise);
52 return PerformPromiseThen(promise, onFulfilled, onRejected,
53 throwawayCapability);
39 } 54 }
40 55
41 %InstallToContext([ "async_function_await", AsyncFunctionAwait ]); 56 %InstallToContext([ "async_function_await", AsyncFunctionAwait ]);
42 57
43 }) 58 })
OLDNEW
« no previous file with comments | « no previous file | src/js/prologue.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698