Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
dart::Type Class Reference

#include <object.h>

Inheritance diagram for dart::Type:
dart::AbstractType dart::Instance dart::Object

Public Member Functions

virtual bool HasTypeClass () const
 
TypePtr ToNullability (Nullability value, Heap::Space space) const
 
virtual classid_t type_class_id () const
 
virtual ClassPtr type_class () const
 
void set_type_class (const Class &value) const
 
virtual TypeArgumentsPtr arguments () const
 
void set_arguments (const TypeArguments &value) const
 
TypeArgumentsPtr GetInstanceTypeArguments (Thread *thread, bool canonicalize=true) const
 
virtual bool IsInstantiated (Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
 
virtual bool IsEquivalent (const Instance &other, TypeEquality kind, FunctionTypeMapping *function_type_equivalence=nullptr) const
 
bool IsDeclarationTypeOf (const Class &cls) const
 
virtual AbstractTypePtr InstantiateFrom (const TypeArguments &instantiator_type_arguments, const TypeArguments &function_type_arguments, intptr_t num_free_fun_type_params, Heap::Space space, FunctionTypeMapping *function_type_mapping=nullptr, intptr_t num_parent_type_args_adjustment=0) const
 
virtual AbstractTypePtr UpdateFunctionTypes (intptr_t num_parent_type_args_adjustment, intptr_t num_free_fun_type_params, Heap::Space space, FunctionTypeMapping *function_type_mapping) const
 
virtual AbstractTypePtr Canonicalize (Thread *thread) const
 
virtual void EnumerateURIs (URIs *uris) const
 
virtual void PrintName (NameVisibility visibility, BaseTextBuffer *printer) const
 
virtual uword ComputeHash () const
 
- Public Member Functions inherited from dart::AbstractType
bool IsFinalized () const
 
void SetIsFinalized () const
 
Nullability nullability () const
 
bool IsNullable () const
 
bool IsNonNullable () const
 
bool IsLegacy () const
 
bool IsStrictlyNonNullable () const
 
virtual AbstractTypePtr SetInstantiatedNullability (const TypeParameter &type_param, Heap::Space space) const
 
virtual AbstractTypePtr NormalizeFutureOrType (Heap::Space space) const
 
virtual bool CanonicalizeEquals (const Instance &other) const
 
virtual uint32_t CanonicalizeHash () const
 
virtual bool Equals (const Instance &other) const
 
virtual InstancePtr CanonicalizeLocked (Thread *thread) const
 
virtual const char * NullabilitySuffix (NameVisibility name_visibility) const
 
StringPtr Name () const
 
const char * NameCString () const
 
StringPtr UserVisibleName () const
 
const char * UserVisibleNameCString () const
 
StringPtr ScrubbedName () const
 
const char * ScrubbedNameCString () const
 
uword Hash () const
 
StringPtr ClassName () const
 
bool IsDynamicType () const
 
bool IsVoidType () const
 
bool IsNullType () const
 
bool IsNeverType () const
 
bool IsSentinelType () const
 
bool IsObjectType () const
 
bool IsNullableObjectType () const
 
bool IsTopTypeForSubtyping () const
 
bool IsTopTypeForInstanceOf () const
 
bool IsBoolType () const
 
bool IsIntType () const
 
bool IsIntegerImplementationType () const
 
bool IsDoubleType () const
 
bool IsFloat32x4Type () const
 
bool IsFloat64x2Type () const
 
bool IsInt32x4Type () const
 
bool IsNumberType () const
 
bool IsSmiType () const
 
bool IsMintType () const
 
bool IsStringType () const
 
bool IsDartFunctionType () const
 
bool IsDartClosureType () const
 
bool IsDartRecordType () const
 
bool IsFfiPointerType () const
 
bool IsFutureOrType () const
 
AbstractTypePtr UnwrapFutureOr () const
 
bool IsCatchAllType () const
 
bool IsTypeClassAllowedBySpawnUri () const
 
bool IsSubtypeOf (const AbstractType &other, Heap::Space space, FunctionTypeMapping *function_type_equivalence=nullptr) const
 
uword type_test_stub_entry_point () const
 
CodePtr type_test_stub () const
 
void SetTypeTestingStub (const Code &stub) const
 
void InitializeTypeTestingStubNonAtomic (const Code &stub) const
 
void UpdateTypeTestingStubEntryPoint () const
 
- Public Member Functions inherited from dart::Instance
virtual bool OperatorEquals (const Instance &other) const
 
bool IsIdenticalTo (const Instance &other) const
 
intptr_t SizeFromClass () const
 
InstancePtr Canonicalize (Thread *thread) const
 
virtual void CanonicalizeFieldsLocked (Thread *thread) const
 
InstancePtr CopyShallowToOldSpace (Thread *thread) const
 
ObjectPtr GetField (const Field &field) const
 
void SetField (const Field &field, const Object &value) const
 
AbstractTypePtr GetType (Heap::Space space) const
 
virtual TypeArgumentsPtr GetTypeArguments () const
 
virtual void SetTypeArguments (const TypeArguments &value) const
 
bool IsInstanceOf (const AbstractType &other, const TypeArguments &other_instantiator_type_arguments, const TypeArguments &other_function_type_arguments) const
 
bool IsAssignableTo (const AbstractType &other, const TypeArguments &other_instantiator_type_arguments, const TypeArguments &other_function_type_arguments) const
 
bool IsValidNativeIndex (int index) const
 
intptr_t * NativeFieldsDataAddr () const
 
intptr_t GetNativeField (int index) const
 
void GetNativeFields (uint16_t num_fields, intptr_t *field_values) const
 
void SetNativeFields (uint16_t num_fields, const intptr_t *field_values) const
 
uint16_t NumNativeFields () const
 
void SetNativeField (int index, intptr_t value) const
 
bool IsCallable (Function *function) const
 
ObjectPtr Invoke (const String &selector, const Array &arguments, const Array &argument_names, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr InvokeGetter (const String &selector, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr InvokeSetter (const String &selector, const Instance &argument, bool respect_reflectable=true, bool check_is_entrypoint=false) const
 
ObjectPtr EvaluateCompiledExpression (const Class &klass, const ExternalTypedData &kernel_buffer, const Array &type_definitions, const Array &arguments, const TypeArguments &type_arguments) const
 
virtual ObjectPtr HashCode () const
 
IntegerPtr IdentityHashCode (Thread *thread) const
 
virtual bool IsPointer () const
 
- Public Member Functions inherited from dart::Object
virtual ~Object ()
 
ObjectPtr ptr () const
 
void operator= (ObjectPtr value)
 
bool IsCanonical () const
 
void SetCanonical () const
 
void ClearCanonical () const
 
bool IsImmutable () const
 
void SetImmutable () const
 
void ClearImmutable () const
 
intptr_t GetClassId () const
 
ClassPtr clazz () const
 
 CLASS_LIST_FOR_HANDLES (DEFINE_CLASS_TESTER)
 
bool IsNull () const
 
virtual const char * ToCString () const
 
void PrintJSON (JSONStream *stream, bool ref=true) const
 
virtual void PrintJSONImpl (JSONStream *stream, bool ref) const
 
void PrintImplementationFields (JSONStream *stream) const
 
virtual void PrintImplementationFieldsImpl (const JSONArray &jsarr_fields) const
 
virtual const char * JSONType () const
 
virtual StringPtr DictionaryName () const
 
bool IsNew () const
 
bool IsOld () const
 
bool InVMIsolateHeap () const
 
void Print () const
 

Static Public Member Functions

static intptr_t arguments_offset ()
 
static intptr_t InstanceSize ()
 
static TypePtr NullType ()
 
static TypePtr DynamicType ()
 
static TypePtr VoidType ()
 
static TypePtr NeverType ()
 
static TypePtr ObjectType ()
 
static TypePtr BoolType ()
 
static TypePtr IntType ()
 
static TypePtr NullableIntType ()
 
static TypePtr SmiType ()
 
static TypePtr MintType ()
 
static TypePtr Double ()
 
static TypePtr NullableDouble ()
 
static TypePtr Float32x4 ()
 
static TypePtr Float64x2 ()
 
static TypePtr Int32x4 ()
 
static TypePtr Number ()
 
static TypePtr NullableNumber ()
 
static TypePtr StringType ()
 
static TypePtr ArrayType ()
 
static TypePtr DartFunctionType ()
 
static TypePtr DartTypeType ()
 
static TypePtr NewNonParameterizedType (const Class &type_class)
 
static TypePtr New (const Class &clazz, const TypeArguments &arguments, Nullability nullability=Nullability::kLegacy, Heap::Space space=Heap::kOld)
 
- Static Public Member Functions inherited from dart::AbstractType
static intptr_t flags_offset ()
 
static intptr_t hash_offset ()
 
static void AddURI (URIs *uris, const String &name, const String &uri)
 
static StringPtr PrintURIs (URIs *uris)
 
static bool InstantiateAndTestSubtype (AbstractType *subtype, AbstractType *supertype, const TypeArguments &instantiator_type_args, const TypeArguments &function_type_args)
 
static intptr_t type_test_stub_entry_point_offset ()
 
static intptr_t InstanceSize ()
 
static intptr_t NextFieldOffset ()
 
- Static Public Member Functions inherited from dart::Instance
static bool NullIsAssignableTo (const AbstractType &other)
 
static bool NullIsAssignableTo (const AbstractType &other, const TypeArguments &other_instantiator_type_arguments, const TypeArguments &other_function_type_arguments)
 
static ObjectPtr EvaluateCompiledExpression (Thread *thread, const Object &receiver, const Library &library, const Class &klass, const ExternalTypedData &kernel_buffer, const Array &type_definitions, const Array &param_values, const TypeArguments &type_param_values)
 
static intptr_t UnroundedSize ()
 
static intptr_t InstanceSize ()
 
static InstancePtr New (const Class &cls, Heap::Space space=Heap::kNew)
 
static InstancePtr NewAlreadyFinalized (const Class &cls, Heap::Space space=Heap::kNew)
 
static intptr_t DataOffsetFor (intptr_t cid)
 
static intptr_t ElementSizeFor (intptr_t cid)
 
static intptr_t NextFieldOffset ()
 
static intptr_t NativeFieldsOffset ()
 
- Static Public Member Functions inherited from dart::Object
static ObjectPtr RawCast (ObjectPtr obj)
 
static constexpr bool ContainsCompressedPointers ()
 
static intptr_t tags_offset ()
 
static ObjectHandle ()
 
static ObjectHandle (Zone *zone)
 
static ObjectHandle (ObjectPtr ptr)
 
static ObjectHandle (Zone *zone, ObjectPtr ptr)
 
static ObjectZoneHandle ()
 
static ObjectZoneHandle (Zone *zone)
 
static ObjectZoneHandle (ObjectPtr ptr)
 
static ObjectZoneHandle (Zone *zone, ObjectPtr ptr)
 
static ObjectReadOnlyHandle ()
 
static ObjectPtr null ()
 
static void set_vm_isolate_snapshot_object_table (const Array &table)
 
static ClassPtr class_class ()
 
static ClassPtr dynamic_class ()
 
static ClassPtr void_class ()
 
static ClassPtr type_parameters_class ()
 
static ClassPtr type_arguments_class ()
 
static ClassPtr patch_class_class ()
 
static ClassPtr function_class ()
 
static ClassPtr closure_data_class ()
 
static ClassPtr ffi_trampoline_data_class ()
 
static ClassPtr field_class ()
 
static ClassPtr script_class ()
 
static ClassPtr library_class ()
 
static ClassPtr namespace_class ()
 
static ClassPtr kernel_program_info_class ()
 
static ClassPtr code_class ()
 
static ClassPtr instructions_class ()
 
static ClassPtr instructions_section_class ()
 
static ClassPtr instructions_table_class ()
 
static ClassPtr object_pool_class ()
 
static ClassPtr pc_descriptors_class ()
 
static ClassPtr code_source_map_class ()
 
static ClassPtr compressed_stackmaps_class ()
 
static ClassPtr var_descriptors_class ()
 
static ClassPtr exception_handlers_class ()
 
static ClassPtr context_class ()
 
static ClassPtr context_scope_class ()
 
static ClassPtr sentinel_class ()
 
static ClassPtr api_error_class ()
 
static ClassPtr language_error_class ()
 
static ClassPtr unhandled_exception_class ()
 
static ClassPtr unwind_error_class ()
 
static ClassPtr singletargetcache_class ()
 
static ClassPtr unlinkedcall_class ()
 
static ClassPtr monomorphicsmiablecall_class ()
 
static ClassPtr icdata_class ()
 
static ClassPtr megamorphic_cache_class ()
 
static ClassPtr subtypetestcache_class ()
 
static ClassPtr loadingunit_class ()
 
static ClassPtr weak_serialization_reference_class ()
 
static ClassPtr weak_array_class ()
 
static void InitNullAndBool (IsolateGroup *isolate_group)
 
static void Init (IsolateGroup *isolate_group)
 
static void InitVtables ()
 
static void FinishInit (IsolateGroup *isolate_group)
 
static void FinalizeVMIsolate (IsolateGroup *isolate_group)
 
static void FinalizeReadOnlyObject (ObjectPtr object)
 
static void Cleanup ()
 
static ErrorPtr Init (IsolateGroup *isolate_group, const uint8_t *kernel_buffer, intptr_t kernel_buffer_size)
 
static void MakeUnusedSpaceTraversable (const Object &obj, intptr_t original_size, intptr_t used_size)
 
static intptr_t InstanceSize ()
 
template<class FakeObject >
static void VerifyBuiltinVtable (intptr_t cid)
 
static void VerifyBuiltinVtables ()
 
static bool ShouldHaveImmutabilityBitSet (classid_t class_id)
 

Friends

class Class
 
class TypeArguments
 

Additional Inherited Members

- Public Types inherited from dart::Object
enum  NameVisibility { kInternalName = 0 , kScrubbedName , kUserVisibleName }
 
enum class  NameDisambiguation { kYes , kNo }
 
using UntaggedObjectType = UntaggedObject
 
using ObjectPtrType = ObjectPtr
 
- Static Public Attributes inherited from dart::Object
static constexpr intptr_t kHashBits = 30
 
static const ClassId kClassId = kObjectCid
 
- Protected Member Functions inherited from dart::AbstractType
bool IsNullabilityEquivalent (Thread *thread, const AbstractType &other_type, TypeEquality kind) const
 
void SetHash (intptr_t value) const
 
UntaggedAbstractType::TypeState type_state () const
 
void set_flags (uint32_t value) const
 
void set_type_state (UntaggedAbstractType::TypeState value) const
 
void set_nullability (Nullability value) const
 
 HEAP_OBJECT_IMPLEMENTATION (AbstractType, Instance)
 
- Protected Member Functions inherited from dart::Instance
virtual void PrintSharedInstanceJSON (JSONObject *jsobj, bool ref, bool include_id=true) const
 
- Protected Member Functions inherited from dart::Object
 Object ()
 
uword raw_value () const
 
void setPtr (ObjectPtr value, intptr_t default_cid)
 
void CheckHandle () const
 
cpp_vtable vtable () const
 
void set_vtable (cpp_vtable value)
 
bool Contains (uword addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
type LoadPointer (type const *addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
void StorePointer (type const *addr, type value) const
 
template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
void StoreCompressedPointer (compressed_type const *addr, type value) const
 
template<typename type >
void StorePointerUnaligned (type const *addr, type value, Thread *thread) const
 
void StoreSmi (SmiPtr const *addr, SmiPtr value) const
 
template<typename FieldType >
void StoreSimd128 (const FieldType *addr, simd128_value_t value) const
 
template<typename FieldType >
FieldType LoadNonPointer (const FieldType *addr) const
 
template<typename FieldType , std::memory_order order>
FieldType LoadNonPointer (const FieldType *addr) const
 
template<typename FieldType , typename ValueType >
void StoreNonPointer (const FieldType *addr, ValueType value) const
 
template<typename FieldType , typename ValueType , std::memory_order order>
void StoreNonPointer (const FieldType *addr, ValueType value) const
 
template<typename FieldType >
FieldType * UnsafeMutableNonPointer (const FieldType *addr) const
 
 CLASS_LIST (STORE_NON_POINTER_ILLEGAL_TYPE)
 
void UnimplementedMethod () const
 
void AddCommonObjectProperties (JSONObject *jsobj, const char *protocol_type, bool ref) const
 
- Static Protected Member Functions inherited from dart::Object
static DART_NOINLINE ObjectHandleImpl (Zone *zone, ObjectPtr ptr, intptr_t default_cid)
 
static DART_NOINLINE ObjectZoneHandleImpl (Zone *zone, ObjectPtr ptr, intptr_t default_cid)
 
static DART_NOINLINE ObjectReadOnlyHandleImpl (intptr_t cid)
 
static ObjectPtr Allocate (intptr_t cls_id, intptr_t size, Heap::Space space, bool compressed, uword ptr_field_start_offset, uword ptr_field_end_offset)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType Allocate (Heap::Space space)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType Allocate (Heap::Space space, intptr_t elements)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType AllocateVariant (intptr_t class_id, Heap::Space space)
 
template<typename T >
static DART_FORCE_INLINE T::ObjectPtrType AllocateVariant (intptr_t class_id, Heap::Space space, intptr_t elements)
 
static constexpr intptr_t RoundedAllocationSize (intptr_t size)
 
static ObjectPtr Clone (const Object &orig, Heap::Space space, bool load_with_relaxed_atomics=false)
 
template<typename T >
static DART_FORCE_INLINE uword from_offset ()
 
template<typename T >
static DART_FORCE_INLINE uword to_offset (intptr_t length=0)
 
- Protected Attributes inherited from dart::Object
ObjectPtr ptr_
 

Detailed Description

Definition at line 9348 of file object.h.

Member Function Documentation

◆ arguments()

virtual TypeArgumentsPtr dart::Type::arguments ( ) const
inlinevirtual

Reimplemented from dart::AbstractType.

Definition at line 9361 of file object.h.

9361{ return untag()->arguments(); }
raw_obj untag() -> num_entries()) VARIABLE_COMPRESSED_VISITOR(Array, Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(TypedData, TypedData::ElementSizeInBytes(raw_obj->GetClassId()) *Smi::Value(raw_obj->untag() ->length())) VARIABLE_COMPRESSED_VISITOR(Record, RecordShape(raw_obj->untag() ->shape()).num_fields()) VARIABLE_NULL_VISITOR(CompressedStackMaps, CompressedStackMaps::PayloadSizeOf(raw_obj)) VARIABLE_NULL_VISITOR(OneByteString, Smi::Value(raw_obj->untag() ->length())) VARIABLE_NULL_VISITOR(TwoByteString, Smi::Value(raw_obj->untag() ->length())) intptr_t UntaggedField::VisitFieldPointers(FieldPtr raw_obj, ObjectPointerVisitor *visitor)

◆ arguments_offset()

static intptr_t dart::Type::arguments_offset ( )
inlinestatic

Definition at line 9350 of file object.h.

9350 {
9351 return OFFSET_OF(UntaggedType, arguments_);
9352 }
#define OFFSET_OF(type, field)
Definition globals.h:138

◆ ArrayType()

TypePtr dart::Type::ArrayType ( )
static

Definition at line 21934 of file object.cc.

21934 {
21935 return IsolateGroup::Current()->object_store()->array_type();
21936}
ObjectStore * object_store() const
Definition isolate.h:505
static IsolateGroup * Current()
Definition isolate.h:534

◆ BoolType()

TypePtr dart::Type::BoolType ( )
static

Definition at line 21882 of file object.cc.

21882 {
21883 return IsolateGroup::Current()->object_store()->bool_type();
21884}

◆ Canonicalize()

AbstractTypePtr dart::Type::Canonicalize ( Thread thread) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22255 of file object.cc.

22255 {
22256 Zone* zone = thread->zone();
22258 if (IsCanonical()) {
22259#ifdef DEBUG
22260 TypeArguments& type_args = TypeArguments::Handle(zone, arguments());
22261 ASSERT(type_args.IsCanonical());
22262 ASSERT(type_args.IsOld());
22263#endif
22264 return this->ptr();
22265 }
22266 auto isolate_group = thread->isolate_group();
22267 const classid_t cid = type_class_id();
22268 if (cid == kDynamicCid) {
22269 ASSERT(Object::dynamic_type().IsCanonical());
22270 return Object::dynamic_type().ptr();
22271 }
22272
22273 if (cid == kVoidCid) {
22274 ASSERT(Object::void_type().IsCanonical());
22275 return Object::void_type().ptr();
22276 }
22277
22278 const Class& cls = Class::Handle(zone, type_class());
22279
22280 // Fast canonical lookup/registry for simple types.
22281 if (IsDeclarationTypeOf(cls)) {
22282 ASSERT(!cls.IsNullClass() || IsNullable());
22283 Type& type = Type::Handle(zone, cls.declaration_type());
22284 if (type.IsNull()) {
22285 ASSERT(!cls.ptr()->untag()->InVMIsolateHeap() ||
22286 (isolate_group == Dart::vm_isolate_group()));
22287 // Canonicalize the type arguments of the supertype, if any.
22288 TypeArguments& type_args = TypeArguments::Handle(zone, arguments());
22289 type_args = type_args.Canonicalize(thread);
22290 set_arguments(type_args);
22291 type = cls.declaration_type();
22292 // May be set while canonicalizing type args.
22293 if (type.IsNull()) {
22294 SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
22295 // Recheck if type exists.
22296 type = cls.declaration_type();
22297 if (type.IsNull()) {
22298 if (this->IsNew()) {
22299 type ^= Object::Clone(*this, Heap::kOld);
22300 } else {
22301 type = this->ptr();
22302 }
22303 ASSERT(type.IsOld());
22304 type.ComputeHash();
22305 type.SetCanonical();
22306 cls.set_declaration_type(type);
22307 return type.ptr();
22308 }
22309 }
22310 }
22311 ASSERT(this->Equals(type));
22312 ASSERT(type.IsOld());
22313 if (type.IsCanonical()) {
22314 return type.ptr();
22315 }
22316 }
22317
22318 Type& type = Type::Handle(zone);
22319 ObjectStore* object_store = isolate_group->object_store();
22320 {
22321 SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
22322 CanonicalTypeSet table(zone, object_store->canonical_types());
22323 type ^= table.GetOrNull(CanonicalTypeKey(*this));
22324 ASSERT(object_store->canonical_types() == table.Release().ptr());
22325 }
22326 if (type.IsNull()) {
22327 // The type was not found in the table. It is not canonical yet.
22328
22329 // Canonicalize the type arguments.
22330 TypeArguments& type_args = TypeArguments::Handle(zone, arguments());
22331 ASSERT(type_args.IsNull() ||
22332 (type_args.Length() == cls.NumTypeParameters()));
22333 type_args = type_args.Canonicalize(thread);
22334 set_arguments(type_args);
22335 ASSERT(type_args.IsNull() || type_args.IsOld());
22336
22337 // Check to see if the type got added to canonical table as part of the
22338 // type arguments canonicalization.
22339 SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
22340 CanonicalTypeSet table(zone, object_store->canonical_types());
22341 type ^= table.GetOrNull(CanonicalTypeKey(*this));
22342 if (type.IsNull()) {
22343 // Add this type into the canonical table of types.
22344 if (this->IsNew()) {
22345 type ^= Object::Clone(*this, Heap::kOld);
22346 } else {
22347 type = this->ptr();
22348 }
22349 ASSERT(type.IsOld());
22350 type.SetCanonical(); // Mark object as being canonical.
22351 bool present = table.Insert(type);
22352 ASSERT(!present);
22353 }
22354 object_store->set_canonical_types(table.Release());
22355 }
22356 return type.ptr();
22357}
SI F table(const skcms_Curve *curve, F v)
bool IsFinalized() const
Definition object.h:9030
virtual bool Equals(const Instance &other) const
Definition object.h:9074
bool IsNullable() const
Definition object.h:9043
static IsolateGroup * vm_isolate_group()
Definition dart.h:69
@ kOld
Definition heap.h:39
static ObjectPtr Clone(const Object &orig, Heap::Space space, bool load_with_relaxed_atomics=false)
Definition object.cc:2960
ObjectPtr ptr() const
Definition object.h:332
bool IsCanonical() const
Definition object.h:335
bool IsNew() const
Definition object.h:390
static Object & Handle()
Definition object.h:407
friend class TypeArguments
Definition object.h:9487
bool IsDeclarationTypeOf(const Class &cls) const
Definition object.cc:22243
virtual TypeArgumentsPtr arguments() const
Definition object.h:9361
void set_arguments(const TypeArguments &value) const
Definition object.cc:22467
virtual classid_t type_class_id() const
Definition object.cc:22024
friend class Class
Definition object.h:9486
virtual ClassPtr type_class() const
Definition object.cc:22028
#define ASSERT(E)
int32_t classid_t
Definition globals.h:524
@ kVoidCid
Definition class_id.h:254
@ kDynamicCid
Definition class_id.h:253
UnorderedHashSet< CanonicalTypeTraits > CanonicalTypeSet
const intptr_t cid

◆ ComputeHash()

uword dart::Type::ComputeHash ( ) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22400 of file object.cc.

22400 {
22402 uint32_t result = type_class_id();
22403 // A legacy type should have the same hash as its non-nullable version to be
22404 // consistent with the definition of type equality in Dart code.
22405 Nullability type_nullability = nullability();
22406 if (type_nullability == Nullability::kLegacy) {
22407 type_nullability = Nullability::kNonNullable;
22408 }
22409 result = CombineHashes(result, static_cast<uint32_t>(type_nullability));
22410 uint32_t type_args_hash = TypeArguments::kAllDynamicHash;
22411 if (arguments() != TypeArguments::null()) {
22413 type_args_hash = args.Hash();
22414 }
22415 result = CombineHashes(result, type_args_hash);
22417 SetHash(result);
22418 return result;
22419}
void SetHash(intptr_t value) const
Definition object.h:13360
Nullability nullability() const
Definition object.h:9037
static ObjectPtr null()
Definition object.h:433
static constexpr intptr_t kHashBits
Definition object.h:323
static constexpr intptr_t kAllDynamicHash
Definition object.h:8549
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
GAsyncResult * result
Nullability
Definition object.h:1112
uint32_t CombineHashes(uint32_t hash, uint32_t other_hash)
Definition hash.h:12
uint32_t FinalizeHash(uint32_t hash, intptr_t hashbits=kBitsPerInt32)
Definition hash.h:20

◆ DartFunctionType()

TypePtr dart::Type::DartFunctionType ( )
static

Definition at line 21938 of file object.cc.

21938 {
21939 return IsolateGroup::Current()->object_store()->function_type();
21940}

◆ DartTypeType()

TypePtr dart::Type::DartTypeType ( )
static

Definition at line 21942 of file object.cc.

21942 {
21943 return IsolateGroup::Current()->object_store()->type_type();
21944}

◆ Double()

TypePtr dart::Type::Double ( )
static

Definition at line 21902 of file object.cc.

21902 {
21903 return IsolateGroup::Current()->object_store()->double_type();
21904}

◆ DynamicType()

TypePtr dart::Type::DynamicType ( )
static

Definition at line 21866 of file object.cc.

21866 {
21867 return Object::dynamic_type().ptr();
21868}

◆ EnumerateURIs()

void dart::Type::EnumerateURIs ( URIs uris) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22359 of file object.cc.

22359 {
22360 if (IsDynamicType() || IsVoidType() || IsNeverType()) {
22361 return;
22362 }
22363 Thread* thread = Thread::Current();
22364 Zone* zone = thread->zone();
22365 const Class& cls = Class::Handle(zone, type_class());
22366 const String& name = String::Handle(zone, cls.UserVisibleName());
22367 const Library& library = Library::Handle(zone, cls.library());
22368 const String& uri = String::Handle(zone, library.url());
22369 AddURI(uris, name, uri);
22370 const TypeArguments& type_args = TypeArguments::Handle(zone, arguments());
22371 type_args.EnumerateURIs(uris);
22372}
bool IsVoidType() const
Definition object.h:9169
static void AddURI(URIs *uris, const String &name, const String &uri)
Definition object.cc:21314
bool IsDynamicType() const
Definition object.h:9166
bool IsNeverType() const
Definition object.cc:21432
static Thread * Current()
Definition thread.h:361
const char *const name

◆ Float32x4()

TypePtr dart::Type::Float32x4 ( )
static

Definition at line 21910 of file object.cc.

21910 {
21911 return IsolateGroup::Current()->object_store()->float32x4_type();
21912}

◆ Float64x2()

TypePtr dart::Type::Float64x2 ( )
static

Definition at line 21914 of file object.cc.

21914 {
21915 return IsolateGroup::Current()->object_store()->float64x2_type();
21916}

◆ GetInstanceTypeArguments()

TypeArgumentsPtr dart::Type::GetInstanceTypeArguments ( Thread thread,
bool  canonicalize = true 
) const

Definition at line 22480 of file object.cc.

22481 {
22482 Zone* zone = thread->zone();
22483 const auto& cls = Class::Handle(zone, type_class());
22484 const auto& args = TypeArguments::Handle(zone, arguments());
22485 return cls.GetInstanceTypeArguments(thread, args, canonicalize);
22486}

◆ HasTypeClass()

virtual bool dart::Type::HasTypeClass ( ) const
inlinevirtual

Reimplemented from dart::AbstractType.

Definition at line 9353 of file object.h.

9353 {
9355 return true;
9356 }
@ kIllegalCid
Definition class_id.h:214

◆ InstanceSize()

static intptr_t dart::Type::InstanceSize ( )
inlinestatic

Definition at line 9402 of file object.h.

9402 {
9403 return RoundedAllocationSize(sizeof(UntaggedType));
9404 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition object.h:758

◆ InstantiateFrom()

AbstractTypePtr dart::Type::InstantiateFrom ( const TypeArguments instantiator_type_arguments,
const TypeArguments function_type_arguments,
intptr_t  num_free_fun_type_params,
Heap::Space  space,
FunctionTypeMapping function_type_mapping = nullptr,
intptr_t  num_parent_type_args_adjustment = 0 
) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22049 of file object.cc.

22055 {
22056 Zone* zone = Thread::Current()->zone();
22059 // Note that the type class has to be resolved at this time, but not
22060 // necessarily finalized yet. We may be checking bounds at compile time or
22061 // finalizing the type argument vector of a recursive type.
22062 const Class& cls = Class::Handle(zone, type_class());
22063 TypeArguments& type_arguments = TypeArguments::Handle(zone, arguments());
22064 ASSERT(type_arguments.Length() == cls.NumTypeParameters());
22065 type_arguments = type_arguments.InstantiateFrom(
22066 instantiator_type_arguments, function_type_arguments,
22067 num_free_fun_type_params, space, function_type_mapping,
22068 num_parent_type_args_adjustment);
22069 // A returned empty_type_arguments indicates a failed instantiation in dead
22070 // code that must be propagated up to the caller, the optimizing compiler.
22071 if (type_arguments.ptr() == Object::empty_type_arguments().ptr()) {
22072 return Type::null();
22073 }
22074 // This uninstantiated type is not modified, as it can be instantiated
22075 // with different instantiators. Allocate a new instantiated version of it.
22076 const Type& instantiated_type =
22077 Type::Handle(zone, Type::New(cls, type_arguments, nullability(), space));
22078 instantiated_type.SetIsFinalized();
22079 // Canonicalization is not part of instantiation.
22080 return instantiated_type.NormalizeFutureOrType(space);
22081}
Zone * zone() const
static TypePtr New(const Class &clazz, const TypeArguments &arguments, Nullability nullability=Nullability::kLegacy, Heap::Space space=Heap::kOld)
Definition object.cc:22492
virtual bool IsInstantiated(Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
Definition object.cc:22032

◆ Int32x4()

TypePtr dart::Type::Int32x4 ( )
static

Definition at line 21918 of file object.cc.

21918 {
21919 return IsolateGroup::Current()->object_store()->int32x4_type();
21920}

◆ IntType()

TypePtr dart::Type::IntType ( )
static

Definition at line 21886 of file object.cc.

21886 {
21887 return IsolateGroup::Current()->object_store()->int_type();
21888}

◆ IsDeclarationTypeOf()

bool dart::Type::IsDeclarationTypeOf ( const Class cls) const

Definition at line 22243 of file object.cc.

22243 {
22244 ASSERT(type_class() == cls.ptr());
22245 if (cls.IsNullClass()) {
22246 return true;
22247 }
22248 if (cls.IsGeneric() || cls.IsClosureClass()) {
22249 return false;
22250 }
22252}

◆ IsEquivalent()

bool dart::Type::IsEquivalent ( const Instance other,
TypeEquality  kind,
FunctionTypeMapping function_type_equivalence = nullptr 
) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22126 of file object.cc.

22128 {
22129 ASSERT(!IsNull());
22130 if (ptr() == other.ptr()) {
22131 return true;
22132 }
22133 if (!other.IsType()) {
22134 return false;
22135 }
22136 const Type& other_type = Type::Cast(other);
22137 const classid_t type_cid = type_class_id();
22138 const classid_t other_type_cid = other_type.type_class_id();
22139 if (type_cid != other_type_cid) {
22140 if ((kind != TypeEquality::kSyntactical) ||
22143 return false;
22144 }
22145 }
22146 Thread* thread = Thread::Current();
22147 Zone* zone = thread->zone();
22148 ASSERT(
22149 Class::Handle(zone, type_class()).NumTypeParameters(thread) ==
22150 Class::Handle(zone, other_type.type_class()).NumTypeParameters(thread));
22151
22152 if (!IsNullabilityEquivalent(thread, other_type, kind)) {
22153 return false;
22154 }
22155 if (!IsFinalized() || !other_type.IsFinalized()) {
22157 return false; // Too early to decide if equal.
22158 }
22159 if (arguments() == other_type.arguments()) {
22160 return true;
22161 }
22162 const TypeArguments& type_args =
22163 TypeArguments::Handle(zone, this->arguments());
22164 const TypeArguments& other_type_args =
22165 TypeArguments::Handle(zone, other_type.arguments());
22166 return type_args.IsEquivalent(other_type_args, kind,
22167 function_type_equivalence);
22168}
bool IsNullabilityEquivalent(Thread *thread, const AbstractType &other_type, TypeEquality kind) const
Definition object.cc:21245
bool IsNull() const
Definition object.h:363
static classid_t NormalizeClassIdForSyntacticalTypeEquality(classid_t cid)
Definition object.cc:22110

◆ IsInstantiated()

bool dart::Type::IsInstantiated ( Genericity  genericity = kAny,
intptr_t  num_free_fun_type_params = kAllFree 
) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22032 of file object.cc.

22033 {
22035 return true;
22036 }
22037 if ((genericity == kAny) && (num_free_fun_type_params == kAllFree) &&
22039 return false;
22040 }
22041 if (arguments() == TypeArguments::null()) {
22042 return true;
22043 }
22045 return args.IsSubvectorInstantiated(0, args.Length(), genericity,
22046 num_free_fun_type_params);
22047}
UntaggedAbstractType::TypeState type_state() const
Definition object.h:9331
@ kAllFree
Definition object.h:2920
@ kAny
Definition object.h:2229

◆ MintType()

TypePtr dart::Type::MintType ( )
static

Definition at line 21898 of file object.cc.

21898 {
21899 return IsolateGroup::Current()->object_store()->mint_type();
21900}

◆ NeverType()

TypePtr dart::Type::NeverType ( )
static

Definition at line 21874 of file object.cc.

21874 {
21875 return IsolateGroup::Current()->object_store()->never_type();
21876}

◆ New()

TypePtr dart::Type::New ( const Class clazz,
const TypeArguments arguments,
Nullability  nullability = Nullability::kLegacy,
Heap::Space  space = Heap::kOld 
)
static

Definition at line 22492 of file object.cc.

22495 {
22496 Zone* Z = Thread::Current()->zone();
22497 const Type& result = Type::Handle(Z, Type::New(space));
22498 result.SetHash(0);
22499 result.set_flags(0);
22500 result.set_nullability(nullability);
22502 result.set_type_class(clazz);
22503 result.set_arguments(arguments);
22504
22505 result.InitializeTypeTestingStubNonAtomic(
22507 return result.ptr();
22508}
#define Z
ClassPtr clazz() const
Definition object.h:13192
static CodePtr DefaultCodeForType(const AbstractType &type, bool lazy_specialize=true)

◆ NewNonParameterizedType()

TypePtr dart::Type::NewNonParameterizedType ( const Class type_class)
static

Definition at line 21946 of file object.cc.

21946 {
21947 ASSERT(type_class.NumTypeArguments() == 0);
21948 if (type_class.IsNullClass()) {
21949 return Type::NullType();
21950 }
21951 if (type_class.IsDynamicClass()) {
21952 return Type::DynamicType();
21953 }
21954 if (type_class.IsVoidClass()) {
21955 return Type::VoidType();
21956 }
21957 // It is too early to use the class finalizer, as type_class may not be named
21958 // yet, so do not call DeclarationType().
21959 Type& type = Type::Handle(type_class.declaration_type());
21960 if (type.IsNull()) {
21962 Object::null_type_arguments(), Nullability::kNonNullable);
21963 type.SetIsFinalized();
21964 type ^= type.Canonicalize(Thread::Current());
21965 type_class.set_declaration_type(type);
21966 }
21967 ASSERT(type.IsFinalized());
21968 return type.ptr();
21969}
static TypePtr VoidType()
Definition object.cc:21870
static TypePtr DynamicType()
Definition object.cc:21866
static TypePtr NullType()
Definition object.cc:21862

◆ NullableDouble()

TypePtr dart::Type::NullableDouble ( )
static

Definition at line 21906 of file object.cc.

21906 {
21907 return IsolateGroup::Current()->object_store()->nullable_double_type();
21908}

◆ NullableIntType()

TypePtr dart::Type::NullableIntType ( )
static

Definition at line 21890 of file object.cc.

21890 {
21891 return IsolateGroup::Current()->object_store()->nullable_int_type();
21892}

◆ NullableNumber()

TypePtr dart::Type::NullableNumber ( )
static

Definition at line 21926 of file object.cc.

21926 {
21927 return IsolateGroup::Current()->object_store()->nullable_number_type();
21928}

◆ NullType()

TypePtr dart::Type::NullType ( )
static

Definition at line 21862 of file object.cc.

21862 {
21863 return IsolateGroup::Current()->object_store()->null_type();
21864}

◆ Number()

TypePtr dart::Type::Number ( )
static

Definition at line 21922 of file object.cc.

21922 {
21923 return IsolateGroup::Current()->object_store()->number_type();
21924}

◆ ObjectType()

TypePtr dart::Type::ObjectType ( )
static

Definition at line 21878 of file object.cc.

21878 {
21879 return IsolateGroup::Current()->object_store()->object_type();
21880}

◆ PrintName()

void dart::Type::PrintName ( NameVisibility  visibility,
BaseTextBuffer printer 
) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22374 of file object.cc.

22375 {
22376 Thread* thread = Thread::Current();
22377 Zone* zone = thread->zone();
22378 const Class& cls = Class::Handle(zone, type_class());
22379 const TypeParameters& params =
22380 TypeParameters::Handle(zone, cls.type_parameters());
22381 printer->AddString(cls.NameCString(name_visibility));
22383 intptr_t num_type_params = 0;
22384 if (cls.is_declaration_loaded()) {
22385 num_type_params = cls.NumTypeParameters(thread);
22386 } else if (!args.IsNull() || args.ptr() != params.defaults()) {
22387 num_type_params = args.Length();
22388 }
22389 if (num_type_params == 0) {
22390 // Do nothing.
22391 } else {
22392 args.PrintSubvectorName(0, num_type_params, name_visibility, printer);
22393 }
22394 printer->AddString(NullabilitySuffix(name_visibility));
22395 // The name is only used for type checking and debugging purposes.
22396 // Unless profiling data shows otherwise, it is not worth caching the name in
22397 // the type.
22398}
virtual const char * NullabilitySuffix(NameVisibility name_visibility) const
Definition object.cc:21360
const EmbeddedViewParams * params

◆ set_arguments()

void dart::Type::set_arguments ( const TypeArguments value) const

Definition at line 22467 of file object.cc.

22467 {
22468 ASSERT(!IsCanonical());
22469 ASSERT(value.IsNull() ||
22470 // Do not attempt to query number of type parameters
22471 // before class declaration is fully loaded.
22472 !Class::Handle(type_class()).is_declaration_loaded() ||
22473 // Relax assertion in order to support invalid generic types
22474 // created in ClosureMirror_function.
22475 (type_class_id() == kInstanceCid) ||
22476 value.Length() == Class::Handle(type_class()).NumTypeParameters());
22477 untag()->set_arguments(value.ptr());
22478}
uint8_t value

◆ set_type_class()

void dart::Type::set_type_class ( const Class value) const

Definition at line 22462 of file object.cc.

22462 {
22463 ASSERT(!value.IsNull());
22464 set_type_class_id(value.id());
22465}

◆ SmiType()

TypePtr dart::Type::SmiType ( )
static

Definition at line 21894 of file object.cc.

21894 {
21895 return IsolateGroup::Current()->object_store()->smi_type();
21896}

◆ StringType()

TypePtr dart::Type::StringType ( )
static

Definition at line 21930 of file object.cc.

21930 {
21931 return IsolateGroup::Current()->object_store()->string_type();
21932}

◆ ToNullability()

TypePtr dart::Type::ToNullability ( Nullability  value,
Heap::Space  space 
) const

Definition at line 21971 of file object.cc.

21971 {
21972 if (nullability() == value) {
21973 return ptr();
21974 }
21975 // Type parameter instantiation may request a nullability change, which should
21976 // be ignored for types dynamic and void. Type Null cannot be the result of
21977 // instantiating a non-nullable type parameter (TypeError thrown).
21978 const classid_t cid = type_class_id();
21979 if (cid == kDynamicCid || cid == kVoidCid || cid == kNullCid) {
21980 return ptr();
21981 }
21982 if (cid == kNeverCid && value == Nullability::kNullable) {
21983 // Normalize Never? to Null.
21984 return Type::NullType();
21985 }
21986 // Clone type and set new nullability.
21987 Type& type = Type::Handle();
21988 // Always cloning in old space and removing space parameter would not satisfy
21989 // currently existing requests for type instantiation in new space.
21990 // Load with relaxed atomics to prevent data race with updating type
21991 // testing stub.
21992 type ^= Object::Clone(*this, space, /*load_with_relaxed_atomics=*/true);
21993 type.set_nullability(value);
21994 type.SetHash(0);
21995 type.InitializeTypeTestingStubNonAtomic(
21997 if (IsCanonical()) {
21998 // Object::Clone does not clone canonical bit.
21999 ASSERT(!type.IsCanonical());
22000 type ^= type.Canonicalize(Thread::Current());
22001 }
22002 return type.ptr();
22003}
@ kNullCid
Definition class_id.h:252
@ kNeverCid
Definition class_id.h:255

◆ type_class()

ClassPtr dart::Type::type_class ( ) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22028 of file object.cc.

22028 {
22030}
ClassPtr At(intptr_t cid) const
ClassTable * class_table() const
Definition isolate.h:491

◆ type_class_id()

classid_t dart::Type::type_class_id ( ) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22024 of file object.cc.

22024 {
22025 return untag()->type_class_id();
22026}

◆ UpdateFunctionTypes()

AbstractTypePtr dart::Type::UpdateFunctionTypes ( intptr_t  num_parent_type_args_adjustment,
intptr_t  num_free_fun_type_params,
Heap::Space  space,
FunctionTypeMapping function_type_mapping 
) const
virtual

Reimplemented from dart::AbstractType.

Definition at line 22083 of file object.cc.

22087 {
22089 ASSERT(num_parent_type_args_adjustment >= 0);
22090 if (arguments() == Object::null()) {
22091 return ptr();
22092 }
22093 Zone* zone = Thread::Current()->zone();
22094 const auto& type_args = TypeArguments::Handle(zone, arguments());
22095 const auto& updated_type_args = TypeArguments::Handle(
22096 zone, type_args.UpdateFunctionTypes(num_parent_type_args_adjustment,
22097 num_free_fun_type_params, space,
22098 function_type_mapping));
22099 if (type_args.ptr() == updated_type_args.ptr()) {
22100 return ptr();
22101 }
22102 const Class& cls = Class::Handle(zone, type_class());
22103 const Type& new_type = Type::Handle(
22104 zone, Type::New(cls, updated_type_args, nullability(), space));
22105 new_type.SetIsFinalized();
22106 return new_type.ptr();
22107}

◆ VoidType()

TypePtr dart::Type::VoidType ( )
static

Definition at line 21870 of file object.cc.

21870 {
21871 return Object::void_type().ptr();
21872}

Friends And Related Symbol Documentation

◆ Class

friend class Class
friend

Definition at line 9486 of file object.h.

◆ TypeArguments

friend class TypeArguments
friend

Definition at line 9487 of file object.h.


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