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

Unified Diff: runtime/vm/parser.cc

Issue 11642003: Create and cache method extraction stub in the ICData. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: lazyly inject extractors as getters into class Created 7 years, 11 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
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index aacdda0b953f57214f7e030b9cbe1fc9a98f3a52..e800c9a3426b9907076fc42f775f3e4d17569210 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -756,6 +756,9 @@ void Parser::ParseFunction(ParsedFunction* parsed_function) {
case RawFunction::kConstImplicitGetter:
node_sequence = parser.ParseStaticConstGetter(func);
break;
+ case RawFunction::kMethodExtractor:
+ node_sequence = parser.ParseMethodExtractor(func);
+ break;
default:
UNREACHABLE();
}
@@ -984,6 +987,37 @@ SequenceNode* Parser::ParseInstanceSetter(const Function& func) {
}
+SequenceNode* Parser::ParseMethodExtractor(const Function& func) {
+ TRACE_PARSER("ParseMethodExtractor");
+ ParamList params;
+
+ const intptr_t ident_pos = func.token_pos();
+ ASSERT(func.token_pos() == 0);
+ ASSERT(current_class().raw() == func.Owner());
+ params.AddReceiver(ReceiverType(ident_pos));
+ ASSERT(func.num_fixed_parameters() == 1); // Receiver.
+ ASSERT(!func.HasOptionalParameters());
+
+ // Build local scope for function and populate with the formal parameters.
+ OpenFunctionBlock(func);
+ AddFormalParamsToScope(&params, current_block_->scope);
+
+ // Receiver is local 0.
+ LocalVariable* receiver = current_block_->scope->VariableAt(0);
+ LoadLocalNode* load_receiver = new LoadLocalNode(ident_pos, receiver);
+
+ ClosureNode* closure = new ClosureNode(
+ ident_pos,
+ Function::ZoneHandle(func.extracted_method_closure()),
+ load_receiver,
+ NULL);
+
+ ReturnNode* return_node = new ReturnNode(ident_pos, closure);
+ 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