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

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

Issue 1309613002: Avoid numerous type allocations by caching the canonical type of a class, which (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | no next file » | 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/ast_transformer.h" 9 #include "vm/ast_transformer.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 11835 matching lines...) Expand 10 before | Expand all | Expand 10 after
11846 current_member_->has_static && !current_member_->has_factory; 11846 current_member_->has_static && !current_member_->has_factory;
11847 } 11847 }
11848 ASSERT(!current_function().IsNull()); 11848 ASSERT(!current_function().IsNull());
11849 return 11849 return
11850 current_function().is_static() && !current_function().IsInFactoryScope(); 11850 current_function().is_static() && !current_function().IsInFactoryScope();
11851 } 11851 }
11852 11852
11853 11853
11854 const AbstractType* Parser::ReceiverType(const Class& cls) { 11854 const AbstractType* Parser::ReceiverType(const Class& cls) {
11855 ASSERT(!cls.IsNull()); 11855 ASSERT(!cls.IsNull());
11856 AbstractType& type = AbstractType::ZoneHandle(Z, cls.CanonicalType()); 11856 Type& type = Type::ZoneHandle(Z, cls.CanonicalType());
11857 if (!type.IsNull()) { 11857 if (!type.IsNull()) {
11858 // This requirement is embedded in 'CanonicalType' function.
11859 ASSERT((cls.NumTypeArguments() == 0) && !cls.IsSignatureClass());
11860 return &type; 11858 return &type;
11861 } 11859 }
11862 11860 if (cls.IsSignatureClass()) {
11863 const TypeArguments& type_arguments = TypeArguments::Handle(Z, 11861 type = cls.SignatureType();
11864 (cls.NumTypeParameters() > 0) ? 11862 } else {
11865 cls.type_parameters() : TypeArguments::null()); 11863 const TypeArguments& type_arguments = TypeArguments::Handle(Z,
11866 type = Type::New(cls, type_arguments, cls.token_pos()); 11864 (cls.NumTypeParameters() > 0) ?
11865 cls.type_parameters() : TypeArguments::null());
11866 type = Type::New(cls, type_arguments, cls.token_pos());
11867 }
11867 if (cls.is_type_finalized()) { 11868 if (cls.is_type_finalized()) {
11868 type ^= ClassFinalizer::FinalizeType( 11869 type ^= ClassFinalizer::FinalizeType(
11869 cls, type, ClassFinalizer::kCanonicalizeWellFormed); 11870 cls, type, ClassFinalizer::kCanonicalizeWellFormed);
11870 // Note that the receiver type may now be a malbounded type. 11871 // Note that the receiver type may now be a malbounded type.
11872 cls.SetCanonicalType(type);
11871 } 11873 }
11872 return &type; 11874 return &type;
11873 } 11875 }
11874 11876
11875 11877
11876 bool Parser::IsInstantiatorRequired() const { 11878 bool Parser::IsInstantiatorRequired() const {
11877 ASSERT(!current_function().IsNull()); 11879 ASSERT(!current_function().IsNull());
11878 if (current_function().is_static() && 11880 if (current_function().is_static() &&
11879 !current_function().IsInFactoryScope()) { 11881 !current_function().IsInFactoryScope()) {
11880 return false; 11882 return false;
(...skipping 2304 matching lines...) Expand 10 before | Expand all | Expand 10 after
14185 void Parser::SkipQualIdent() { 14187 void Parser::SkipQualIdent() {
14186 ASSERT(IsIdentifier()); 14188 ASSERT(IsIdentifier());
14187 ConsumeToken(); 14189 ConsumeToken();
14188 if (CurrentToken() == Token::kPERIOD) { 14190 if (CurrentToken() == Token::kPERIOD) {
14189 ConsumeToken(); // Consume the kPERIOD token. 14191 ConsumeToken(); // Consume the kPERIOD token.
14190 ExpectIdentifier("identifier expected after '.'"); 14192 ExpectIdentifier("identifier expected after '.'");
14191 } 14193 }
14192 } 14194 }
14193 14195
14194 } // namespace dart 14196 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698