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

Unified Diff: runtime/vm/parser.cc

Issue 1236943003: Create only one closure for the body of an async* function. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index d3ccd424b460387eda6b682b53f55741618863dd..7763caebafa46d18c87a3665da8649eaa0d7f3eb 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -6736,13 +6736,13 @@ RawFunction* Parser::OpenAsyncGeneratorFunction(intptr_t async_func_pos) {
// ... source code of f ...
// }
// var :async_op = f_async_body;
-// :controller = new _AsyncStarStreamController(f_async_body);
+// :controller = new _AsyncStarStreamController(:async_op);
// return :controller.stream;
// }
-SequenceNode* Parser::CloseAsyncGeneratorFunction(const Function& closure,
+SequenceNode* Parser::CloseAsyncGeneratorFunction(const Function& closure_func,
SequenceNode* closure_body) {
TRACE_PARSER("CloseAsyncGeneratorFunction");
- ASSERT(!closure.IsNull());
+ ASSERT(!closure_func.IsNull());
ASSERT(closure_body != NULL);
// The block for the async closure body has already been closed. Close the
@@ -6775,19 +6775,17 @@ SequenceNode* Parser::CloseAsyncGeneratorFunction(const Function& closure,
// :async_op = <closure>; (containing the original body)
LocalVariable* async_op_var =
current_block_->scope->LookupVariable(Symbols::AsyncOperation(), false);
- ClosureNode* cn = new(Z) ClosureNode(
- Scanner::kNoSourcePos, closure, NULL, closure_body->scope());
+ ClosureNode* closure_obj = new(Z) ClosureNode(
+ Scanner::kNoSourcePos, closure_func, NULL, closure_body->scope());
StoreLocalNode* store_async_op = new (Z) StoreLocalNode(
Scanner::kNoSourcePos,
async_op_var,
- cn);
+ closure_obj);
current_block_->statements->Add(store_async_op);
// :controller = new _AsyncStarStreamController(body_closure);
ArgumentListNode* arguments = new(Z) ArgumentListNode(Scanner::kNoSourcePos);
- ClosureNode* closure_obj = new(Z) ClosureNode(
- Scanner::kNoSourcePos, closure, NULL, closure_body->scope());
- arguments->Add(closure_obj);
+ arguments->Add(new (Z) LoadLocalNode(Scanner::kNoSourcePos, async_op_var));
ConstructorCallNode* controller_constructor_call =
new(Z) ConstructorCallNode(Scanner::kNoSourcePos,
TypeArguments::ZoneHandle(Z),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698