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

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

Issue 135913003: Optimize getField by caching a closure generated from a specialized function kind. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
« no previous file with comments | « runtime/vm/parser.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 case RawFunction::kGetterFunction: 775 case RawFunction::kGetterFunction:
776 case RawFunction::kSetterFunction: 776 case RawFunction::kSetterFunction:
777 case RawFunction::kConstructor: 777 case RawFunction::kConstructor:
778 // The call to a redirecting factory is redirected. 778 // The call to a redirecting factory is redirected.
779 ASSERT(!func.IsRedirectingFactory()); 779 ASSERT(!func.IsRedirectingFactory());
780 if (!func.IsImplicitConstructor()) { 780 if (!func.IsImplicitConstructor()) {
781 parser.SkipFunctionPreamble(); 781 parser.SkipFunctionPreamble();
782 } 782 }
783 node_sequence = parser.ParseFunc(func, default_parameter_values); 783 node_sequence = parser.ParseFunc(func, default_parameter_values);
784 break; 784 break;
785 case RawFunction::kGetFieldClosure:
786 node_sequence = parser.ParseGetFieldClosure(func);
787 break;
788 case RawFunction::kSetFieldClosure:
789 node_sequence = parser.ParseSetFieldClosure(func);
790 break;
785 case RawFunction::kImplicitGetter: 791 case RawFunction::kImplicitGetter:
786 ASSERT(!func.is_static()); 792 ASSERT(!func.is_static());
787 node_sequence = parser.ParseInstanceGetter(func); 793 node_sequence = parser.ParseInstanceGetter(func);
788 break; 794 break;
789 case RawFunction::kImplicitSetter: 795 case RawFunction::kImplicitSetter:
790 ASSERT(!func.is_static()); 796 ASSERT(!func.is_static());
791 node_sequence = parser.ParseInstanceSetter(func); 797 node_sequence = parser.ParseInstanceSetter(func);
792 break; 798 break;
793 case RawFunction::kImplicitStaticFinalGetter: 799 case RawFunction::kImplicitStaticFinalGetter:
794 node_sequence = parser.ParseStaticFinalGetter(func); 800 node_sequence = parser.ParseStaticFinalGetter(func);
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 1229
1224 EnsureExpressionTemp(); 1230 EnsureExpressionTemp();
1225 StoreInstanceFieldNode* store_field = 1231 StoreInstanceFieldNode* store_field =
1226 new StoreInstanceFieldNode(ident_pos, receiver, field, value); 1232 new StoreInstanceFieldNode(ident_pos, receiver, field, value);
1227 current_block_->statements->Add(store_field); 1233 current_block_->statements->Add(store_field);
1228 current_block_->statements->Add(new ReturnNode(Scanner::kNoSourcePos)); 1234 current_block_->statements->Add(new ReturnNode(Scanner::kNoSourcePos));
1229 return CloseBlock(); 1235 return CloseBlock();
1230 } 1236 }
1231 1237
1232 1238
1239 SequenceNode* Parser::ParseGetFieldClosure(const Function& func) {
1240 TRACE_PARSER("ParseGetFieldClosure");
1241 ParamList params;
1242
1243 const intptr_t ident_pos = func.token_pos();
1244 ASSERT(func.token_pos() == 0);
1245 ASSERT(current_class().raw() == func.Owner());
1246 params.AddReceiver(ReceiverType(current_class()), ident_pos);
1247 params.AddFinalParameter(0, // token pos
1248 &Symbols::PhaseParameter(),
1249 &Type::ZoneHandle(Type::DynamicType()));
1250 ASSERT(func.num_fixed_parameters() == 2);
1251 ASSERT(!func.HasOptionalParameters());
1252
1253 OpenFunctionBlock(func);
1254 AddFormalParamsToScope(&params, current_block_->scope);
1255
1256 LoadLocalNode* victim =
1257 new LoadLocalNode(ident_pos, current_block_->scope->VariableAt(1));
1258
1259 const String& selector = String::ZoneHandle(func.name());
1260 AstNode* get_field = CallGetter(ident_pos, victim, selector);
1261
1262 ReturnNode* return_node = new ReturnNode(ident_pos, get_field);
1263 current_block_->statements->Add(return_node);
1264 return CloseBlock();
1265 }
1266
1267
1268 SequenceNode* Parser::ParseSetFieldClosure(const Function& func) {
1269 TRACE_PARSER("ParseSetFieldClosure");
1270 ParamList params;
1271
1272 const intptr_t ident_pos = func.token_pos();
1273 ASSERT(func.token_pos() == 0);
1274 ASSERT(current_class().raw() == func.Owner());
1275 params.AddReceiver(ReceiverType(current_class()), ident_pos);
1276 params.AddFinalParameter(0, // token pos
1277 &Symbols::PhaseParameter(),
1278 &Type::ZoneHandle(Type::DynamicType()));
1279 params.AddFinalParameter(0, // token pos
1280 &Symbols::Value(),
1281 &Type::ZoneHandle(Type::DynamicType()));
1282 ASSERT(func.num_fixed_parameters() == 3);
1283 ASSERT(!func.HasOptionalParameters());
1284
1285 OpenFunctionBlock(func);
1286 AddFormalParamsToScope(&params, current_block_->scope);
1287
1288 LoadLocalNode* victim =
1289 new LoadLocalNode(ident_pos, current_block_->scope->VariableAt(1));
1290 LoadLocalNode* value =
1291 new LoadLocalNode(ident_pos, current_block_->scope->VariableAt(2));
1292
1293 const String& selector = String::ZoneHandle(func.name());
1294 AstNode* get_field = CallGetter(ident_pos, victim, selector);
1295 AstNode* set_field =
1296 Parser::CreateAssignmentNode(get_field, value, &selector, ident_pos);
1297 ASSERT(set_field->IsInstanceSetterNode());
1298
1299 ReturnNode* return_node = new ReturnNode(ident_pos, set_field);
1300 current_block_->statements->Add(return_node);
1301 return CloseBlock();
1302 }
1303
1304
1233 SequenceNode* Parser::ParseMethodExtractor(const Function& func) { 1305 SequenceNode* Parser::ParseMethodExtractor(const Function& func) {
1234 TRACE_PARSER("ParseMethodExtractor"); 1306 TRACE_PARSER("ParseMethodExtractor");
1235 ParamList params; 1307 ParamList params;
1236 1308
1237 const intptr_t ident_pos = func.token_pos(); 1309 const intptr_t ident_pos = func.token_pos();
1238 ASSERT(func.token_pos() == 0); 1310 ASSERT(func.token_pos() == 0);
1239 ASSERT(current_class().raw() == func.Owner()); 1311 ASSERT(current_class().raw() == func.Owner());
1240 params.AddReceiver(ReceiverType(current_class()), ident_pos); 1312 params.AddReceiver(ReceiverType(current_class()), ident_pos);
1241 ASSERT(func.num_fixed_parameters() == 1); // Receiver. 1313 ASSERT(func.num_fixed_parameters() == 1); // Receiver.
1242 ASSERT(!func.HasOptionalParameters()); 1314 ASSERT(!func.HasOptionalParameters());
(...skipping 9557 matching lines...) Expand 10 before | Expand all | Expand 10 after
10800 void Parser::SkipQualIdent() { 10872 void Parser::SkipQualIdent() {
10801 ASSERT(IsIdentifier()); 10873 ASSERT(IsIdentifier());
10802 ConsumeToken(); 10874 ConsumeToken();
10803 if (CurrentToken() == Token::kPERIOD) { 10875 if (CurrentToken() == Token::kPERIOD) {
10804 ConsumeToken(); // Consume the kPERIOD token. 10876 ConsumeToken(); // Consume the kPERIOD token.
10805 ExpectIdentifier("identifier expected after '.'"); 10877 ExpectIdentifier("identifier expected after '.'");
10806 } 10878 }
10807 } 10879 }
10808 10880
10809 } // namespace dart 10881 } // namespace dart
OLDNEW
« 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