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

Side by Side 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, 7 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
« no previous file with comments | « runtime/vm/object.h ('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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 15949 matching lines...) Expand 10 before | Expand all | Expand 10 after
15960 RawString* AbstractType::ClassName() const { 15960 RawString* AbstractType::ClassName() const {
15961 ASSERT(!IsFunctionType()); 15961 ASSERT(!IsFunctionType());
15962 if (HasResolvedTypeClass()) { 15962 if (HasResolvedTypeClass()) {
15963 return Class::Handle(type_class()).Name(); 15963 return Class::Handle(type_class()).Name();
15964 } else { 15964 } else {
15965 return UnresolvedClass::Handle(unresolved_class()).Name(); 15965 return UnresolvedClass::Handle(unresolved_class()).Name();
15966 } 15966 }
15967 } 15967 }
15968 15968
15969 15969
15970 bool AbstractType::IsDynamicType() const {
15971 if (IsCanonical()) {
15972 return raw() == Object::dynamic_type().raw();
15973 }
15974 return HasResolvedTypeClass() && (type_class() == Object::dynamic_class());
15975 }
15976
15977
15978 bool AbstractType::IsVoidType() const {
15979 return raw() == Object::void_type().raw();
15980 }
15981
15982
15970 bool AbstractType::IsNullType() const { 15983 bool AbstractType::IsNullType() const {
15971 return !IsFunctionType() && 15984 return !IsFunctionType() &&
15972 HasResolvedTypeClass() && 15985 HasResolvedTypeClass() &&
15973 (type_class() == Isolate::Current()->object_store()->null_class()); 15986 (type_class() == Isolate::Current()->object_store()->null_class());
15974 } 15987 }
15975 15988
15976 15989
15977 bool AbstractType::IsBoolType() const { 15990 bool AbstractType::IsBoolType() const {
15978 return !IsFunctionType() && 15991 return !IsFunctionType() &&
15979 HasResolvedTypeClass() && 15992 HasResolvedTypeClass() &&
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after
16816 ASSERT(IsFinalized()); 16829 ASSERT(IsFinalized());
16817 if (IsCanonical() || IsMalformed()) { 16830 if (IsCanonical() || IsMalformed()) {
16818 ASSERT(IsMalformed() || TypeArguments::Handle(arguments()).IsOld()); 16831 ASSERT(IsMalformed() || TypeArguments::Handle(arguments()).IsOld());
16819 return this->raw(); 16832 return this->raw();
16820 } 16833 }
16821 Thread* thread = Thread::Current(); 16834 Thread* thread = Thread::Current();
16822 Zone* zone = thread->zone(); 16835 Zone* zone = thread->zone();
16823 Isolate* isolate = thread->isolate(); 16836 Isolate* isolate = thread->isolate();
16824 AbstractType& type = Type::Handle(zone); 16837 AbstractType& type = Type::Handle(zone);
16825 const Class& cls = Class::Handle(zone, type_class()); 16838 const Class& cls = Class::Handle(zone, type_class());
16826 if (cls.raw() == Object::dynamic_class() && (isolate != Dart::vm_isolate())) { 16839 // Since void is a keyword, we never have to canonicalize the void type after
16840 // it is canonicalized once by the vm isolate. The parser does the mapping.
16841 ASSERT((cls.raw() != Object::void_class()) ||
16842 (isolate == Dart::vm_isolate()));
16843 // Since dynamic is not a keyword, the parser builds a type that requires
16844 // canonicalization.
16845 if ((cls.raw() == Object::dynamic_class()) &&
16846 (isolate != Dart::vm_isolate())) {
16847 ASSERT(Object::dynamic_type().IsCanonical());
16827 return Object::dynamic_type().raw(); 16848 return Object::dynamic_type().raw();
16828 } 16849 }
16829 // Fast canonical lookup/registry for simple types. 16850 // Fast canonical lookup/registry for simple types.
16830 if (!cls.IsGeneric() && !cls.IsClosureClass() && !cls.IsTypedefClass()) { 16851 if (!cls.IsGeneric() && !cls.IsClosureClass() && !cls.IsTypedefClass()) {
16831 ASSERT(!IsFunctionType()); 16852 ASSERT(!IsFunctionType());
16832 type = cls.CanonicalType(); 16853 type = cls.CanonicalType();
16833 if (type.IsNull()) { 16854 if (type.IsNull()) {
16834 ASSERT(!cls.raw()->IsVMHeapObject() || (isolate == Dart::vm_isolate())); 16855 ASSERT(!cls.raw()->IsVMHeapObject() || (isolate == Dart::vm_isolate()));
16835 // Canonicalize the type arguments of the supertype, if any. 16856 // Canonicalize the type arguments of the supertype, if any.
16836 TypeArguments& type_args = TypeArguments::Handle(zone, arguments()); 16857 TypeArguments& type_args = TypeArguments::Handle(zone, arguments());
(...skipping 5545 matching lines...) Expand 10 before | Expand all | Expand 10 after
22382 return UserTag::null(); 22403 return UserTag::null();
22383 } 22404 }
22384 22405
22385 22406
22386 const char* UserTag::ToCString() const { 22407 const char* UserTag::ToCString() const {
22387 const String& tag_label = String::Handle(label()); 22408 const String& tag_label = String::Handle(label());
22388 return tag_label.ToCString(); 22409 return tag_label.ToCString();
22389 } 22410 }
22390 22411
22391 } // namespace dart 22412 } // namespace dart
OLDNEW
« 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