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

Unified Diff: runtime/vm/object.cc

Issue 1947753002: More efficient identification of dynamic and void types. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 6f48c9202ac687e858dd3d7702194f9cb056012a..f466a1007ce04a82191c854bf66b399735f39d3e 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -15967,6 +15967,19 @@ RawString* AbstractType::ClassName() const {
}
+bool AbstractType::IsDynamicType() const {
+ if (IsCanonical()) {
+ return raw() == Object::dynamic_type().raw();
+ }
+ return HasResolvedTypeClass() && (type_class() == Object::dynamic_class());
+}
+
+
+bool AbstractType::IsVoidType() const {
+ return raw() == Object::void_type().raw();
+}
+
+
bool AbstractType::IsNullType() const {
return !IsFunctionType() &&
HasResolvedTypeClass() &&
@@ -16823,7 +16836,15 @@ RawAbstractType* Type::Canonicalize(TrailPtr trail) const {
Isolate* isolate = thread->isolate();
AbstractType& type = Type::Handle(zone);
const Class& cls = Class::Handle(zone, type_class());
- if (cls.raw() == Object::dynamic_class() && (isolate != Dart::vm_isolate())) {
+ // Since void is a keyword, we never have to canonicalize the void type after
+ // it is canonicalized once by the vm isolate. The parser does the mapping.
+ ASSERT((cls.raw() != Object::void_class()) ||
+ (isolate == Dart::vm_isolate()));
+ // Since dynamic is not a keyword, the parser builds a type that requires
+ // canonicalization.
+ if ((cls.raw() == Object::dynamic_class()) &&
+ (isolate != Dart::vm_isolate())) {
+ ASSERT(Object::dynamic_type().IsCanonical());
return Object::dynamic_type().raw();
}
// Fast canonical lookup/registry for simple types.
« 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