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

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: 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 GlobalPromise;
17 var PromiseResolve; 17 var NewPromiseCapability;
18 var PromiseThen; 18 var PerformPromiseThen;
19 19
20 utils.Import(function(from) { 20 utils.Import(function(from) {
21 AsyncFunctionNext = from.AsyncFunctionNext; 21 AsyncFunctionNext = from.AsyncFunctionNext;
22 AsyncFunctionThrow = from.AsyncFunctionThrow; 22 AsyncFunctionThrow = from.AsyncFunctionThrow;
23 PromiseReject = from.PromiseCreateRejected; 23 GlobalPromise = from.GlobalPromise;
24 PromiseResolve = from.PromiseCreateResolved; 24 NewPromiseCapability = from.NewPromiseCapability;
25 PromiseThen = from.PromiseThen; 25 PerformPromiseThen = from.PerformPromiseThen;
26 }); 26 });
27 27
28 // ------------------------------------------------------------------- 28 // -------------------------------------------------------------------
29 29
30 function AsyncFunctionAwait(generator, value) { 30 function AsyncFunctionAwait(generator, value) {
31 return %_Call( 31 // Promise.resolve(value).then(
32 PromiseThen, PromiseResolve(value), 32 // value => AsyncFunctionNext(value),
33 function(sentValue) { 33 // error => AsyncFunctionThrow(error)
34 return %_Call(AsyncFunctionNext, generator, sentValue); 34 // );
35 }, 35 var promiseCapability = NewPromiseCapability(GlobalPromise);
36 function(sentError) { 36 var resolveResult = %_Call(promiseCapability.resolve, UNDEFINED, value);
37 return %_Call(AsyncFunctionThrow, generator, sentError); 37 var onFulfilled =
38 }); 38 (sentValue) => %_Call(AsyncFunctionNext, generator, sentValue);
39 var onRejected =
40 (sentError) => %_Call(AsyncFunctionThrow, generator, sentError);
41
42 var throwawayCapability = NewPromiseCapability(GlobalPromise);
Dan Ehrenberg 2016/08/02 20:20:56 I'm a big fan of how this exactly mirrors the spec
caitp 2016/08/02 20:40:20 I assume that's meant to be "I'm not a big fan of
Dan Ehrenberg 2016/08/02 20:54:45 Yeah, this does seem tricky. I definitely didn't m
43 return PerformPromiseThen(promiseCapability.promise, onFulfilled, onRejected,
44 throwawayCapability);
39 } 45 }
40 46
41 %InstallToContext([ "async_function_await", AsyncFunctionAwait ]); 47 %InstallToContext([ "async_function_await", AsyncFunctionAwait ]);
42 48
43 }) 49 })
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