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

Unified Diff: runtime/vm/parser.cc

Issue 2478703003: Run async immediately in dart2js and VM. (Closed)
Patch Set: Also run sync in VM. Created 3 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index b18c4fda87d1d1f08306b059046bd05ce0faa5a7..57ebcc17659592d501120a83d037ef9fc588361d 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -7514,22 +7514,21 @@ SequenceNode* Parser::CloseAsyncFunction(const Function& closure,
Symbols::AsyncStackTraceVar(), false);
ASSERT((existing_var != NULL) && existing_var->is_captured());
- // Create and return a new future that executes a closure with the current
- // body.
+ // Create and return a new _AsyncAwaitCompleter that executes a closure with
+ // the current body.
// No need to capture parameters or other variables, since they have already
// been captured in the corresponding scope as the body has been parsed within
// a nested block (contained in the async function's block).
- const Class& future = Class::ZoneHandle(Z, I->object_store()->future_class());
- ASSERT(!future.IsNull());
- const Function& constructor = Function::ZoneHandle(
- Z, future.LookupFunction(Symbols::FutureMicrotask()));
- ASSERT(!constructor.IsNull());
- const Class& completer =
- Class::ZoneHandle(Z, I->object_store()->completer_class());
- ASSERT(!completer.IsNull());
- const Function& completer_constructor = Function::ZoneHandle(
- Z, completer.LookupFunction(Symbols::CompleterSyncConstructor()));
+
+ const Library& async_lib = Library::Handle(Library::AsyncLibrary());
+
+ const Class& completer_class = Class::Handle(
+ Z, async_lib.LookupClassAllowPrivate(Symbols::_AsyncAwaitCompleter()));
+ ASSERT(!completer_class.IsNull());
+ const Function& completer_constructor =
+ Function::ZoneHandle(Z, completer_class.LookupConstructorAllowPrivate(
+ Symbols::_AsyncAwaitCompleterConstructor()));
ASSERT(!completer_constructor.IsNull());
LocalVariable* async_completer =
@@ -7564,8 +7563,6 @@ SequenceNode* Parser::CloseAsyncFunction(const Function& closure,
new (Z) StoreLocalNode(token_pos, async_op_var, cn);
current_block_->statements->Add(store_async_op);
- const Library& async_lib = Library::Handle(Library::AsyncLibrary());
-
if (FLAG_causal_async_stacks) {
// Add to AST:
// :async_stack_trace = _asyncStackTraceHelper();
@@ -7627,12 +7624,13 @@ SequenceNode* Parser::CloseAsyncFunction(const Function& closure,
current_block_->statements->Add(store_async_catch_error_callback);
// Add to AST:
- // new Future.microtask(:async_op);
+ // :async_completer.start(:async_op);
ArgumentListNode* arguments = new (Z) ArgumentListNode(token_pos);
arguments->Add(new (Z) LoadLocalNode(token_pos, async_op_var));
- ConstructorCallNode* future_node = new (Z) ConstructorCallNode(
- token_pos, TypeArguments::ZoneHandle(Z), constructor, arguments);
- current_block_->statements->Add(future_node);
+ InstanceCallNode* start_call = new (Z) InstanceCallNode(
+ token_pos, new (Z) LoadLocalNode(token_pos, async_completer),
+ Symbols::_AsyncAwaitStart(), arguments);
+ current_block_->statements->Add(start_call);
// Add to AST:
// return :async_completer.future;

Powered by Google App Engine
This is Rietveld 408576698