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

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

Issue 12529008: Collect type feedback for fields. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 OpenFunctionBlock(func); 982 OpenFunctionBlock(func);
983 AddFormalParamsToScope(&params, current_block_->scope); 983 AddFormalParamsToScope(&params, current_block_->scope);
984 984
985 LoadLocalNode* receiver = 985 LoadLocalNode* receiver =
986 new LoadLocalNode(ident_pos, current_block_->scope->VariableAt(0)); 986 new LoadLocalNode(ident_pos, current_block_->scope->VariableAt(0));
987 LoadLocalNode* value = 987 LoadLocalNode* value =
988 new LoadLocalNode(ident_pos, current_block_->scope->VariableAt(1)); 988 new LoadLocalNode(ident_pos, current_block_->scope->VariableAt(1));
989 989
990 StoreInstanceFieldNode* store_field = 990 StoreInstanceFieldNode* store_field =
991 new StoreInstanceFieldNode(ident_pos, receiver, field, value); 991 new StoreInstanceFieldNode(ident_pos, receiver, field, value);
992
993 current_block_->statements->Add(store_field); 992 current_block_->statements->Add(store_field);
994 current_block_->statements->Add(new ReturnNode(ident_pos)); 993 current_block_->statements->Add(new ReturnNode(ident_pos));
995 return CloseBlock(); 994 return CloseBlock();
996 } 995 }
997 996
998 997
999 SequenceNode* Parser::ParseMethodExtractor(const Function& func) { 998 SequenceNode* Parser::ParseMethodExtractor(const Function& func) {
1000 TRACE_PARSER("ParseMethodExtractor"); 999 TRACE_PARSER("ParseMethodExtractor");
1001 ParamList params; 1000 ParamList params;
1002 1001
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1794 return new StoreInstanceFieldNode(field_pos, instance, field, init_expr); 1793 return new StoreInstanceFieldNode(field_pos, instance, field, init_expr);
1795 } 1794 }
1796 1795
1797 1796
1798 void Parser::CheckConstFieldsInitialized(const Class& cls) { 1797 void Parser::CheckConstFieldsInitialized(const Class& cls) {
1799 const Array& fields = Array::Handle(cls.fields()); 1798 const Array& fields = Array::Handle(cls.fields());
1800 Field& field = Field::Handle(); 1799 Field& field = Field::Handle();
1801 SequenceNode* initializers = current_block_->statements; 1800 SequenceNode* initializers = current_block_->statements;
1802 for (int field_num = 0; field_num < fields.Length(); field_num++) { 1801 for (int field_num = 0; field_num < fields.Length(); field_num++) {
1803 field ^= fields.At(field_num); 1802 field ^= fields.At(field_num);
1804 if (field.is_static() || !field.is_final()) { 1803 if (field.is_static()) {
1805 continue; 1804 continue;
1806 } 1805 }
1806
1807 bool found = false; 1807 bool found = false;
1808 for (int i = 0; i < initializers->length(); i++) { 1808 for (int i = 0; i < initializers->length(); i++) {
1809 found = false; 1809 found = false;
1810 if (initializers->NodeAt(i)->IsStoreInstanceFieldNode()) { 1810 if (initializers->NodeAt(i)->IsStoreInstanceFieldNode()) {
1811 StoreInstanceFieldNode* initializer = 1811 StoreInstanceFieldNode* initializer =
1812 initializers->NodeAt(i)->AsStoreInstanceFieldNode(); 1812 initializers->NodeAt(i)->AsStoreInstanceFieldNode();
1813 if (initializer->field().raw() == field.raw()) { 1813 if (initializer->field().raw() == field.raw()) {
1814 found = true; 1814 found = true;
1815 break; 1815 break;
1816 } 1816 }
1817 } 1817 }
1818 } 1818 }
1819 if (!found) { 1819
1820 if (found) continue;
1821
1822 if (field.is_final()) {
1820 ErrorMsg("final field '%s' not initialized", 1823 ErrorMsg("final field '%s' not initialized",
1821 String::Handle(field.name()).ToCString()); 1824 String::Handle(field.name()).ToCString());
1825 } else {
1826 field.UpdateCid(kNullCid);
1822 } 1827 }
1823 } 1828 }
1824 } 1829 }
1825 1830
1826 1831
1827 void Parser::ParseInitializedInstanceFields(const Class& cls, 1832 void Parser::ParseInitializedInstanceFields(const Class& cls,
1828 LocalVariable* receiver, 1833 LocalVariable* receiver,
1829 GrowableArray<Field*>* initialized_fields) { 1834 GrowableArray<Field*>* initialized_fields) {
1830 TRACE_PARSER("ParseInitializedInstanceFields"); 1835 TRACE_PARSER("ParseInitializedInstanceFields");
1831 const Array& fields = Array::Handle(cls.fields()); 1836 const Array& fields = Array::Handle(cls.fields());
(...skipping 8237 matching lines...) Expand 10 before | Expand all | Expand 10 after
10069 void Parser::SkipQualIdent() { 10074 void Parser::SkipQualIdent() {
10070 ASSERT(IsIdentifier()); 10075 ASSERT(IsIdentifier());
10071 ConsumeToken(); 10076 ConsumeToken();
10072 if (CurrentToken() == Token::kPERIOD) { 10077 if (CurrentToken() == Token::kPERIOD) {
10073 ConsumeToken(); // Consume the kPERIOD token. 10078 ConsumeToken(); // Consume the kPERIOD token.
10074 ExpectIdentifier("identifier expected after '.'"); 10079 ExpectIdentifier("identifier expected after '.'");
10075 } 10080 }
10076 } 10081 }
10077 10082
10078 } // namespace dart 10083 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698