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

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

Issue 2348403003: Revert of Fix async/await memory leak (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('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
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // yield AsyncFunctionAwait{Caught,Uncaught}(.generator, awaited) 59 // yield AsyncFunctionAwait{Caught,Uncaught}(.generator, awaited)
60 // The 'awaited' parameter is the value; the generator stands in 60 // The 'awaited' parameter is the value; the generator stands in
61 // for the asyncContext, and mark is metadata for debugging 61 // for the asyncContext, and mark is metadata for debugging
62 function AsyncFunctionAwait(generator, awaited, mark) { 62 function AsyncFunctionAwait(generator, awaited, mark) {
63 // Promise.resolve(awaited).then( 63 // Promise.resolve(awaited).then(
64 // value => AsyncFunctionNext(value), 64 // value => AsyncFunctionNext(value),
65 // error => AsyncFunctionThrow(error) 65 // error => AsyncFunctionThrow(error)
66 // ); 66 // );
67 var promise = PromiseCastResolved(awaited); 67 var promise = PromiseCastResolved(awaited);
68 68
69 var onFulfilled = sentValue => { 69 var onFulfilled =
70 %_Call(AsyncFunctionNext, generator, sentValue); 70 (sentValue) => %_Call(AsyncFunctionNext, generator, sentValue);
71 // The resulting Promise is a throwaway, so it doesn't matter what it 71 var onRejected =
72 // resolves to. What is important is that we don't end up keeping the 72 (sentError) => %_Call(AsyncFunctionThrow, generator, sentError);
73 // whole chain of intermediate Promises alive by returning the value
74 // of AsyncFunctionNext, as that would create a memory leak.
75 return;
76 };
77 var onRejected = sentError => {
78 %_Call(AsyncFunctionThrow, generator, sentError);
79 // Similarly, returning the huge Promise here would cause a long
80 // resolution chain to find what the exception to throw is, and
81 // create a similar memory leak, and it does not matter what
82 // sort of rejection this intermediate Promise becomes.
83 return;
84 }
85 73
86 if (mark && DEBUG_IS_ACTIVE && IsPromise(awaited)) { 74 if (mark && DEBUG_IS_ACTIVE && IsPromise(awaited)) {
87 // Mark the reject handler callback such that it does not influence 75 // Mark the reject handler callback such that it does not influence
88 // catch prediction. 76 // catch prediction.
89 SET_PRIVATE(onRejected, promiseAwaitHandlerSymbol, true); 77 SET_PRIVATE(onRejected, promiseAwaitHandlerSymbol, true);
90 } 78 }
91 79
92 // Just forwarding the exception, so no debugEvent for throwawayCapability 80 // Just forwarding the exception, so no debugEvent for throwawayCapability
93 var throwawayCapability = NewPromiseCapability(GlobalPromise, false); 81 var throwawayCapability = NewPromiseCapability(GlobalPromise, false);
94 82
(...skipping 26 matching lines...) Expand all
121 return RejectPromise(promise, reason, false); 109 return RejectPromise(promise, reason, false);
122 } 110 }
123 111
124 %InstallToContext([ 112 %InstallToContext([
125 "async_function_await_caught", AsyncFunctionAwaitCaught, 113 "async_function_await_caught", AsyncFunctionAwaitCaught,
126 "async_function_await_uncaught", AsyncFunctionAwaitUncaught, 114 "async_function_await_uncaught", AsyncFunctionAwaitUncaught,
127 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent, 115 "reject_promise_no_debug_event", RejectPromiseNoDebugEvent,
128 ]); 116 ]);
129 117
130 }) 118 })
OLDNEW
« 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