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

Unified Diff: runtime/vm/parser.cc

Issue 17571010: Reland: Optimizing noSuchMethod invocation with no arguments. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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 | « runtime/vm/parser.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 24285)
+++ runtime/vm/parser.cc (working copy)
@@ -802,6 +802,9 @@
case RawFunction::kMethodExtractor:
node_sequence = parser.ParseMethodExtractor(func);
break;
+ case RawFunction::kNoSuchMethodDispatcher:
+ node_sequence = parser.ParseNoSuchMethodDispatcher(func);
+ break;
default:
UNREACHABLE();
}
@@ -1134,6 +1137,46 @@
}
+SequenceNode* Parser::ParseNoSuchMethodDispatcher(const Function& func) {
+ TRACE_PARSER("ParseNoSuchMethodDispatcher");
+ ParamList params;
+
+ ASSERT(func.IsNoSuchMethodDispatcher());
+ intptr_t token_pos = func.token_pos();
+ ASSERT(func.token_pos() == 0);
+ ASSERT(current_class().raw() == func.Owner());
+ params.AddReceiver(ReceiverType(token_pos));
+ ASSERT(func.num_fixed_parameters() == 1); // Receiver.
+ ASSERT(!func.HasOptionalParameters());
+
+ // Build local scope for function and populate with the formal parameters.
+ OpenFunctionBlock(func);
+ LocalScope* scope = current_block_->scope;
+ AddFormalParamsToScope(&params, scope);
+
+ // Receiver is local 0.
+ LocalVariable* receiver = scope->VariableAt(0);
+ LoadLocalNode* load_receiver = new LoadLocalNode(token_pos, receiver);
+
+ ArgumentListNode* func_args = new ArgumentListNode(token_pos);
+ func_args->Add(load_receiver);
+ const String& func_name = String::ZoneHandle(func.name());
+ ArgumentListNode* arguments = BuildNoSuchMethodArguments(token_pos,
+ func_name,
+ *func_args);
+ const Function& no_such_method = Function::ZoneHandle(
+ Resolver::ResolveDynamicAnyArgs(Class::Handle(func.Owner()),
+ Symbols::NoSuchMethod()));
+ StaticCallNode* call =
+ new StaticCallNode(token_pos, no_such_method, arguments);
+
+
+ ReturnNode* return_node = new ReturnNode(token_pos, call);
+ current_block_->statements->Add(return_node);
+ return CloseBlock();
+}
+
+
void Parser::SkipBlock() {
ASSERT(CurrentToken() == Token::kLBRACE);
GrowableArray<Token::Kind> token_stack(8);
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698