Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
dart::CompileType Class Reference

#include <compile_type.h>

Inheritance diagram for dart::CompileType:
dart::ZoneAllocated

Public Member Functions

 CompileType (bool can_be_null, bool can_be_sentinel, intptr_t cid, const AbstractType *type)
 
 CompileType (const CompileType &other)
 
CompileTypeoperator= (const CompileType &other)
 
bool is_nullable () const
 
bool can_be_sentinel () const
 
const AbstractTypeToAbstractType ()
 
intptr_t ToCid ()
 
intptr_t ToNullableCid ()
 
bool HasDecidableNullability ()
 
bool IsNull ()
 
bool IsSubtypeOf (const AbstractType &other)
 
bool IsAssignableTo (const AbstractType &other)
 
bool IsInstanceOf (const AbstractType &other)
 
CompileType CopyNonNullable ()
 
CompileType CopyNonSentinel ()
 
void Union (CompileType *other)
 
bool IsEqualTo (CompileType *other)
 
bool IsNone () const
 
bool IsObject () const
 
bool IsInt ()
 
bool IsDouble ()
 
bool IsBool ()
 
bool IsNullableInt ()
 
bool IsNullableSmi ()
 
bool IsNullableDouble ()
 
bool IsNullableBool ()
 
bool CanBeSmi ()
 
bool CanBeFuture ()
 
bool Specialize (GrowableArray< intptr_t > *class_ids)
 
void PrintTo (BaseTextBuffer *f) const
 
void PrintTo (JSONWriter *writer) const
 
const char * ToCString () const
 
void set_owner (Definition *owner)
 
Definitionowner () const
 
void Write (FlowGraphSerializer *s) const
 
 CompileType (FlowGraphDeserializer *d)
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Static Public Member Functions

static CompileType FromAbstractType (const AbstractType &type, bool can_be_null, bool can_be_sentinel)
 
static CompileType FromCid (intptr_t cid)
 
static CompileType FromUnboxedRepresentation (Representation rep)
 
static CompileType FromRepresentation (Representation rep)
 
static CompileType None ()
 
static CompileType Dynamic ()
 
static CompileType DynamicOrSentinel ()
 
static CompileType Null ()
 
static CompileType Bool ()
 
static CompileType Int ()
 
static CompileType Int32 ()
 
static CompileType NullableInt ()
 
static CompileType Smi ()
 
static CompileType NullableSmi ()
 
static CompileType NullableMint ()
 
static CompileType Double ()
 
static CompileType NullableDouble ()
 
static CompileType String ()
 
static CompileType Object ()
 
static CompileTypeComputeRefinedType (CompileType *old_type, CompileType *new_type)
 

Static Public Attributes

static constexpr bool kCanBeNull = true
 
static constexpr bool kCannotBeNull = false
 
static constexpr bool kCanBeSentinel = true
 
static constexpr bool kCannotBeSentinel = false
 

Detailed Description

Definition at line 43 of file compile_type.h.

Constructor & Destructor Documentation

◆ CompileType() [1/3]

dart::CompileType::CompileType ( bool  can_be_null,
bool  can_be_sentinel,
intptr_t  cid,
const AbstractType type 
)
inline

Definition at line 51 of file compile_type.h.

55 : can_be_null_(can_be_null),
56 can_be_sentinel_(can_be_sentinel),
57 cid_(cid),
58 type_(type) {}
GLenum type
bool can_be_sentinel() const
Definition: compile_type.h:80
const intptr_t cid

◆ CompileType() [2/3]

dart::CompileType::CompileType ( const CompileType other)
inline

Definition at line 60 of file compile_type.h.

61 : ZoneAllocated(),
62 can_be_null_(other.can_be_null_),
63 can_be_sentinel_(other.can_be_sentinel_),
64 cid_(other.cid_),
65 type_(other.type_) {}

◆ CompileType() [3/3]

dart::CompileType::CompileType ( FlowGraphDeserializer d)
explicit

Definition at line 527 of file il_serializer.cc.

528 : can_be_null_(d->Read<bool>()),
529 can_be_sentinel_(d->Read<bool>()),
530 cid_(d->Read<classid_t>()),
531 type_(nullptr) {
532 if (d->Read<bool>()) {
533 type_ = &d->Read<const AbstractType&>();
534 }
535}
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition: main.cc:19
int32_t classid_t
Definition: globals.h:524

Member Function Documentation

◆ Bool()

CompileType dart::CompileType::Bool ( )
static

Definition at line 728 of file type_propagator.cc.

728 {
731}
static constexpr bool kCannotBeSentinel
Definition: compile_type.h:49
CompileType(bool can_be_null, bool can_be_sentinel, intptr_t cid, const AbstractType *type)
Definition: compile_type.h:51
static constexpr bool kCannotBeNull
Definition: compile_type.h:46
static Object & ZoneHandle()
Definition: object.h:419
static TypePtr BoolType()

◆ can_be_sentinel()

bool dart::CompileType::can_be_sentinel ( ) const
inline

Definition at line 80 of file compile_type.h.

80{ return can_be_sentinel_; }

◆ CanBeFuture()

bool dart::CompileType::CanBeFuture ( )

Definition at line 982 of file type_propagator.cc.

982 {
983 Thread* thread = Thread::Current();
984 Zone* zone = thread->zone();
985 if (cid_ != kIllegalCid && cid_ != kDynamicCid) {
986 if ((cid_ == kNullCid) || (cid_ == kNeverCid) ||
987 IsInternalOnlyClassId(cid_) || cid_ == kTypeArgumentsCid) {
988 return false;
989 }
990 const Class& cls =
991 Class::Handle(zone, thread->isolate_group()->class_table()->At(cid_));
992 return cls.is_future_subtype();
993 }
994
995 AbstractType& type = AbstractType::Handle(zone, ToAbstractType()->ptr());
996 if (type.IsTypeParameter()) {
997 type = TypeParameter::Cast(type).bound();
998 }
999 if (type.IsTypeParameter()) {
1000 // Type parameter bounds can be cyclic, do not bother handling them here.
1001 return true;
1002 }
1003 const intptr_t type_class_id = type.type_class_id();
1004 if (type_class_id == kDynamicCid || type_class_id == kVoidCid ||
1005 type_class_id == kInstanceCid || type_class_id == kFutureOrCid) {
1006 return true;
1007 }
1008 if ((type_class_id == kIllegalCid) || (type_class_id == kNullCid) ||
1009 (type_class_id == kNeverCid)) {
1010 return false;
1011 }
1012 const auto& cls = Class::Handle(zone, type.type_class());
1013 return CHA::ClassCanBeFuture(cls);
1014}
static bool ClassCanBeFuture(const Class &cls)
Definition: cha.cc:160
const AbstractType * ToAbstractType()
static Object & Handle()
Definition: object.h:407
static Thread * Current()
Definition: thread.h:362
@ kIllegalCid
Definition: class_id.h:214
@ kNullCid
Definition: class_id.h:252
@ kVoidCid
Definition: class_id.h:254
@ kDynamicCid
Definition: class_id.h:253
@ kNeverCid
Definition: class_id.h:255
bool IsInternalOnlyClassId(intptr_t index)
Definition: class_id.h:299

◆ CanBeSmi()

bool dart::CompileType::CanBeSmi ( )

Definition at line 974 of file type_propagator.cc.

974 {
975 // Fast path for known cid.
976 if (cid_ != kIllegalCid && cid_ != kDynamicCid) {
977 return cid_ == kSmiCid;
978 }
979 return CanPotentiallyBeSmi(*ToAbstractType(), /*recurse=*/true);
980}
static bool CanPotentiallyBeSmi(const AbstractType &type, bool recurse)

◆ ComputeRefinedType()

CompileType * dart::CompileType::ComputeRefinedType ( CompileType old_type,
CompileType new_type 
)
static

Definition at line 613 of file type_propagator.cc.

614 {
615 ASSERT(new_type != nullptr);
616
617 // In general, prefer the newly inferred type over old type.
618 // It is possible that new and old types are unrelated or do not intersect
619 // at all (for example, in case of unreachable code).
620
621 // Discard None type as it is used to denote an unknown type.
622 if (old_type == nullptr || old_type->IsNone()) {
623 return new_type;
624 }
625 if (new_type->IsNone()) {
626 return old_type;
627 }
628
629 CompileType* preferred_type = nullptr;
630
631 // Prefer exact Cid if known.
632 const intptr_t new_type_cid = new_type->ToCid();
633 const intptr_t old_type_cid = old_type->ToCid();
634 if (new_type_cid != old_type_cid) {
635 if (new_type_cid != kDynamicCid) {
636 preferred_type = new_type;
637 } else if (old_type_cid != kDynamicCid) {
638 preferred_type = old_type;
639 }
640 }
641
642 if (preferred_type == nullptr) {
643 const AbstractType* old_abstract_type = old_type->ToAbstractType();
644 const AbstractType* new_abstract_type = new_type->ToAbstractType();
645
646 // Prefer 'int' if known.
647 if (old_type->IsNullableInt()) {
648 preferred_type = old_type;
649 } else if (new_type->IsNullableInt()) {
650 preferred_type = new_type;
651 } else if (old_abstract_type->IsSubtypeOf(*new_abstract_type, Heap::kOld)) {
652 // Prefer old type, as it is clearly more specific.
653 preferred_type = old_type;
654 } else {
655 // Prefer new type as it is more recent, even though it might be
656 // no better than the old type.
657 preferred_type = new_type;
658 }
659 }
660
661 // Refine non-nullability and whether it can be sentinel.
662 const bool can_be_null = old_type->is_nullable() && new_type->is_nullable();
663 const bool can_be_sentinel =
664 old_type->can_be_sentinel() && new_type->can_be_sentinel();
665
666 if ((preferred_type->is_nullable() && !can_be_null) ||
667 (preferred_type->can_be_sentinel() && !can_be_sentinel)) {
668 return new CompileType(can_be_null, can_be_sentinel, preferred_type->cid_,
669 preferred_type->type_);
670 } else {
671 ASSERT(preferred_type->is_nullable() == can_be_null);
672 ASSERT(preferred_type->can_be_sentinel() == can_be_sentinel);
673 return preferred_type;
674 }
675}
@ kOld
Definition: heap.h:39
#define ASSERT(E)

◆ CopyNonNullable()

CompileType dart::CompileType::CopyNonNullable ( )
inline

Definition at line 113 of file compile_type.h.

113 {
114 if (IsNull()) {
115 // Represent a non-nullable null type (typically arising for
116 // unreachable values) as None.
117 return None();
118 }
119
120 return CompileType(kCannotBeNull, can_be_sentinel_, cid_, type_);
121 }
static CompileType None()
Definition: compile_type.h:155

◆ CopyNonSentinel()

CompileType dart::CompileType::CopyNonSentinel ( )
inline

Definition at line 124 of file compile_type.h.

124 {
125 return CompileType(can_be_null_, kCannotBeSentinel, cid_, type_);
126 }

◆ Double()

CompileType dart::CompileType::Double ( )
static

Definition at line 756 of file type_propagator.cc.

756 {
757 return CompileType(kCannotBeNull, kCannotBeSentinel, kDoubleCid,
759}
static TypePtr Double()

◆ Dynamic()

CompileType dart::CompileType::Dynamic ( )
static

Definition at line 713 of file type_propagator.cc.

713 {
715 &Object::dynamic_type());
716}
static constexpr bool kCanBeNull
Definition: compile_type.h:45

◆ DynamicOrSentinel()

CompileType dart::CompileType::DynamicOrSentinel ( )
static

Definition at line 718 of file type_propagator.cc.

718 {
720 &Object::dynamic_type());
721}
static constexpr bool kCanBeSentinel
Definition: compile_type.h:48

◆ FromAbstractType()

CompileType dart::CompileType::FromAbstractType ( const AbstractType type,
bool  can_be_null,
bool  can_be_sentinel 
)
static

Definition at line 677 of file type_propagator.cc.

679 {
680 return CompileType(can_be_null && !type.IsStrictlyNonNullable(),
682}

◆ FromCid()

CompileType dart::CompileType::FromCid ( intptr_t  cid)
static

Definition at line 684 of file type_propagator.cc.

684 {
686 if (cid == kDynamicCid) {
687 return CompileType::Dynamic();
688 }
689 return CompileType(cid == kNullCid, cid == kSentinelCid, cid, nullptr);
690}
static CompileType Dynamic()

◆ FromRepresentation()

CompileType dart::CompileType::FromRepresentation ( Representation  rep)
static

Definition at line 704 of file type_propagator.cc.

704 {
705 if (rep == kUntagged) return CompileType::Object();
707 return FromUnboxedRepresentation(rep);
708 }
709 ASSERT(rep != kNoRepresentation);
710 return CompileType::Dynamic();
711}
static CompileType Object()
static CompileType FromUnboxedRepresentation(Representation rep)
static constexpr bool IsUnboxed(Representation rep)
Definition: locations.h:101

◆ FromUnboxedRepresentation()

CompileType dart::CompileType::FromUnboxedRepresentation ( Representation  rep)
static

Definition at line 692 of file type_propagator.cc.

692 {
693 ASSERT(rep != kTagged);
694 ASSERT(rep != kUntagged);
696 if (!Boxing::RequiresAllocation(rep)) {
697 return CompileType::Smi();
698 }
699 return CompileType::Int();
700 }
702}
static CompileType FromCid(intptr_t cid)
static CompileType Int()
static CompileType Smi()
static bool RequiresAllocation(Representation rep)
Definition: il.cc:470
static intptr_t BoxCid(Representation rep)
Definition: il.cc:493
static constexpr bool IsUnboxedInteger(Representation rep)
Definition: locations.h:92

◆ HasDecidableNullability()

bool dart::CompileType::HasDecidableNullability ( )

Definition at line 839 of file type_propagator.cc.

839 {
840 return !can_be_null_ || IsNull();
841}

◆ Int()

CompileType dart::CompileType::Int ( )
static

Definition at line 733 of file type_propagator.cc.

733 {
736}
static CompileType FromAbstractType(const AbstractType &type, bool can_be_null, bool can_be_sentinel)
static TypePtr IntType()

◆ Int32()

CompileType dart::CompileType::Int32 ( )
static

Definition at line 738 of file type_propagator.cc.

738 {
739#if defined(HAS_SMI_63_BITS)
740 return FromCid(kSmiCid);
741#else
742 return Int();
743#endif
744}

◆ is_nullable()

bool dart::CompileType::is_nullable ( ) const
inline

Definition at line 76 of file compile_type.h.

76{ return can_be_null_; }

◆ IsAssignableTo()

bool dart::CompileType::IsAssignableTo ( const AbstractType other)

Definition at line 881 of file type_propagator.cc.

881 {
882 if (other.IsTopTypeForSubtyping()) {
883 return true;
884 }
885 // If we allow comparisons against an uninstantiated type, then we can
886 // end up incorrectly optimizing away AssertAssignables where the incoming
887 // value and outgoing value have CompileTypes that would return true to the
888 // subtype check below, but at runtime are instantiated with different type
889 // argument vectors such that the relation does not hold for the runtime
890 // instantiated values.
891 //
892 // We might consider using an approximation of the uninstantiated type,
893 // like the instantiation to bounds, and compare to that. However, in
894 // vm/dart/regress_b_230945329_test.dart we have a case where the compared
895 // uninstantiated type is the same as the one in the CompileType. Thus, no
896 // approach will be able to distinguish the two types, and so we fail the
897 // comparison in all cases.
898 if (IsNone() || !other.IsInstantiated()) {
899 return false;
900 }
901 if (is_nullable() && !Instance::NullIsAssignableTo(other)) {
902 return false;
903 }
904 return ToAbstractType()->IsSubtypeOf(other, Heap::kOld);
905}
bool IsSubtypeOf(const AbstractType &other, Heap::Space space, FunctionTypeMapping *function_type_equivalence=nullptr) const
Definition: object.cc:21550
bool IsNone() const
Definition: compile_type.h:221
bool is_nullable() const
Definition: compile_type.h:76
static bool NullIsAssignableTo(const AbstractType &other)
Definition: object.cc:20674

◆ IsBool()

bool dart::CompileType::IsBool ( )
inline

Definition at line 233 of file compile_type.h.

233{ return !is_nullable() && IsNullableBool(); }

◆ IsDouble()

bool dart::CompileType::IsDouble ( )
inline

Definition at line 230 of file compile_type.h.

230{ return !is_nullable() && IsNullableDouble(); }

◆ IsEqualTo()

bool dart::CompileType::IsEqualTo ( CompileType other)
inline

Definition at line 214 of file compile_type.h.

214 {
215 return (can_be_null_ == other->can_be_null_) &&
216 (can_be_sentinel_ == other->can_be_sentinel_) &&
217 (ToNullableCid() == other->ToNullableCid()) &&
218 (compiler::IsEqualType(*ToAbstractType(), *other->ToAbstractType()));
219 }
intptr_t ToNullableCid()
bool IsEqualType(const AbstractType &a, const AbstractType &b)
Definition: runtime_api.cc:67

◆ IsInstanceOf()

bool dart::CompileType::IsInstanceOf ( const AbstractType other)

Definition at line 907 of file type_propagator.cc.

907 {
908 if (other.IsTopTypeForInstanceOf()) {
909 return true;
910 }
911 if (IsNone() || !other.IsInstantiated()) {
912 return false;
913 }
914 if (is_nullable() && !other.IsNullable()) {
915 return false;
916 }
917 return ToAbstractType()->IsSubtypeOf(other, Heap::kOld);
918}

◆ IsInt()

bool dart::CompileType::IsInt ( )
inline

Definition at line 227 of file compile_type.h.

227{ return !is_nullable() && IsNullableInt(); }

◆ IsNone()

bool dart::CompileType::IsNone ( ) const
inline

Definition at line 221 of file compile_type.h.

221{ return (cid_ == kIllegalCid) && (type_ == nullptr); }

◆ IsNull()

bool dart::CompileType::IsNull ( )

Definition at line 843 of file type_propagator.cc.

843 {
844 return (ToCid() == kNullCid);
845}

◆ IsNullableBool()

bool dart::CompileType::IsNullableBool ( )
inline

Definition at line 269 of file compile_type.h.

269 {
270 if (cid_ == kBoolCid) {
271 return true;
272 }
273 if ((cid_ == kIllegalCid) || (cid_ == kDynamicCid)) {
274 return type_ != nullptr && compiler::IsBoolType(*type_);
275 }
276 return false;
277 }
bool IsBoolType(const AbstractType &type)
Definition: runtime_api.cc:75

◆ IsNullableDouble()

bool dart::CompileType::IsNullableDouble ( )
inline

Definition at line 258 of file compile_type.h.

258 {
259 if (cid_ == kDoubleCid) {
260 return true;
261 }
262 if ((cid_ == kIllegalCid) || (cid_ == kDynamicCid)) {
263 return type_ != nullptr && compiler::IsDoubleType(*type_);
264 }
265 return false;
266 }
bool IsDoubleType(const AbstractType &type)
Definition: runtime_api.cc:71

◆ IsNullableInt()

bool dart::CompileType::IsNullableInt ( )
inline

Definition at line 236 of file compile_type.h.

236 {
237 if (cid_ == kSmiCid || cid_ == kMintCid) {
238 return true;
239 }
240 if (cid_ == kIllegalCid || cid_ == kDynamicCid) {
241 return type_ != nullptr && compiler::IsSubtypeOfInt(*type_);
242 }
243 return false;
244 }
bool IsSubtypeOfInt(const AbstractType &type)
Definition: runtime_api.cc:79

◆ IsNullableSmi()

bool dart::CompileType::IsNullableSmi ( )
inline

Definition at line 247 of file compile_type.h.

247 {
248 if (cid_ == kSmiCid) {
249 return true;
250 }
251 if (cid_ == kIllegalCid || cid_ == kDynamicCid) {
252 return type_ != nullptr && compiler::IsSmiType(*type_);
253 }
254 return false;
255 }
bool IsSmiType(const AbstractType &type)
Definition: runtime_api.cc:84

◆ IsObject()

bool dart::CompileType::IsObject ( ) const

Definition at line 776 of file type_propagator.cc.

776 {
777 if (is_nullable()) return false;
778 if (cid_ != kIllegalCid && cid_ != kDynamicCid) return false;
779 return type_ != nullptr && type_->IsObjectType();
780}
bool IsObjectType() const
Definition: object.h:9201

◆ IsSubtypeOf()

bool dart::CompileType::IsSubtypeOf ( const AbstractType other)

Definition at line 869 of file type_propagator.cc.

869 {
870 if (other.IsTopTypeForSubtyping()) {
871 return true;
872 }
873
874 if (IsNone()) {
875 return false;
876 }
877
878 return ToAbstractType()->IsSubtypeOf(other, Heap::kOld);
879}

◆ None()

static CompileType dart::CompileType::None ( )
inlinestatic

Definition at line 155 of file compile_type.h.

155 {
157 }

◆ Null()

CompileType dart::CompileType::Null ( )
static

Definition at line 723 of file type_propagator.cc.

723 {
726}
static TypePtr NullType()

◆ NullableDouble()

CompileType dart::CompileType::NullableDouble ( )
static

Definition at line 761 of file type_propagator.cc.

761 {
764}
static TypePtr NullableDouble()

◆ NullableInt()

CompileType dart::CompileType::NullableInt ( )
static

Definition at line 746 of file type_propagator.cc.

746 {
749}
static TypePtr NullableIntType()

◆ NullableMint()

static CompileType dart::CompileType::NullableMint ( )
inlinestatic

Definition at line 188 of file compile_type.h.

188 {
189 return CompileType(kCanBeNull, kCannotBeSentinel, kMintCid, nullptr);
190 }

◆ NullableSmi()

static CompileType dart::CompileType::NullableSmi ( )
inlinestatic

Definition at line 183 of file compile_type.h.

183 {
184 return CompileType(kCanBeNull, kCannotBeSentinel, kSmiCid, nullptr);
185 }

◆ Object()

CompileType dart::CompileType::Object ( )
static

Definition at line 771 of file type_propagator.cc.

771 {
774}
static TypePtr ObjectType()

◆ operator=()

CompileType & dart::CompileType::operator= ( const CompileType other)
inline

Definition at line 67 of file compile_type.h.

67 {
68 // This intentionally does not change the owner of this type.
69 can_be_null_ = other.can_be_null_;
70 can_be_sentinel_ = other.can_be_sentinel_;
71 cid_ = other.cid_;
72 type_ = other.type_;
73 return *this;
74 }

◆ owner()

Definition * dart::CompileType::owner ( ) const
inline

Definition at line 304 of file compile_type.h.

304{ return owner_; }

◆ PrintTo() [1/2]

void dart::CompileType::PrintTo ( BaseTextBuffer f) const

Definition at line 1041 of file type_propagator.cc.

1041 {
1042 const char* type_name = "?";
1043 if (IsNone()) {
1044 f->AddString("T{}");
1045 return;
1046 } else if ((cid_ != kIllegalCid) && (cid_ != kDynamicCid)) {
1047 const Class& cls =
1048 Class::Handle(IsolateGroup::Current()->class_table()->At(cid_));
1049 type_name = cls.ScrubbedNameCString();
1050 } else if (type_ != nullptr) {
1051 type_name = type_->IsDynamicType() ? "*" : type_->ScrubbedNameCString();
1052 } else if (!is_nullable()) {
1053 type_name = "!null";
1054 }
1055
1056 f->Printf("T{%s%s%s}", type_name, can_be_null_ ? "?" : "",
1057 can_be_sentinel_ ? "~" : "");
1058}
const char * ScrubbedNameCString() const
Definition: object.cc:21346
bool IsDynamicType() const
Definition: object.h:9186
static IsolateGroup * Current()
Definition: isolate.h:539

◆ PrintTo() [2/2]

void dart::CompileType::PrintTo ( JSONWriter writer) const

Definition at line 1017 of file type_propagator.cc.

1017 {
1018 if (IsNone()) {
1019 return;
1020 }
1021
1022 if (cid_ != kIllegalCid && cid_ != kDynamicCid) {
1023 const Class& cls =
1024 Class::Handle(IsolateGroup::Current()->class_table()->At(cid_));
1025 writer->PrintPropertyStr("c", String::Handle(cls.ScrubbedName()));
1026 }
1027
1028 if (type_ != nullptr && !type_->IsDynamicType()) {
1029 writer->PrintPropertyStr("t", String::Handle(type_->ScrubbedName()));
1030 }
1031
1032 if (can_be_null_) {
1033 writer->PrintPropertyBool("n", true);
1034 }
1035
1036 if (can_be_sentinel_) {
1037 writer->PrintPropertyBool("s", true);
1038 }
1039}
StringPtr ScrubbedName() const
Definition: object.cc:21342

◆ set_owner()

void dart::CompileType::set_owner ( Definition owner)
inline

Definition at line 303 of file compile_type.h.

303{ owner_ = owner; }
Definition * owner() const
Definition: compile_type.h:304

◆ Smi()

CompileType dart::CompileType::Smi ( )
static

Definition at line 751 of file type_propagator.cc.

751 {
754}
static TypePtr SmiType()

◆ Specialize()

bool dart::CompileType::Specialize ( GrowableArray< intptr_t > *  class_ids)

Definition at line 920 of file type_propagator.cc.

920 {
922 if (cid_ != kDynamicCid) {
923 class_ids->Add(cid_);
924 return true;
925 }
926 if (type_ != nullptr && type_->type_class_id() != kIllegalCid) {
927 const Class& type_class = Class::Handle(type_->type_class());
928 if (!CHA::ConcreteSubclasses(type_class, class_ids)) return false;
929 if (can_be_null_) {
930 class_ids->Add(kNullCid);
931 }
932 if (can_be_sentinel_) {
933 class_ids->Add(kSentinelCid);
934 }
935 }
936 return false;
937}
virtual classid_t type_class_id() const
Definition: object.cc:21033
virtual ClassPtr type_class() const
Definition: object.cc:21042
void Add(const T &value)
static bool ConcreteSubclasses(const Class &cls, GrowableArray< intptr_t > *class_ids)
Definition: cha.cc:93

◆ String()

CompileType dart::CompileType::String ( )
static

Definition at line 766 of file type_propagator.cc.

766 {
769}
static TypePtr StringType()

◆ ToAbstractType()

const AbstractType * dart::CompileType::ToAbstractType ( )

Definition at line 847 of file type_propagator.cc.

847 {
848 if (type_ == nullptr) {
849 // Type propagation has not run. Return dynamic-type.
850 if (cid_ == kIllegalCid) {
851 return &Object::dynamic_type();
852 }
853
854 // VM-internal objects don't have a compile-type. Return dynamic-type
855 // in this case.
856 if (IsInternalOnlyClassId(cid_) || cid_ == kTypeArgumentsCid) {
857 type_ = &Object::dynamic_type();
858 return type_;
859 }
860
861 auto IG = IsolateGroup::Current();
862 const Class& type_class = Class::Handle(IG->class_table()->At(cid_));
863 type_ = &AbstractType::ZoneHandle(type_class.RareType());
864 }
865
866 return type_;
867}
#define IG

◆ ToCid()

intptr_t dart::CompileType::ToCid ( )

Definition at line 782 of file type_propagator.cc.

782 {
783 if (cid_ == kIllegalCid) {
784 // Make sure to initialize cid_ for Null type to consistently return
785 // kNullCid.
786 if ((type_ != nullptr) && type_->IsNullType()) {
787 cid_ = kNullCid;
788 }
789 // Same for sentinel.
790 if ((type_ != nullptr) && type_->IsSentinelType()) {
791 cid_ = kSentinelCid;
792 }
793 }
794
795 if ((cid_ == kDynamicCid) || (can_be_null_ && (cid_ != kNullCid)) ||
796 (can_be_sentinel_ && (cid_ != kSentinelCid))) {
797 return kDynamicCid;
798 }
799
800 return ToNullableCid();
801}
bool IsNullType() const
Definition: object.cc:21367
bool IsSentinelType() const
Definition: object.cc:21375

◆ ToCString()

const char * dart::CompileType::ToCString ( ) const

Definition at line 1060 of file type_propagator.cc.

1060 {
1061 char buffer[1024];
1062 BufferFormatter f(buffer, sizeof(buffer));
1063 PrintTo(&f);
1065}
void PrintTo(BaseTextBuffer *f) const
Zone * zone() const
Definition: thread_state.h:37
char * MakeCopyOfString(const char *str)
Definition: zone.cc:270
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ ToNullableCid()

intptr_t dart::CompileType::ToNullableCid ( )

Definition at line 803 of file type_propagator.cc.

803 {
804 if (cid_ == kIllegalCid) {
805 if (type_ == nullptr) {
806 // Type propagation is turned off or has not yet run.
807 return kDynamicCid;
808 } else if (type_->IsVoidType()) {
809 cid_ = kDynamicCid;
810 } else if (type_->IsNullType()) {
811 cid_ = kNullCid;
812 } else if (type_->IsSentinelType()) {
813 cid_ = kSentinelCid;
814 } else if (type_->IsFunctionType() || type_->IsDartFunctionType()) {
815 cid_ = kClosureCid;
816 } else if (type_->IsRecordType() || type_->IsDartRecordType()) {
817 cid_ = kRecordCid;
818 } else if (type_->type_class_id() != kIllegalCid) {
819 const Class& type_class = Class::Handle(type_->type_class());
820 intptr_t implementation_cid = kIllegalCid;
822 &implementation_cid)) {
823 cid_ = implementation_cid;
824 } else {
825 cid_ = kDynamicCid;
826 }
827 } else {
828 cid_ = kDynamicCid;
829 }
830 }
831
832 if (can_be_sentinel_ && (cid_ != kSentinelCid)) {
833 return kDynamicCid;
834 }
835
836 return cid_;
837}
bool IsDartFunctionType() const
Definition: object.cc:21451
bool IsDartRecordType() const
Definition: object.cc:21460
bool IsVoidType() const
Definition: object.h:9189
static bool HasSingleConcreteImplementation(const Class &interface, intptr_t *implementation_cid)
Definition: cha.cc:132

◆ Union()

void dart::CompileType::Union ( CompileType other)

Definition at line 556 of file type_propagator.cc.

556 {
557 if (other->IsNone()) {
558 return;
559 }
560
561 if (IsNone()) {
562 *this = *other;
563 return;
564 }
565
566 can_be_null_ = can_be_null_ || other->can_be_null_;
567 can_be_sentinel_ = can_be_sentinel_ || other->can_be_sentinel_;
568
569 ToNullableCid(); // Ensure cid_ is set.
570 if ((cid_ == kNullCid) || (cid_ == kSentinelCid)) {
571 cid_ = other->cid_;
572 type_ = other->type_;
573 return;
574 }
575
576 other->ToNullableCid(); // Ensure other->cid_ is set.
577 if ((other->cid_ == kNullCid) || (other->cid_ == kSentinelCid)) {
578 return;
579 }
580
581 const AbstractType* abstract_type = ToAbstractType();
582 if (cid_ != other->cid_) {
583 cid_ = kDynamicCid;
584 }
585
586 const AbstractType* other_abstract_type = other->ToAbstractType();
587 if (abstract_type->IsSubtypeOf(*other_abstract_type, Heap::kOld)) {
588 type_ = other_abstract_type;
589 return;
590 } else if (other_abstract_type->IsSubtypeOf(*abstract_type, Heap::kOld)) {
591 return; // Nothing to do.
592 }
593
594 // Climb up the hierarchy to find a suitable supertype. Note that interface
595 // types are not considered, making the union potentially non-commutative
596 if (abstract_type->IsInstantiated() && !abstract_type->IsDynamicType() &&
597 !abstract_type->IsFunctionType() && !abstract_type->IsRecordType()) {
598 Class& cls = Class::Handle(abstract_type->type_class());
599 for (; !cls.IsNull() && !cls.IsGeneric(); cls = cls.SuperClass()) {
600 type_ = &AbstractType::ZoneHandle(cls.RareType());
601 if (other_abstract_type->IsSubtypeOf(*type_, Heap::kOld)) {
602 // Found suitable supertype: keep type_ only.
603 cid_ = kDynamicCid;
604 return;
605 }
606 }
607 }
608
609 // Can't unify.
610 type_ = &Object::dynamic_type();
611}

◆ Write()

void dart::CompileType::Write ( FlowGraphSerializer s) const

Definition at line 515 of file il_serializer.cc.

515 {
516 s->Write<bool>(can_be_null_);
517 s->Write<bool>(can_be_sentinel_);
518 s->Write<classid_t>(cid_);
519 if (type_ == nullptr) {
520 s->Write<bool>(false);
521 } else {
522 s->Write<bool>(true);
523 s->Write<const AbstractType&>(*type_);
524 }
525}
struct MyStruct s

Member Data Documentation

◆ kCanBeNull

constexpr bool dart::CompileType::kCanBeNull = true
staticconstexpr

Definition at line 45 of file compile_type.h.

◆ kCanBeSentinel

constexpr bool dart::CompileType::kCanBeSentinel = true
staticconstexpr

Definition at line 48 of file compile_type.h.

◆ kCannotBeNull

constexpr bool dart::CompileType::kCannotBeNull = false
staticconstexpr

Definition at line 46 of file compile_type.h.

◆ kCannotBeSentinel

constexpr bool dart::CompileType::kCannotBeSentinel = false
staticconstexpr

Definition at line 49 of file compile_type.h.


The documentation for this class was generated from the following files: