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

Unified Diff: src/js/harmony-async-await.js

Issue 2334323006: Fix async/await memory leak (Closed)
Patch Set: Also do for catch, and fix another test Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: src/js/harmony-async-await.js
diff --git a/src/js/harmony-async-await.js b/src/js/harmony-async-await.js
index 0d470bbe8c84300dfcd9213ba1becb016294bd40..a7934abec0d173fea2dab8f87ecdaff7d45a5a11 100644
--- a/src/js/harmony-async-await.js
+++ b/src/js/harmony-async-await.js
@@ -67,10 +67,22 @@ function AsyncFunctionAwait(generator, awaited, outerPromise) {
// );
var promise = PromiseCastResolved(awaited);
- var onFulfilled =
- (sentValue) => %_Call(AsyncFunctionNext, generator, sentValue);
- var onRejected =
- (sentError) => %_Call(AsyncFunctionThrow, generator, sentError);
+ var onFulfilled = (sentValue) => {
adamk 2016/09/15 22:43:20 Nit: no need for parens while you're changing this
Dan Ehrenberg 2016/09/16 00:36:01 Done
+ %_Call(AsyncFunctionNext, generator, sentValue);
+ // The resulting Promise is a throwaway, so it doesn't matter what it
+ // resolves to. What is important is that we don't end up keeping the
+ // whole chain of intermediate Promises alive by returning the value
+ // of AsyncFunctionNext, as that would create a memory leak.
+ return;
+ };
+ var onRejected = (sentError) => {
adamk 2016/09/15 22:43:20 ditto
Dan Ehrenberg 2016/09/16 00:36:00 Done
+ %_Call(AsyncFunctionThrow, generator, sentError);
+ // Similarly, returning the huge Promise here would cause a long
+ // resolution chain to find what the exception to throw is, and
+ // create a similar memory leak, and it does not matter what
+ // sort of rejection this intermediate Promise becomes.
+ return;
+ }
// Just forwarding the exception, so no debugEvent for throwawayCapability
var throwawayCapability = NewPromiseCapability(GlobalPromise, false);
« no previous file with comments | « no previous file | test/mjsunit/harmony/async-await-loop.js » ('j') | test/mjsunit/harmony/debug-async-function-async-task-event.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698