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

Unified Diff: runtime/vm/object.h

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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/object.h
diff --git a/runtime/vm/object.h b/runtime/vm/object.h
index bdfab97cd5745c957ab6ab8ed107a36b363f1301..e39c855b2cc64f33c1406ad39643e55d644f9ffa 100644
--- a/runtime/vm/object.h
+++ b/runtime/vm/object.h
@@ -1034,12 +1034,12 @@ class Class : public Object {
return OFFSET_OF(RawClass, type_arguments_field_offset_in_words_);
}
- RawType* CanonicalType() const {
- if ((NumTypeArguments() == 0) && !IsSignatureClass()) {
- return reinterpret_cast<RawType*>(raw_ptr()->canonical_types_);
- }
- return reinterpret_cast<RawType*>(Object::null());
- }
+ // Returns the canonical type of this class, i.e. the canonical type whose
+ // type class is this class and whose type arguments are the uninstantiated
+ // type parameters declared by this class if it is generic, e.g. Map<K, V>.
srdjan 2015/08/21 05:02:21 Add comment: returns Type::null() if ...
regis 2015/08/21 15:38:22 Done.
+ RawType* CanonicalType() const;
+ void SetCanonicalType(const Type& type) const;
+
static intptr_t canonical_types_offset() {
return OFFSET_OF(RawClass, canonical_types_);
}
@@ -1193,7 +1193,6 @@ class Class : public Object {
void InsertCanonicalConstant(intptr_t index, const Instance& constant) const;
- intptr_t NumCanonicalTypes() const;
intptr_t FindCanonicalTypeIndex(const Type& needle) const;
RawType* CanonicalTypeFromIndex(intptr_t idx) const;
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698