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

Side by Side Diff: runtime/vm/parser.cc

Issue 17315008: Optimizing noSuchMethod invocation with no arguments. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 case RawFunction::kImplicitSetter: 795 case RawFunction::kImplicitSetter:
796 ASSERT(!func.is_static()); 796 ASSERT(!func.is_static());
797 node_sequence = parser.ParseInstanceSetter(func); 797 node_sequence = parser.ParseInstanceSetter(func);
798 break; 798 break;
799 case RawFunction::kConstImplicitGetter: 799 case RawFunction::kConstImplicitGetter:
800 node_sequence = parser.ParseStaticConstGetter(func); 800 node_sequence = parser.ParseStaticConstGetter(func);
801 break; 801 break;
802 case RawFunction::kMethodExtractor: 802 case RawFunction::kMethodExtractor:
803 node_sequence = parser.ParseMethodExtractor(func); 803 node_sequence = parser.ParseMethodExtractor(func);
804 break; 804 break;
805 case RawFunction::kNoSuchMethodDispatcher:
806 node_sequence = parser.ParseNoSuchMethodDispatcher(func);
807 break;
805 default: 808 default:
806 UNREACHABLE(); 809 UNREACHABLE();
807 } 810 }
808 811
809 if (!HasReturnNode(node_sequence)) { 812 if (!HasReturnNode(node_sequence)) {
810 // Add implicit return node. 813 // Add implicit return node.
811 node_sequence->Add(new ReturnNode(func.end_token_pos())); 814 node_sequence->Add(new ReturnNode(func.end_token_pos()));
812 } 815 }
813 if (parsed_function->has_expression_temp_var()) { 816 if (parsed_function->has_expression_temp_var()) {
814 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var()); 817 node_sequence->scope()->AddVariable(parsed_function->expression_temp_var());
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 Function::ZoneHandle(func.extracted_method_closure()), 1130 Function::ZoneHandle(func.extracted_method_closure()),
1128 load_receiver, 1131 load_receiver,
1129 NULL); 1132 NULL);
1130 1133
1131 ReturnNode* return_node = new ReturnNode(ident_pos, closure); 1134 ReturnNode* return_node = new ReturnNode(ident_pos, closure);
1132 current_block_->statements->Add(return_node); 1135 current_block_->statements->Add(return_node);
1133 return CloseBlock(); 1136 return CloseBlock();
1134 } 1137 }
1135 1138
1136 1139
1140 SequenceNode* Parser::ParseNoSuchMethodDispatcher(const Function& func) {
1141 TRACE_PARSER("ParseNoSuchMethodDispatcher");
1142 ParamList params;
1143
srdjan 2013/06/20 16:34:17 ASSERT that func kind is RawFunction::kNoSuchMetho
Florian Schneider 2013/06/21 06:46:26 Done.
1144 intptr_t token_pos = func.token_pos();
1145 ASSERT(func.token_pos() == 0);
1146 ASSERT(current_class().raw() == func.Owner());
1147 params.AddReceiver(ReceiverType(token_pos));
1148 ASSERT(func.num_fixed_parameters() == 1); // Receiver.
1149 ASSERT(!func.HasOptionalParameters());
1150
1151 // Build local scope for function and populate with the formal parameters.
1152 OpenFunctionBlock(func);
1153 LocalScope* scope = current_block_->scope;
1154 AddFormalParamsToScope(&params, scope);
1155
1156 // Receiver is local 0.
1157 LocalVariable* receiver = scope->VariableAt(0);
1158 LoadLocalNode* load_receiver = new LoadLocalNode(token_pos, receiver);
1159
1160 ArgumentListNode* func_args = new ArgumentListNode(token_pos);
1161 func_args->Add(load_receiver);
1162 const String& func_name = String::ZoneHandle(func.name());
1163 ArgumentListNode* arguments = BuildNoSuchMethodArguments(token_pos,
1164 func_name,
1165 *func_args);
1166 const Function& no_such_method = Function::ZoneHandle(
1167 Resolver::ResolveDynamicAnyArgs(Class::Handle(func.Owner()),
1168 Symbols::NoSuchMethod()));
1169 StaticCallNode* call =
1170 new StaticCallNode(token_pos, no_such_method, arguments);
1171
1172
1173 ReturnNode* return_node = new ReturnNode(token_pos, call);
1174 current_block_->statements->Add(return_node);
1175 return CloseBlock();
1176 }
1177
1178
1137 void Parser::SkipBlock() { 1179 void Parser::SkipBlock() {
1138 ASSERT(CurrentToken() == Token::kLBRACE); 1180 ASSERT(CurrentToken() == Token::kLBRACE);
1139 GrowableArray<Token::Kind> token_stack(8); 1181 GrowableArray<Token::Kind> token_stack(8);
1140 const intptr_t block_start_pos = TokenPos(); 1182 const intptr_t block_start_pos = TokenPos();
1141 bool is_match = true; 1183 bool is_match = true;
1142 bool unexpected_token_found = false; 1184 bool unexpected_token_found = false;
1143 Token::Kind token; 1185 Token::Kind token;
1144 intptr_t token_pos; 1186 intptr_t token_pos;
1145 do { 1187 do {
1146 token = CurrentToken(); 1188 token = CurrentToken();
(...skipping 8958 matching lines...) Expand 10 before | Expand all | Expand 10 after
10105 void Parser::SkipQualIdent() { 10147 void Parser::SkipQualIdent() {
10106 ASSERT(IsIdentifier()); 10148 ASSERT(IsIdentifier());
10107 ConsumeToken(); 10149 ConsumeToken();
10108 if (CurrentToken() == Token::kPERIOD) { 10150 if (CurrentToken() == Token::kPERIOD) {
10109 ConsumeToken(); // Consume the kPERIOD token. 10151 ConsumeToken(); // Consume the kPERIOD token.
10110 ExpectIdentifier("identifier expected after '.'"); 10152 ExpectIdentifier("identifier expected after '.'");
10111 } 10153 }
10112 } 10154 }
10113 10155
10114 } // namespace dart 10156 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698