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

Unified Diff: runtime/vm/object.cc

Issue 1556113002: Use the fast canonical type cache for non-generic classes, even if their (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 837e8b76a370c05e6be19cf9c9ac61353268b2a9..70ba1b5224625f07c70e99fa8cfeed91e4519cf6 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -2347,6 +2347,12 @@ intptr_t Class::NumTypeParameters(Thread* thread) const {
ClassFinalizer::ApplyMixinType(*this);
}
if (type_parameters() == TypeArguments::null()) {
+ const intptr_t cid = id();
+ if ((cid == kArrayCid) ||
+ (cid == kImmutableArrayCid) ||
+ (cid == kGrowableObjectArrayCid)) {
+ return 1; // List's type parameter not yet parsed.
srdjan 2016/01/04 20:15:24 Should the comment say: List's type parameter may
regis 2016/01/05 11:24:51 Done.
+ }
return 0;
}
REUSABLE_TYPE_ARGUMENTS_HANDLESCOPE(thread);
@@ -3630,7 +3636,7 @@ void Class::set_canonical_types(const Object& value) const {
RawType* Class::CanonicalType() const {
- if (NumTypeArguments() == 0) {
+ if (!IsGeneric()) {
return reinterpret_cast<RawType*>(raw_ptr()->canonical_types_);
}
Array& types = Array::Handle();
@@ -3644,7 +3650,7 @@ RawType* Class::CanonicalType() const {
void Class::SetCanonicalType(const Type& type) const {
ASSERT(type.IsCanonical());
- if (NumTypeArguments() == 0) {
+ if (!IsGeneric()) {
ASSERT((canonical_types() == Object::null()) ||
(canonical_types() == type.raw())); // Set during own finalization.
set_canonical_types(type);
@@ -14953,7 +14959,7 @@ RawType* Instance::GetType() const {
}
const Class& cls = Class::Handle(clazz());
Type& type = Type::Handle();
- if (cls.NumTypeArguments() == 0) {
+ if (!cls.IsGeneric()) {
type = cls.CanonicalType();
}
if (type.IsNull()) {
@@ -15871,7 +15877,7 @@ RawType* Type::Function() {
RawType* Type::NewNonParameterizedType(const Class& type_class) {
- ASSERT(type_class.NumTypeArguments() == 0);
+ ASSERT(!type_class.IsGeneric()); // Super class may have type arguments.
srdjan 2016/01/04 20:15:24 I do not understand this comment.
regis 2016/01/05 11:24:51 I reverted this change. A type may be non-paramete
Type& type = Type::Handle(type_class.CanonicalType());
if (type.IsNull()) {
const TypeArguments& no_type_arguments = TypeArguments::Handle();
@@ -16214,13 +16220,20 @@ RawAbstractType* Type::Canonicalize(TrailPtr trail) const {
return Object::dynamic_type().raw();
}
// Fast canonical lookup/registry for simple types.
- if (cls.NumTypeArguments() == 0) {
+ if (!cls.IsGeneric()) {
type = cls.CanonicalType();
if (type.IsNull()) {
ASSERT(!cls.raw()->IsVMHeapObject() || (isolate == Dart::vm_isolate()));
- cls.set_canonical_types(*this);
- SetCanonical();
- return this->raw();
+ // Canonicalize the type arguments of the supertype, if any.
+ TypeArguments& type_args = TypeArguments::Handle(zone, arguments());
+ type_args = type_args.Canonicalize(trail);
+ set_arguments(type_args);
+ type = cls.CanonicalType(); // May be set while canonicalizing type args.
+ if (type.IsNull()) {
+ cls.set_canonical_types(*this);
+ SetCanonical();
+ return this->raw();
+ }
}
ASSERT(this->Equals(type));
ASSERT(type.IsCanonical());
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698