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

Side by Side 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: remove hand written assembly stub 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 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 "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 ASSERT(!func.is_static()); 749 ASSERT(!func.is_static());
750 node_sequence = parser.ParseInstanceGetter(func); 750 node_sequence = parser.ParseInstanceGetter(func);
751 break; 751 break;
752 case RawFunction::kImplicitSetter: 752 case RawFunction::kImplicitSetter:
753 ASSERT(!func.is_static()); 753 ASSERT(!func.is_static());
754 node_sequence = parser.ParseInstanceSetter(func); 754 node_sequence = parser.ParseInstanceSetter(func);
755 break; 755 break;
756 case RawFunction::kConstImplicitGetter: 756 case RawFunction::kConstImplicitGetter:
757 node_sequence = parser.ParseStaticConstGetter(func); 757 node_sequence = parser.ParseStaticConstGetter(func);
758 break; 758 break;
759 case RawFunction::kMethodExtractor:
760 node_sequence = parser.ParseMethodExtractor(func);
761 break;
759 default: 762 default:
760 UNREACHABLE(); 763 UNREACHABLE();
761 } 764 }
762 765
763 if (!HasReturnNode(node_sequence)) { 766 if (!HasReturnNode(node_sequence)) {
764 // Add implicit return node. 767 // Add implicit return node.
765 node_sequence->Add(new ReturnNode(func.end_token_pos())); 768 node_sequence->Add(new ReturnNode(func.end_token_pos()));
766 } 769 }
767 if (parser.expression_temp_ != NULL) { 770 if (parser.expression_temp_ != NULL) {
768 parsed_function->set_expression_temp_var(parser.expression_temp_); 771 parsed_function->set_expression_temp_var(parser.expression_temp_);
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 980
978 StoreInstanceFieldNode* store_field = 981 StoreInstanceFieldNode* store_field =
979 new StoreInstanceFieldNode(ident_pos, receiver, field, value); 982 new StoreInstanceFieldNode(ident_pos, receiver, field, value);
980 983
981 current_block_->statements->Add(store_field); 984 current_block_->statements->Add(store_field);
982 current_block_->statements->Add(new ReturnNode(ident_pos)); 985 current_block_->statements->Add(new ReturnNode(ident_pos));
983 return CloseBlock(); 986 return CloseBlock();
984 } 987 }
985 988
986 989
990 SequenceNode* Parser::ParseMethodExtractor(const Function& func) {
991 TRACE_PARSER("ParseMethodExtractor");
992 ParamList params;
993
994 // func.token_pos() points to the name of the field.
Ivan Posva 2013/01/17 08:03:20 I don't think this comment is correct. The token_p
Vyacheslav Egorov (Google) 2013/01/17 12:46:38 Indeed it is not. token_pos is 0 actually.
995 intptr_t ident_pos = func.token_pos();
996 ASSERT(current_class().raw() == func.Owner());
997 params.AddReceiver(ReceiverType(ident_pos));
998 ASSERT(func.num_fixed_parameters() == 1); // receiver.
999 ASSERT(!func.HasOptionalParameters());
1000
1001 // Build local scope for function and populate with the formal parameters.
1002 OpenFunctionBlock(func);
1003 AddFormalParamsToScope(&params, current_block_->scope);
1004
1005 // Receiver is local 0.
1006 LocalVariable* receiver = current_block_->scope->VariableAt(0);
1007 LoadLocalNode* load_receiver = new LoadLocalNode(ident_pos, receiver);
1008
1009 ClosureNode* closure = new ClosureNode(
1010 ident_pos,
1011 Function::ZoneHandle(func.extracted_method_closure()),
1012 load_receiver,
1013 NULL);
1014
1015 ReturnNode* return_node = new ReturnNode(ident_pos, closure);
1016 current_block_->statements->Add(return_node);
1017 return CloseBlock();
1018 }
1019
1020
987 void Parser::SkipBlock() { 1021 void Parser::SkipBlock() {
988 ASSERT(CurrentToken() == Token::kLBRACE); 1022 ASSERT(CurrentToken() == Token::kLBRACE);
989 GrowableArray<Token::Kind> token_stack(8); 1023 GrowableArray<Token::Kind> token_stack(8);
990 const intptr_t block_start_pos = TokenPos(); 1024 const intptr_t block_start_pos = TokenPos();
991 bool is_match = true; 1025 bool is_match = true;
992 bool unexpected_token_found = false; 1026 bool unexpected_token_found = false;
993 Token::Kind token; 1027 Token::Kind token;
994 intptr_t token_pos; 1028 intptr_t token_pos;
995 do { 1029 do {
996 token = CurrentToken(); 1030 token = CurrentToken();
(...skipping 8709 matching lines...) Expand 10 before | Expand all | Expand 10 after
9706 void Parser::SkipQualIdent() { 9740 void Parser::SkipQualIdent() {
9707 ASSERT(IsIdentifier()); 9741 ASSERT(IsIdentifier());
9708 ConsumeToken(); 9742 ConsumeToken();
9709 if (CurrentToken() == Token::kPERIOD) { 9743 if (CurrentToken() == Token::kPERIOD) {
9710 ConsumeToken(); // Consume the kPERIOD token. 9744 ConsumeToken(); // Consume the kPERIOD token.
9711 ExpectIdentifier("identifier expected after '.'"); 9745 ExpectIdentifier("identifier expected after '.'");
9712 } 9746 }
9713 } 9747 }
9714 9748
9715 } // namespace dart 9749 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698