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

#include <object.h>

Inheritance diagram for dart::TypeArguments:
dart::Instance dart::Object

Classes

struct  ArrayTraits
 
class  Cache
 

Public Member Functions

bool HasCount (intptr_t count) const
 
intptr_t Length () const
 
AbstractTypePtr TypeAt (intptr_t index) const
 
AbstractTypePtr TypeAtNullSafe (intptr_t index) const
 
void SetTypeAt (intptr_t index, const AbstractType &value) const
 
intptr_t nullability () const
 
StringPtr Name () const
 
StringPtr UserVisibleName () const
 
void PrintSubvectorName (intptr_t from_index, intptr_t len, NameVisibility name_visibility, BaseTextBuffer *printer) const
 
void PrintTo (BaseTextBuffer *printer) const
 
bool IsRaw (intptr_t from_index, intptr_t len) const
 
bool IsRawWhenInstantiatedFromRaw (intptr_t len) const
 
TypeArgumentsPtr Prepend (Zone *zone, const TypeArguments &other, intptr_t other_length, intptr_t total_length) const
 
TypeArgumentsPtr ConcatenateTypeParameters (Zone *zone, const TypeArguments &other) const
 
InstantiationMode GetInstantiationMode (Zone *zone, const Function *function=nullptr, const Class *cls=nullptr) const
 
bool Equals (const TypeArguments &other) const
 
bool IsEquivalent (const TypeArguments &other, TypeEquality kind, FunctionTypeMapping *function_type_equivalence=nullptr) const
 
bool IsSubvectorEquivalent (const TypeArguments &other, intptr_t from_index, intptr_t len, TypeEquality kind, FunctionTypeMapping *function_type_equivalence=nullptr) const
 
bool IsInstantiated (Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
 
bool IsSubvectorInstantiated (intptr_t from_index, intptr_t len, Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
 
bool IsUninstantiatedIdentity () const
 
bool CanShareInstantiatorTypeArguments (const Class &instantiator_class, bool *with_runtime_check=nullptr) const
 
bool CanShareFunctionTypeArguments (const Function &function, bool *with_runtime_check=nullptr) const
 
TypeArgumentsPtr TruncatedTo (intptr_t length) const
 
bool IsFinalized () const
 
virtual InstancePtr CanonicalizeLocked (Thread *thread) const
 
TypeArgumentsPtr Canonicalize (Thread *thread) const
 
TypeArgumentsPtr FromInstanceTypeArguments (Thread *thread, const Class &cls) const
 
TypeArgumentsPtr ToInstantiatorTypeArguments (Thread *thread, const Class &cls) const
 
void EnumerateURIs (URIs *uris) const
 
TypeArgumentsPtr 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
 
TypeArgumentsPtr UpdateFunctionTypes (intptr_t num_parent_type_args_adjustment, intptr_t num_free_fun_type_params, Heap::Space space, FunctionTypeMapping *function_type_mapping) const
 
TypeArgumentsPtr InstantiateAndCanonicalizeFrom (const TypeArguments &instantiator_type_arguments, const TypeArguments &function_type_arguments) const
 
bool HasInstantiations () const
 
virtual uint32_t CanonicalizeHash () const
 
uword Hash () const
 
uword HashForRange (intptr_t from_index, intptr_t len) const
 
- Public Member Functions inherited from dart::Instance
virtual bool OperatorEquals (const Instance &other) const
 
bool IsIdenticalTo (const Instance &other) const
 
virtual bool CanonicalizeEquals (const Instance &other) const
 
virtual uint32_t CanonicalizeHash () const
 
intptr_t SizeFromClass () const
 
InstancePtr Canonicalize (Thread *thread) const
 
virtual InstancePtr CanonicalizeLocked (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 length_offset ()
 
static intptr_t types_offset ()
 
static intptr_t type_at_offset (intptr_t index)
 
static intptr_t nullability_offset ()
 
static intptr_t instantiations_offset ()
 
static intptr_t InstanceSize ()
 
static intptr_t InstanceSize (intptr_t len)
 
static intptr_t hash_offset ()
 
static TypeArgumentsPtr New (intptr_t len, Heap::Space space=Heap::kOld)
 
- 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)
 

Static Public Attributes

static constexpr intptr_t kAllDynamicHash = 1
 
static constexpr intptr_t kNullabilityBitsPerType = 1
 
static constexpr intptr_t kNullabilityMaxTypes
 
static constexpr intptr_t kNonNullableBit = 0
 
static constexpr intptr_t kNullableBit = 1
 
static constexpr intptr_t kBytesPerElement = kCompressedWordSize
 
static constexpr intptr_t kMaxElements = kSmiMax / kBytesPerElement
 
- Static Public Attributes inherited from dart::Object
static constexpr intptr_t kHashBits = 30
 
static const ClassId kClassId = kObjectCid
 

Friends

class AbstractType
 
class Class
 
class ClearTypeHashVisitor
 
class Object
 

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
 
- 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 8575 of file object.h.

Member Function Documentation

◆ Canonicalize()

TypeArgumentsPtr dart::TypeArguments::Canonicalize ( Thread thread) const

Definition at line 7703 of file object.cc.

7703 {
7704 if (IsNull() || IsCanonical()) {
7705 ASSERT(IsOld());
7706 return this->ptr();
7707 }
7708 const intptr_t num_types = Length();
7709 if (num_types == 0) {
7710 return TypeArguments::empty_type_arguments().ptr();
7711 } else if (IsRaw(0, num_types)) {
7712 return TypeArguments::null();
7713 }
7714 Zone* zone = thread->zone();
7715 auto isolate_group = thread->isolate_group();
7716 ObjectStore* object_store = isolate_group->object_store();
7717 TypeArguments& result = TypeArguments::Handle(zone);
7718 {
7719 SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
7721 object_store->canonical_type_arguments());
7722 result ^= table.GetOrNull(CanonicalTypeArgumentsKey(*this));
7723 object_store->set_canonical_type_arguments(table.Release());
7724 }
7725 if (result.IsNull()) {
7726 // Canonicalize each type argument.
7727 AbstractType& type_arg = AbstractType::Handle(zone);
7728 GrowableHandlePtrArray<const AbstractType> canonicalized_types(zone,
7729 num_types);
7730 for (intptr_t i = 0; i < num_types; i++) {
7731 type_arg = TypeAt(i);
7732 type_arg = type_arg.Canonicalize(thread);
7733 canonicalized_types.Add(type_arg);
7734 }
7735 SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
7737 object_store->canonical_type_arguments());
7738 // Since we canonicalized some type arguments above we need to lookup
7739 // in the table again to make sure we don't already have an equivalent
7740 // canonical entry.
7741 result ^= table.GetOrNull(CanonicalTypeArgumentsKey(*this));
7742 if (result.IsNull()) {
7743 for (intptr_t i = 0; i < num_types; i++) {
7744 SetTypeAt(i, canonicalized_types.At(i));
7745 }
7746 // Make sure we have an old space object and add it to the table.
7747 if (this->IsNew()) {
7748 result ^= Object::Clone(*this, Heap::kOld);
7749 } else {
7750 result = this->ptr();
7751 }
7752 ASSERT(result.IsOld());
7753 result.ComputeNullability();
7754 result.SetCanonical(); // Mark object as being canonical.
7755 // Now add this TypeArgument into the canonical list of type arguments.
7756 bool present = table.Insert(result);
7757 ASSERT(!present);
7758 }
7759 object_store->set_canonical_type_arguments(table.Release());
7760 }
7761 ASSERT(result.Equals(*this));
7762 ASSERT(!result.IsNull());
7763 ASSERT(result.IsTypeArguments());
7764 ASSERT(result.IsCanonical());
7765 return result.ptr();
7766}
SI F table(const skcms_Curve *curve, F v)
@ kOld
Definition: heap.h:39
static ObjectPtr Clone(const Object &orig, Heap::Space space, bool load_with_relaxed_atomics=false)
Definition: object.cc:2899
static ObjectPtr null()
Definition: object.h:433
ObjectPtr ptr() const
Definition: object.h:332
bool IsCanonical() const
Definition: object.h:335
bool IsNew() const
Definition: object.h:390
bool IsOld() const
Definition: object.h:391
bool IsNull() const
Definition: object.h:363
static Object & Handle()
Definition: object.h:407
intptr_t Length() const
Definition: object.cc:7294
void SetTypeAt(intptr_t index, const AbstractType &value) const
Definition: object.cc:7323
bool IsRaw(intptr_t from_index, intptr_t len) const
Definition: object.h:8646
friend class AbstractType
Definition: object.h:9036
AbstractTypePtr TypeAt(intptr_t index) const
Definition: object.cc:7308
#define ASSERT(E)
GAsyncResult * result
UnorderedHashSet< CanonicalTypeArgumentsTraits > CanonicalTypeArgumentsSet

◆ CanonicalizeHash()

virtual uint32_t dart::TypeArguments::CanonicalizeHash ( ) const
inlinevirtual

Reimplemented from dart::Instance.

Definition at line 9004 of file object.h.

9004{ return Hash(); }
uword Hash() const
Definition: object.h:13396

◆ CanonicalizeLocked()

virtual InstancePtr dart::TypeArguments::CanonicalizeLocked ( Thread thread) const
inlinevirtual

Reimplemented from dart::Instance.

Definition at line 8737 of file object.h.

8737 {
8738 return Canonicalize(thread);
8739 }
TypeArgumentsPtr Canonicalize(Thread *thread) const
Definition: object.cc:7703

◆ CanShareFunctionTypeArguments()

bool dart::TypeArguments::CanShareFunctionTypeArguments ( const Function function,
bool *  with_runtime_check = nullptr 
) const

Definition at line 7472 of file object.cc.

7474 {
7476 if (with_runtime_check != nullptr) {
7477 *with_runtime_check = false;
7478 }
7479 const intptr_t num_type_args = Length();
7480 const intptr_t num_parent_type_args = function.NumParentTypeArguments();
7481 const intptr_t num_function_type_params = function.NumTypeParameters();
7482 const intptr_t num_function_type_args =
7483 num_parent_type_args + num_function_type_params;
7484 if (num_type_args > num_function_type_args) {
7485 // This vector cannot be a prefix of a shorter vector.
7486 return false;
7487 }
7488 AbstractType& type_arg = AbstractType::Handle();
7489 for (intptr_t i = 0; i < num_type_args; i++) {
7490 type_arg = TypeAt(i);
7491 if (!type_arg.IsTypeParameter()) {
7492 return false;
7493 }
7494 const TypeParameter& type_param = TypeParameter::Cast(type_arg);
7495 ASSERT(type_param.IsFinalized());
7496 if ((type_param.index() != i) || !type_param.IsFunctionTypeParameter()) {
7497 return false;
7498 }
7499 // Instantiating nullable type parameters may change nullability
7500 // of a type, so type arguments vector containing such type parameters
7501 // cannot be substituted with the enclosing function type arguments, unless
7502 // we check at runtime the nullability of the first 1 or 2 type arguments of
7503 // the enclosing function type arguments.
7504 if (type_param.IsNullable()) {
7505 if (with_runtime_check == nullptr || i >= kNullabilityMaxTypes) {
7506 return false;
7507 }
7508 *with_runtime_check = true;
7509 }
7510 }
7511 return true;
7512}
bool IsInstantiated(Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
Definition: object.h:8707
static constexpr intptr_t kNullabilityMaxTypes
Definition: object.h:8620
Dart_NativeFunction function
Definition: fuchsia.cc:51

◆ CanShareInstantiatorTypeArguments()

bool dart::TypeArguments::CanShareInstantiatorTypeArguments ( const Class instantiator_class,
bool *  with_runtime_check = nullptr 
) const

Definition at line 7384 of file object.cc.

7386 {
7388 if (with_runtime_check != nullptr) {
7389 *with_runtime_check = false;
7390 }
7391 const intptr_t num_type_args = Length();
7392 const intptr_t num_instantiator_type_args =
7393 instantiator_class.NumTypeArguments();
7394 if (num_type_args > num_instantiator_type_args) {
7395 // This vector cannot be a prefix of a shorter vector.
7396 return false;
7397 }
7398 const intptr_t num_instantiator_type_params =
7399 instantiator_class.NumTypeParameters();
7400 const intptr_t first_type_param_offset =
7401 num_instantiator_type_args - num_instantiator_type_params;
7402 // At compile time, the type argument vector of the instantiator consists of
7403 // the type argument vector of its super type, which may refer to the type
7404 // parameters of the instantiator class, followed by (or overlapping partially
7405 // or fully with) the type parameters of the instantiator class in declaration
7406 // order.
7407 // In other words, the only variables are the type parameters of the
7408 // instantiator class.
7409 // This uninstantiated type argument vector is also expressed in terms of the
7410 // type parameters of the instantiator class. Therefore, in order to be a
7411 // prefix once instantiated at runtime, every one of its type argument must be
7412 // equal to the type argument of the instantiator vector at the same index.
7413
7414 // As a first requirement, the last num_instantiator_type_params type
7415 // arguments of this type argument vector must refer to the corresponding type
7416 // parameters of the instantiator class.
7417 AbstractType& type_arg = AbstractType::Handle();
7418 for (intptr_t i = first_type_param_offset; i < num_type_args; i++) {
7419 type_arg = TypeAt(i);
7420 if (!type_arg.IsTypeParameter()) {
7421 return false;
7422 }
7423 const TypeParameter& type_param = TypeParameter::Cast(type_arg);
7424 ASSERT(type_param.IsFinalized());
7425 if ((type_param.index() != i) || type_param.IsFunctionTypeParameter()) {
7426 return false;
7427 }
7428 // Instantiating nullable type parameters may change nullability
7429 // of a type, so type arguments vector containing such type parameters
7430 // cannot be substituted with instantiator type arguments, unless we check
7431 // at runtime the nullability of the first 1 or 2 type arguments of the
7432 // instantiator.
7433 // Note that the presence of non-overlapping super type arguments (i.e.
7434 // first_type_param_offset > 0) will prevent this optimization.
7435 if (type_param.IsNullable()) {
7436 if (with_runtime_check == nullptr || i >= kNullabilityMaxTypes) {
7437 return false;
7438 }
7439 *with_runtime_check = true;
7440 }
7441 }
7442 // As a second requirement, the type arguments corresponding to the super type
7443 // must be identical. Overlapping ones have already been checked starting at
7444 // first_type_param_offset.
7445 if (first_type_param_offset == 0) {
7446 return true;
7447 }
7448 Type& super_type = Type::Handle(instantiator_class.super_type());
7449 const TypeArguments& super_type_args =
7450 TypeArguments::Handle(super_type.GetInstanceTypeArguments(
7451 Thread::Current(), /*canonicalize=*/false));
7452 if (super_type_args.IsNull()) {
7454 return false;
7455 }
7456 AbstractType& super_type_arg = AbstractType::Handle();
7457 for (intptr_t i = 0; (i < first_type_param_offset) && (i < num_type_args);
7458 i++) {
7459 type_arg = TypeAt(i);
7460 super_type_arg = super_type_args.TypeAt(i);
7461 if (!type_arg.Equals(super_type_arg)) {
7463 return false;
7464 }
7465 }
7466 return true;
7467}
static Thread * Current()
Definition: thread.h:362
bool IsUninstantiatedIdentity() const
Definition: object.cc:7352

◆ ConcatenateTypeParameters()

TypeArgumentsPtr dart::TypeArguments::ConcatenateTypeParameters ( Zone zone,
const TypeArguments other 
) const

Definition at line 6827 of file object.cc.

6829 {
6830 ASSERT(!IsNull() && !other.IsNull());
6831 const intptr_t this_len = Length();
6832 const intptr_t other_len = other.Length();
6833 const auto& result = TypeArguments::Handle(
6834 zone, TypeArguments::New(this_len + other_len, Heap::kNew));
6835 auto& type = AbstractType::Handle(zone);
6836 for (intptr_t i = 0; i < this_len; ++i) {
6837 type = TypeAt(i);
6838 result.SetTypeAt(i, type);
6839 }
6840 for (intptr_t i = 0; i < other_len; ++i) {
6841 type = other.TypeAt(i);
6842 result.SetTypeAt(this_len + i, type);
6843 }
6844 return result.ptr();
6845}
GLenum type
@ kNew
Definition: heap.h:38
static TypeArgumentsPtr New(intptr_t len, Heap::Space space=Heap::kOld)
Definition: object.cc:7675

◆ EnumerateURIs()

void dart::TypeArguments::EnumerateURIs ( URIs uris) const

Definition at line 7819 of file object.cc.

7819 {
7820 if (IsNull()) {
7821 return;
7822 }
7823 Thread* thread = Thread::Current();
7824 Zone* zone = thread->zone();
7826 const intptr_t num_types = Length();
7827 for (intptr_t i = 0; i < num_types; i++) {
7828 type = TypeAt(i);
7829 type.EnumerateURIs(uris);
7830 }
7831}
friend class Thread
Definition: object.h:1025

◆ Equals()

bool dart::TypeArguments::Equals ( const TypeArguments other) const
inline

Definition at line 8686 of file object.h.

8686 {
8687 return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length(),
8689 }
bool IsSubvectorEquivalent(const TypeArguments &other, intptr_t from_index, intptr_t len, TypeEquality kind, FunctionTypeMapping *function_type_equivalence=nullptr) const
Definition: object.cc:6920

◆ FromInstanceTypeArguments()

TypeArgumentsPtr dart::TypeArguments::FromInstanceTypeArguments ( Thread thread,
const Class cls 
) const

Definition at line 7768 of file object.cc.

7770 {
7771 if (IsNull()) {
7772 return ptr();
7773 }
7774 const intptr_t num_type_arguments = cls.NumTypeArguments();
7775 const intptr_t num_type_parameters = cls.NumTypeParameters(thread);
7776 ASSERT(Length() >= num_type_arguments);
7777 if (Length() == num_type_parameters) {
7778 return ptr();
7779 }
7780 if (num_type_parameters == 0) {
7781 return TypeArguments::null();
7782 }
7783 Zone* zone = thread->zone();
7784 const auto& args =
7785 TypeArguments::Handle(zone, TypeArguments::New(num_type_parameters));
7786 const intptr_t offset = num_type_arguments - num_type_parameters;
7787 auto& type = AbstractType::Handle(zone);
7788 for (intptr_t i = 0; i < num_type_parameters; ++i) {
7789 type = TypeAt(offset + i);
7790 args.SetTypeAt(i, type);
7791 }
7792 return args.ptr();
7793}
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
SeparatedVector2 offset

◆ GetInstantiationMode()

InstantiationMode dart::TypeArguments::GetInstantiationMode ( Zone zone,
const Function function = nullptr,
const Class cls = nullptr 
) const

Definition at line 6847 of file object.cc.

6849 {
6850 if (IsNull() || IsInstantiated()) {
6852 }
6853 if (function != nullptr) {
6856 }
6857 if (cls == nullptr) {
6858 cls = &Class::Handle(zone, function->Owner());
6859 }
6860 }
6861 if (cls != nullptr) {
6864 }
6865 }
6867}
bool CanShareFunctionTypeArguments(const Function &function, bool *with_runtime_check=nullptr) const
Definition: object.cc:7472
bool CanShareInstantiatorTypeArguments(const Class &instantiator_class, bool *with_runtime_check=nullptr) const
Definition: object.cc:7384

◆ HasCount()

bool dart::TypeArguments::HasCount ( intptr_t  count) const

Definition at line 7287 of file object.cc.

7287 {
7288 if (IsNull()) {
7289 return true;
7290 }
7291 return Length() == count;
7292}
int count
Definition: FontMgrTest.cpp:50

◆ Hash()

uword dart::TypeArguments::Hash ( ) const
inline

Definition at line 13396 of file object.h.

13396 {
13397 if (IsNull()) return kAllDynamicHash;
13398 intptr_t result = Smi::Value(untag()->hash());
13399 if (result != 0) {
13400 return result;
13401 }
13402 return ComputeHash();
13403}
static uint32_t hash(const SkShaderBase::GradientInfo &v)
intptr_t Value() const
Definition: object.h:9990
static constexpr intptr_t kAllDynamicHash
Definition: object.h:8578
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)
Definition: raw_object.cc:558

◆ hash_offset()

static intptr_t dart::TypeArguments::hash_offset ( )
inlinestatic

Definition at line 9007 of file object.h.

9007 {
9008 return OFFSET_OF(UntaggedTypeArguments, hash_);
9009 }
#define OFFSET_OF(type, field)
Definition: globals.h:138

◆ HashForRange()

uword dart::TypeArguments::HashForRange ( intptr_t  from_index,
intptr_t  len 
) const

Definition at line 6778 of file object.cc.

6778 {
6779 if (IsNull()) return kAllDynamicHash;
6780 if (IsRaw(from_index, len)) return kAllDynamicHash;
6781 uint32_t result = 0;
6783 for (intptr_t i = 0; i < len; i++) {
6784 type = TypeAt(from_index + i);
6785 ASSERT(!type.IsNull());
6786 result = CombineHashes(result, type.Hash());
6787 }
6789 return result;
6790}
static constexpr intptr_t kHashBits
Definition: object.h:323
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

◆ HasInstantiations()

bool dart::TypeArguments::HasInstantiations ( ) const

Definition at line 7269 of file object.cc.

7269 {
7270 return instantiations() != Cache::EmptyStorage().ptr();
7271}
static const Array & EmptyStorage()
Definition: object.h:8891

◆ InstanceSize() [1/2]

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

Definition at line 8988 of file object.h.

8988 {
8989 ASSERT(sizeof(UntaggedTypeArguments) ==
8990 OFFSET_OF_RETURNED_VALUE(UntaggedTypeArguments, types));
8991 return 0;
8992 }
#define OFFSET_OF_RETURNED_VALUE(type, accessor)
Definition: globals.h:143

◆ InstanceSize() [2/2]

static intptr_t dart::TypeArguments::InstanceSize ( intptr_t  len)
inlinestatic

Definition at line 8994 of file object.h.

8994 {
8995 // Ensure that the types() is not adding to the object size, which includes
8996 // 4 fields: instantiations_, length_, hash_, and nullability_.
8997 ASSERT(sizeof(UntaggedTypeArguments) ==
8998 (sizeof(UntaggedObject) + (kNumFields * kCompressedWordSize)));
8999 ASSERT(0 <= len && len <= kMaxElements);
9000 return RoundedAllocationSize(sizeof(UntaggedTypeArguments) +
9001 (len * kBytesPerElement));
9002 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition: object.h:758
static constexpr intptr_t kBytesPerElement
Definition: object.h:8985
static constexpr intptr_t kMaxElements
Definition: object.h:8986
static constexpr intptr_t kCompressedWordSize
Definition: globals.h:42

◆ InstantiateAndCanonicalizeFrom()

TypeArgumentsPtr dart::TypeArguments::InstantiateAndCanonicalizeFrom ( const TypeArguments instantiator_type_arguments,
const TypeArguments function_type_arguments 
) const

Definition at line 7620 of file object.cc.

7622 {
7623 auto thread = Thread::Current();
7624 auto zone = thread->zone();
7625 SafepointMutexLocker ml(
7626 thread->isolate_group()->type_arguments_canonicalization_mutex());
7627
7629 ASSERT(instantiator_type_arguments.IsNull() ||
7630 instantiator_type_arguments.IsCanonical());
7631 ASSERT(function_type_arguments.IsNull() ||
7632 function_type_arguments.IsCanonical());
7633 // Lookup instantiators and if found, return instantiated result.
7634 Cache cache(zone, *this);
7635 auto const loc = cache.FindKeyOrUnused(instantiator_type_arguments,
7636 function_type_arguments);
7637 if (loc.present) {
7638#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
7640 TextBuffer buffer(1024);
7641 buffer.Printf("for\n");
7642 buffer.Printf(" * uninstantiated type arguments %s\n", ToCString());
7643 buffer.Printf(" * instantiation type arguments: %s (hash: %" Pu ")\n",
7644 instantiator_type_arguments.ToCString(),
7645 instantiator_type_arguments.Hash());
7646 buffer.Printf(" * function type arguments: %s (hash: %" Pu ")\n",
7647 function_type_arguments.ToCString(),
7648 function_type_arguments.Hash());
7649 buffer.Printf(" * number of occupied entries in cache: %" Pd "\n",
7650 cache.NumOccupied());
7651 buffer.Printf(" * number of total entries in cache: %" Pd "\n",
7652 cache.NumEntries());
7653 buffer.Printf("expected to find entry %" Pd
7654 " of cache in stub, but reached runtime",
7655 loc.entry);
7656 FATAL("%s", buffer.buffer());
7657 }
7658#endif
7659 return cache.Retrieve(loc.entry);
7660 }
7661 // Cache lookup failed. Instantiate the type arguments.
7662 TypeArguments& result = TypeArguments::Handle(zone);
7663 result = InstantiateFrom(instantiator_type_arguments, function_type_arguments,
7665 // Canonicalize type arguments.
7666 result = result.Canonicalize(thread);
7667 // InstantiateAndCanonicalizeFrom is not reentrant. It cannot have been called
7668 // indirectly, so the prior_instantiations array cannot have grown.
7669 ASSERT(cache.data_.ptr() == instantiations());
7670 cache.AddEntry(loc.entry, instantiator_type_arguments,
7671 function_type_arguments, result);
7672 return result.ptr();
7673}
virtual const char * ToCString() const
Definition: object.h:366
TypeArgumentsPtr 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
Definition: object.cc:7540
#define FATAL(error)
bool TESTING_runtime_fail_on_existing_cache_entry
Definition: object.cc:7617
@ kAllFree
Definition: object.h:2940
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 Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets Path to the Flutter assets directory enable service port Allow the VM service to fallback to automatic port selection if binding to a specified port fails trace Trace early application lifecycle Automatically switches to an endless trace buffer trace skia Filters out all Skia trace event categories except those that are specified in this comma separated list dump skp on shader Automatically dump the skp that triggers new shader compilations This is useful for writing custom ShaderWarmUp to reduce jank By this is not enabled to reduce the overhead purge persistent cache
Definition: switches.h:191
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
#define Pu
Definition: globals.h:409
#define Pd
Definition: globals.h:408

◆ InstantiateFrom()

TypeArgumentsPtr dart::TypeArguments::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

Definition at line 7540 of file object.cc.

7546 {
7548 if ((instantiator_type_arguments.IsNull() ||
7549 instantiator_type_arguments.Length() == Length()) &&
7551 return instantiator_type_arguments.ptr();
7552 }
7553 const intptr_t num_types = Length();
7554 TypeArguments& instantiated_array =
7555 TypeArguments::Handle(TypeArguments::New(num_types, space));
7557 for (intptr_t i = 0; i < num_types; i++) {
7558 type = TypeAt(i);
7559 // If this type argument T is null, the type A containing T in its flattened
7560 // type argument vector V is recursive and is still being finalized.
7561 // T is the type argument of a super type of A. T is being instantiated
7562 // during finalization of V, which is also the instantiator. T depends
7563 // solely on the type parameters of A and will be replaced by a non-null
7564 // type before A is marked as finalized.
7565 if (!type.IsNull() && !type.IsInstantiated()) {
7566 type = type.InstantiateFrom(
7567 instantiator_type_arguments, function_type_arguments,
7568 num_free_fun_type_params, space, function_type_mapping,
7569 num_parent_type_args_adjustment);
7570 // A returned null type indicates a failed instantiation in dead code that
7571 // must be propagated up to the caller, the optimizing compiler.
7572 if (type.IsNull()) {
7573 return Object::empty_type_arguments().ptr();
7574 }
7575 }
7576 instantiated_array.SetTypeAt(i, type);
7577 }
7578 return instantiated_array.ptr();
7579}

◆ instantiations_offset()

static intptr_t dart::TypeArguments::instantiations_offset ( )
inlinestatic

Definition at line 8981 of file object.h.

8981 {
8982 return OFFSET_OF(UntaggedTypeArguments, instantiations_);
8983 }

◆ IsEquivalent()

bool dart::TypeArguments::IsEquivalent ( const TypeArguments other,
TypeEquality  kind,
FunctionTypeMapping function_type_equivalence = nullptr 
) const
inline

Definition at line 8691 of file object.h.

8694 {
8695 // Make a null vector a vector of dynamic as long as the other vector.
8696 return IsSubvectorEquivalent(other, 0, IsNull() ? other.Length() : Length(),
8697 kind, function_type_equivalence);
8698 }

◆ IsFinalized()

bool dart::TypeArguments::IsFinalized ( ) const

Definition at line 7527 of file object.cc.

7527 {
7528 ASSERT(!IsNull());
7530 const intptr_t num_types = Length();
7531 for (intptr_t i = 0; i < num_types; i++) {
7532 type = TypeAt(i);
7533 if (!type.IsFinalized()) {
7534 return false;
7535 }
7536 }
7537 return true;
7538}

◆ IsInstantiated()

bool dart::TypeArguments::IsInstantiated ( Genericity  genericity = kAny,
intptr_t  num_free_fun_type_params = kAllFree 
) const
inline

Definition at line 8707 of file object.h.

8708 {
8709 return IsSubvectorInstantiated(0, Length(), genericity,
8710 num_free_fun_type_params);
8711 }
bool IsSubvectorInstantiated(intptr_t from_index, intptr_t len, Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
Definition: object.cc:7329

◆ IsRaw()

bool dart::TypeArguments::IsRaw ( intptr_t  from_index,
intptr_t  len 
) const
inline

Definition at line 8646 of file object.h.

8646 {
8647 return IsDynamicTypes(false, from_index, len);
8648 }

◆ IsRawWhenInstantiatedFromRaw()

bool dart::TypeArguments::IsRawWhenInstantiatedFromRaw ( intptr_t  len) const
inline

Definition at line 8656 of file object.h.

8656 {
8657 return IsDynamicTypes(true, 0, len);
8658 }

◆ IsSubvectorEquivalent()

bool dart::TypeArguments::IsSubvectorEquivalent ( const TypeArguments other,
intptr_t  from_index,
intptr_t  len,
TypeEquality  kind,
FunctionTypeMapping function_type_equivalence = nullptr 
) const

Definition at line 6920 of file object.cc.

6925 {
6926 if (this->ptr() == other.ptr()) {
6927 return true;
6928 }
6929 if (kind == TypeEquality::kCanonical) {
6930 if (IsNull() || other.IsNull()) {
6931 return false;
6932 }
6933 if (Length() != other.Length()) {
6934 return false;
6935 }
6936 }
6938 AbstractType& other_type = AbstractType::Handle();
6939 for (intptr_t i = from_index; i < from_index + len; i++) {
6941 ASSERT(!type.IsNull());
6942 other_type = other.IsNull() ? Type::DynamicType() : other.TypeAt(i);
6943 ASSERT(!other_type.IsNull());
6944 if (!type.IsEquivalent(other_type, kind, function_type_equivalence)) {
6945 return false;
6946 }
6947 }
6948 return true;
6949}
static TypePtr DynamicType()

◆ IsSubvectorInstantiated()

bool dart::TypeArguments::IsSubvectorInstantiated ( intptr_t  from_index,
intptr_t  len,
Genericity  genericity = kAny,
intptr_t  num_free_fun_type_params = kAllFree 
) const

Definition at line 7329 of file object.cc.

7333 {
7334 ASSERT(!IsNull());
7336 for (intptr_t i = 0; i < len; i++) {
7337 type = TypeAt(from_index + i);
7338 // If this type argument T is null, the type A containing T in its flattened
7339 // type argument vector V is recursive and is still being finalized.
7340 // T is the type argument of a super type of A. T is being instantiated
7341 // during finalization of V, which is also the instantiator. T depends
7342 // solely on the type parameters of A and will be replaced by a non-null
7343 // type before A is marked as finalized.
7344 if (!type.IsNull() &&
7345 !type.IsInstantiated(genericity, num_free_fun_type_params)) {
7346 return false;
7347 }
7348 }
7349 return true;
7350}

◆ IsUninstantiatedIdentity()

bool dart::TypeArguments::IsUninstantiatedIdentity ( ) const

Definition at line 7352 of file object.cc.

7352 {
7354 const intptr_t num_types = Length();
7355 for (intptr_t i = 0; i < num_types; i++) {
7356 type = TypeAt(i);
7357 if (type.IsNull()) {
7358 return false; // Still unfinalized, too early to tell.
7359 }
7360 if (!type.IsTypeParameter()) {
7361 return false;
7362 }
7363 const TypeParameter& type_param = TypeParameter::Cast(type);
7364 ASSERT(type_param.IsFinalized());
7365 if ((type_param.index() != i) || type_param.IsFunctionTypeParameter()) {
7366 return false;
7367 }
7368 // Instantiating nullable type parameters may change
7369 // nullability of a type, so type arguments vector containing such type
7370 // parameters cannot be substituted with instantiator type arguments.
7371 if (type_param.IsNullable()) {
7372 return false;
7373 }
7374 }
7375 return true;
7376 // Note that it is not necessary to verify at runtime that the instantiator
7377 // type vector is long enough, since this uninstantiated vector contains as
7378 // many different type parameters as it is long.
7379}

◆ Length()

intptr_t dart::TypeArguments::Length ( ) const

Definition at line 7294 of file object.cc.

7294 {
7295 if (IsNull()) {
7296 return 0;
7297 }
7298 return Smi::Value(untag()->length());
7299}
size_t length

◆ length_offset()

static intptr_t dart::TypeArguments::length_offset ( )
inlinestatic

Definition at line 8583 of file object.h.

8583 {
8584 return OFFSET_OF(UntaggedTypeArguments, length_);
8585 }

◆ Name()

StringPtr dart::TypeArguments::Name ( ) const

Definition at line 6869 of file object.cc.

6869 {
6870 Thread* thread = Thread::Current();
6871 ZoneTextBuffer printer(thread->zone());
6872 PrintSubvectorName(0, Length(), kInternalName, &printer);
6873 return Symbols::New(thread, printer.buffer());
6874}
@ kInternalName
Definition: object.h:622
static StringPtr New(Thread *thread, const char *cstr)
Definition: symbols.h:723
void PrintSubvectorName(intptr_t from_index, intptr_t len, NameVisibility name_visibility, BaseTextBuffer *printer) const
Definition: object.cc:6883

◆ New()

TypeArgumentsPtr dart::TypeArguments::New ( intptr_t  len,
Heap::Space  space = Heap::kOld 
)
static

Definition at line 7675 of file object.cc.

7675 {
7676 if (len < 0 || len > kMaxElements) {
7677 // This should be caught before we reach here.
7678 FATAL("Fatal error in TypeArguments::New: invalid len %" Pd "\n", len);
7679 }
7680 TypeArguments& result = TypeArguments::Handle();
7681 {
7682 auto raw = Object::Allocate<TypeArguments>(space, len);
7683 NoSafepointScope no_safepoint;
7684 result = raw;
7685 // Length must be set before we start storing into the array.
7686 result.SetLength(len);
7687 result.SetHash(0);
7688 result.set_nullability(0);
7689 }
7690 // The array used as storage for an empty linear cache should be initialized.
7692 result.set_instantiations(Cache::EmptyStorage());
7693 return result.ptr();
7694}

◆ nullability()

intptr_t dart::TypeArguments::nullability ( ) const

Definition at line 7301 of file object.cc.

7301 {
7302 if (IsNull()) {
7303 return 0;
7304 }
7305 return Smi::Value(untag()->nullability());
7306}
intptr_t nullability() const
Definition: object.cc:7301

◆ nullability_offset()

static intptr_t dart::TypeArguments::nullability_offset ( )
inlinestatic

Definition at line 8625 of file object.h.

8625 {
8626 return OFFSET_OF(UntaggedTypeArguments, nullability_);
8627 }

◆ Prepend()

TypeArgumentsPtr dart::TypeArguments::Prepend ( Zone zone,
const TypeArguments other,
intptr_t  other_length,
intptr_t  total_length 
) const

Definition at line 6800 of file object.cc.

6803 {
6804 if (other_length == 0) {
6806 return ptr();
6807 } else if (other_length == total_length) {
6808 ASSERT(other.IsCanonical());
6809 return other.ptr();
6810 } else if (IsNull() && other.IsNull()) {
6811 return TypeArguments::null();
6812 }
6813 const TypeArguments& result =
6816 for (intptr_t i = 0; i < other_length; i++) {
6817 type = other.IsNull() ? Type::DynamicType() : other.TypeAt(i);
6818 result.SetTypeAt(i, type);
6819 }
6820 for (intptr_t i = other_length; i < total_length; i++) {
6821 type = IsNull() ? Type::DynamicType() : TypeAt(i - other_length);
6822 result.SetTypeAt(i, type);
6823 }
6824 return result.Canonicalize(Thread::Current());
6825}

◆ PrintSubvectorName()

void dart::TypeArguments::PrintSubvectorName ( intptr_t  from_index,
intptr_t  len,
NameVisibility  name_visibility,
BaseTextBuffer printer 
) const

Definition at line 6883 of file object.cc.

6886 {
6887 printer->AddString("<");
6889 for (intptr_t i = 0; i < len; i++) {
6890 if (from_index + i < Length()) {
6891 type = TypeAt(from_index + i);
6892 if (type.IsNull()) {
6893 printer->AddString("null"); // Unfinalized vector.
6894 } else {
6895 type.PrintName(name_visibility, printer);
6896 }
6897 } else {
6898 printer->AddString("dynamic");
6899 }
6900 if (i < len - 1) {
6901 printer->AddString(", ");
6902 }
6903 }
6904 printer->AddString(">");
6905}

◆ PrintTo()

void dart::TypeArguments::PrintTo ( BaseTextBuffer printer) const

Definition at line 6907 of file object.cc.

6907 {
6908 buffer->AddString("TypeArguments: ");
6909 if (IsNull()) {
6910 return buffer->AddString("null");
6911 }
6912 buffer->Printf("(H%" Px ")", Smi::Value(untag()->hash()));
6913 auto& type_at = AbstractType::Handle();
6914 for (intptr_t i = 0; i < Length(); i++) {
6915 type_at = TypeAt(i);
6916 buffer->Printf(" [%s]", type_at.IsNull() ? "null" : type_at.ToCString());
6917 }
6918}
#define Px
Definition: globals.h:410

◆ SetTypeAt()

void dart::TypeArguments::SetTypeAt ( intptr_t  index,
const AbstractType value 
) const

Definition at line 7323 of file object.cc.

7323 {
7324 ASSERT(!IsCanonical());
7325 ASSERT((index >= 0) && (index < Length()));
7326 return untag()->set_element(index, value.ptr());
7327}
uint8_t value

◆ ToInstantiatorTypeArguments()

TypeArgumentsPtr dart::TypeArguments::ToInstantiatorTypeArguments ( Thread thread,
const Class cls 
) const

Definition at line 7795 of file object.cc.

7797 {
7798 if (IsNull()) {
7799 return ptr();
7800 }
7801 const intptr_t num_type_arguments = cls.NumTypeArguments();
7802 const intptr_t num_type_parameters = cls.NumTypeParameters(thread);
7803 ASSERT(Length() == num_type_parameters);
7804 if (num_type_arguments == num_type_parameters) {
7805 return ptr();
7806 }
7807 Zone* zone = thread->zone();
7808 const auto& args =
7809 TypeArguments::Handle(zone, TypeArguments::New(num_type_arguments));
7810 const intptr_t offset = num_type_arguments - num_type_parameters;
7811 auto& type = AbstractType::Handle(zone);
7812 for (intptr_t i = 0; i < num_type_parameters; ++i) {
7813 type = TypeAt(i);
7814 args.SetTypeAt(offset + i, type);
7815 }
7816 return args.ptr();
7817}

◆ TruncatedTo()

TypeArgumentsPtr dart::TypeArguments::TruncatedTo ( intptr_t  length) const

Definition at line 7514 of file object.cc.

7514 {
7515 Thread* thread = Thread::Current();
7516 Zone* zone = thread->zone();
7517 const TypeArguments& result =
7520 for (intptr_t i = 0; i < length; i++) {
7521 type = TypeAt(i);
7522 result.SetTypeAt(i, type);
7523 }
7524 return result.Canonicalize(thread);
7525}

◆ type_at_offset()

static intptr_t dart::TypeArguments::type_at_offset ( intptr_t  index)
inlinestatic

Definition at line 8592 of file object.h.

8592 {
8593 return types_offset() + index * kCompressedWordSize;
8594 }
static intptr_t types_offset()
Definition: object.h:8589

◆ TypeAt()

AbstractTypePtr dart::TypeArguments::TypeAt ( intptr_t  index) const

Definition at line 7308 of file object.cc.

7308 {
7309 ASSERT(!IsNull());
7310 ASSERT((index >= 0) && (index < Length()));
7311 return untag()->element(index);
7312}

◆ TypeAtNullSafe()

AbstractTypePtr dart::TypeArguments::TypeAtNullSafe ( intptr_t  index) const

Definition at line 7314 of file object.cc.

7314 {
7315 if (IsNull()) {
7316 // null vector represents infinite list of dynamics
7317 return Type::dynamic_type().ptr();
7318 }
7319 ASSERT((index >= 0) && (index < Length()));
7320 return TypeAt(index);
7321}

◆ types_offset()

static intptr_t dart::TypeArguments::types_offset ( )
inlinestatic

Definition at line 8589 of file object.h.

8589 {
8590 return OFFSET_OF_RETURNED_VALUE(UntaggedTypeArguments, types);
8591 }

◆ UpdateFunctionTypes()

TypeArgumentsPtr dart::TypeArguments::UpdateFunctionTypes ( intptr_t  num_parent_type_args_adjustment,
intptr_t  num_free_fun_type_params,
Heap::Space  space,
FunctionTypeMapping function_type_mapping 
) const

Definition at line 7581 of file object.cc.

7585 {
7586 Zone* zone = Thread::Current()->zone();
7587 TypeArguments* updated_args = nullptr;
7589 AbstractType& updated = AbstractType::Handle(zone);
7590 for (intptr_t i = 0, n = Length(); i < n; ++i) {
7591 type = TypeAt(i);
7592 updated = type.UpdateFunctionTypes(num_parent_type_args_adjustment,
7593 num_free_fun_type_params, space,
7594 function_type_mapping);
7595 if (type.ptr() != updated.ptr()) {
7596 if (updated_args == nullptr) {
7597 updated_args =
7598 &TypeArguments::Handle(zone, TypeArguments::New(n, space));
7599 for (intptr_t j = 0; j < i; ++j) {
7600 type = TypeAt(j);
7601 updated_args->SetTypeAt(j, type);
7602 }
7603 }
7604 }
7605 if (updated_args != nullptr) {
7606 updated_args->SetTypeAt(i, updated);
7607 }
7608 }
7609 return (updated_args != nullptr) ? updated_args->ptr() : ptr();
7610}
Zone * zone() const
Definition: thread_state.h:37

◆ UserVisibleName()

StringPtr dart::TypeArguments::UserVisibleName ( ) const

Definition at line 6876 of file object.cc.

6876 {
6877 Thread* thread = Thread::Current();
6878 ZoneTextBuffer printer(thread->zone());
6880 return Symbols::New(thread, printer.buffer());
6881}
@ kUserVisibleName
Definition: object.h:645

Friends And Related Function Documentation

◆ AbstractType

friend class AbstractType
friend

Definition at line 9036 of file object.h.

◆ Class

friend class Class
friend

Definition at line 9037 of file object.h.

◆ ClearTypeHashVisitor

friend class ClearTypeHashVisitor
friend

Definition at line 9038 of file object.h.

◆ Object

friend class Object
friend

Definition at line 9039 of file object.h.

Member Data Documentation

◆ kAllDynamicHash

constexpr intptr_t dart::TypeArguments::kAllDynamicHash = 1
staticconstexpr

Definition at line 8578 of file object.h.

◆ kBytesPerElement

constexpr intptr_t dart::TypeArguments::kBytesPerElement = kCompressedWordSize
staticconstexpr

Definition at line 8985 of file object.h.

◆ kMaxElements

constexpr intptr_t dart::TypeArguments::kMaxElements = kSmiMax / kBytesPerElement
staticconstexpr

Definition at line 8986 of file object.h.

◆ kNonNullableBit

constexpr intptr_t dart::TypeArguments::kNonNullableBit = 0
staticconstexpr

Definition at line 8622 of file object.h.

◆ kNullabilityBitsPerType

constexpr intptr_t dart::TypeArguments::kNullabilityBitsPerType = 1
staticconstexpr

Definition at line 8619 of file object.h.

◆ kNullabilityMaxTypes

constexpr intptr_t dart::TypeArguments::kNullabilityMaxTypes
staticconstexpr
Initial value:
=
static constexpr intptr_t kNullabilityBitsPerType
Definition: object.h:8619
const intptr_t kSmiBits
Definition: globals.h:24

Definition at line 8620 of file object.h.

◆ kNullableBit

constexpr intptr_t dart::TypeArguments::kNullableBit = 1
staticconstexpr

Definition at line 8623 of file object.h.


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