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

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

Issue 2348403002: Reland of Fix async/await memory leak (Closed)
Patch Set: Formatting 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
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/harmony-async-await.js
diff --git a/src/js/harmony-async-await.js b/src/js/harmony-async-await.js
index 396ebdc750a8c865f8007592a9a7ce518ba88d9a..dc82249e9fc49595d6a53169fe2ca8b5eca62b51 100644
--- a/src/js/harmony-async-await.js
+++ b/src/js/harmony-async-await.js
@@ -66,10 +66,22 @@ function AsyncFunctionAwait(generator, awaited, mark) {
// );
var promise = PromiseCastResolved(awaited);
- var onFulfilled =
- (sentValue) => %_Call(AsyncFunctionNext, generator, sentValue);
- var onRejected =
- (sentError) => %_Call(AsyncFunctionThrow, generator, sentError);
+ var onFulfilled = sentValue => {
+ %_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 => {
+ %_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;
+ }
if (mark && DEBUG_IS_ACTIVE && IsPromise(awaited)) {
// Mark the reject handler callback such that it does not influence
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698