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

Unified 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: address comments 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 side-by-side diff with in-line comments
Download patch
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 79a786af2b014e651eff49a4774195cbf8d05521..1915a4eed76aeda983912a79683ffec34d16900b 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -11853,21 +11853,23 @@ bool Parser::ParsingStaticMember() const {
const AbstractType* Parser::ReceiverType(const Class& cls) {
ASSERT(!cls.IsNull());
- AbstractType& type = AbstractType::ZoneHandle(Z, cls.CanonicalType());
+ Type& type = Type::ZoneHandle(Z, cls.CanonicalType());
if (!type.IsNull()) {
- // This requirement is embedded in 'CanonicalType' function.
- ASSERT((cls.NumTypeArguments() == 0) && !cls.IsSignatureClass());
return &type;
}
-
- const TypeArguments& type_arguments = TypeArguments::Handle(Z,
- (cls.NumTypeParameters() > 0) ?
- cls.type_parameters() : TypeArguments::null());
- type = Type::New(cls, type_arguments, cls.token_pos());
+ if (cls.IsSignatureClass()) {
+ type = cls.SignatureType();
+ } else {
+ const TypeArguments& type_arguments = TypeArguments::Handle(Z,
+ (cls.NumTypeParameters() > 0) ?
+ cls.type_parameters() : TypeArguments::null());
+ type = Type::New(cls, type_arguments, cls.token_pos());
+ }
if (cls.is_type_finalized()) {
type ^= ClassFinalizer::FinalizeType(
cls, type, ClassFinalizer::kCanonicalizeWellFormed);
// Note that the receiver type may now be a malbounded type.
+ cls.SetCanonicalType(type);
}
return &type;
}
« 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