Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
 
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 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 = 2
 
static constexpr intptr_t kNullabilityMaxTypes
 
static constexpr intptr_t kNonNullableBits = 0
 
static constexpr intptr_t kNullableBits = 3
 
static constexpr intptr_t kLegacyBits = 2
 
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 8546 of file object.h.

Member Function Documentation

◆ Canonicalize()

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

Definition at line 7761 of file object.cc.

7761 {
7762 if (IsNull() || IsCanonical()) {
7763 ASSERT(IsOld());
7764 return this->ptr();
7765 }
7766 const intptr_t num_types = Length();
7767 if (num_types == 0) {
7768 return TypeArguments::empty_type_arguments().ptr();
7769 } else if (IsRaw(0, num_types)) {
7770 return TypeArguments::null();
7771 }
7772 Zone* zone = thread->zone();
7773 auto isolate_group = thread->isolate_group();
7774 ObjectStore* object_store = isolate_group->object_store();
7775 TypeArguments& result = TypeArguments::Handle(zone);
7776 {
7777 SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
7779 object_store->canonical_type_arguments());
7780 result ^= table.GetOrNull(CanonicalTypeArgumentsKey(*this));
7781 object_store->set_canonical_type_arguments(table.Release());
7782 }
7783 if (result.IsNull()) {
7784 // Canonicalize each type argument.
7785 AbstractType& type_arg = AbstractType::Handle(zone);
7786 GrowableHandlePtrArray<const AbstractType> canonicalized_types(zone,
7787 num_types);
7788 for (intptr_t i = 0; i < num_types; i++) {
7789 type_arg = TypeAt(i);
7790 type_arg = type_arg.Canonicalize(thread);
7791 canonicalized_types.Add(type_arg);
7792 }
7793 SafepointMutexLocker ml(isolate_group->type_canonicalization_mutex());
7795 object_store->canonical_type_arguments());
7796 // Since we canonicalized some type arguments above we need to lookup
7797 // in the table again to make sure we don't already have an equivalent
7798 // canonical entry.
7799 result ^= table.GetOrNull(CanonicalTypeArgumentsKey(*this));
7800 if (result.IsNull()) {
7801 for (intptr_t i = 0; i < num_types; i++) {
7802 SetTypeAt(i, canonicalized_types.At(i));
7803 }
7804 // Make sure we have an old space object and add it to the table.
7805 if (this->IsNew()) {
7806 result ^= Object::Clone(*this, Heap::kOld);
7807 } else {
7808 result = this->ptr();
7809 }
7810 ASSERT(result.IsOld());
7811 result.ComputeNullability();
7812 result.SetCanonical(); // Mark object as being canonical.
7813 // Now add this TypeArgument into the canonical list of type arguments.
7814 bool present = table.Insert(result);
7815 ASSERT(!present);
7816 }
7817 object_store->set_canonical_type_arguments(table.Release());
7818 }
7819 ASSERT(result.Equals(*this));
7820 ASSERT(!result.IsNull());
7821 ASSERT(result.IsTypeArguments());
7822 ASSERT(result.IsCanonical());
7823 return result.ptr();
7824}
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:2960
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:7352
void SetTypeAt(intptr_t index, const AbstractType &value) const
Definition object.cc:7381
bool IsRaw(intptr_t from_index, intptr_t len) const
Definition object.h:8620
friend class AbstractType
Definition object.h:9013
AbstractTypePtr TypeAt(intptr_t index) const
Definition object.cc:7366
#define ASSERT(E)
GAsyncResult * result
UnorderedHashSet< CanonicalTypeArgumentsTraits > CanonicalTypeArgumentsSet

◆ CanonicalizeHash()

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

Reimplemented from dart::Instance.

Definition at line 8978 of file object.h.

8978 {
8979 // Hash() is not stable until finalization is done.
8980 return 0;
8981 }

◆ CanonicalizeLocked()

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

Reimplemented from dart::Instance.

Definition at line 8711 of file object.h.

8711 {
8712 return Canonicalize(thread);
8713 }
unibrow::Mapping< unibrow::Ecma262Canonicalize > Canonicalize

◆ CanShareFunctionTypeArguments()

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

Definition at line 7530 of file object.cc.

7532 {
7534 if (with_runtime_check != nullptr) {
7535 *with_runtime_check = false;
7536 }
7537 const intptr_t num_type_args = Length();
7538 const intptr_t num_parent_type_args = function.NumParentTypeArguments();
7539 const intptr_t num_function_type_params = function.NumTypeParameters();
7540 const intptr_t num_function_type_args =
7541 num_parent_type_args + num_function_type_params;
7542 if (num_type_args > num_function_type_args) {
7543 // This vector cannot be a prefix of a shorter vector.
7544 return false;
7545 }
7546 AbstractType& type_arg = AbstractType::Handle();
7547 for (intptr_t i = 0; i < num_type_args; i++) {
7548 type_arg = TypeAt(i);
7549 if (!type_arg.IsTypeParameter()) {
7550 return false;
7551 }
7552 const TypeParameter& type_param = TypeParameter::Cast(type_arg);
7553 ASSERT(type_param.IsFinalized());
7554 if ((type_param.index() != i) || !type_param.IsFunctionTypeParameter()) {
7555 return false;
7556 }
7557 // Instantiating nullable and legacy type parameters may change nullability
7558 // of a type, so type arguments vector containing such type parameters
7559 // cannot be substituted with the enclosing function type arguments, unless
7560 // we check at runtime the nullability of the first 1 or 2 type arguments of
7561 // the enclosing function type arguments.
7562 if (type_param.IsNullable() || type_param.IsLegacy()) {
7563 if (with_runtime_check == nullptr || i >= kNullabilityMaxTypes) {
7564 return false;
7565 }
7566 *with_runtime_check = true;
7567 }
7568 }
7569 return true;
7570}
bool IsInstantiated(Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
Definition object.h:8681
static constexpr intptr_t kNullabilityMaxTypes
Definition object.h:8593
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 7442 of file object.cc.

7444 {
7446 if (with_runtime_check != nullptr) {
7447 *with_runtime_check = false;
7448 }
7449 const intptr_t num_type_args = Length();
7450 const intptr_t num_instantiator_type_args =
7451 instantiator_class.NumTypeArguments();
7452 if (num_type_args > num_instantiator_type_args) {
7453 // This vector cannot be a prefix of a shorter vector.
7454 return false;
7455 }
7456 const intptr_t num_instantiator_type_params =
7457 instantiator_class.NumTypeParameters();
7458 const intptr_t first_type_param_offset =
7459 num_instantiator_type_args - num_instantiator_type_params;
7460 // At compile time, the type argument vector of the instantiator consists of
7461 // the type argument vector of its super type, which may refer to the type
7462 // parameters of the instantiator class, followed by (or overlapping partially
7463 // or fully with) the type parameters of the instantiator class in declaration
7464 // order.
7465 // In other words, the only variables are the type parameters of the
7466 // instantiator class.
7467 // This uninstantiated type argument vector is also expressed in terms of the
7468 // type parameters of the instantiator class. Therefore, in order to be a
7469 // prefix once instantiated at runtime, every one of its type argument must be
7470 // equal to the type argument of the instantiator vector at the same index.
7471
7472 // As a first requirement, the last num_instantiator_type_params type
7473 // arguments of this type argument vector must refer to the corresponding type
7474 // parameters of the instantiator class.
7475 AbstractType& type_arg = AbstractType::Handle();
7476 for (intptr_t i = first_type_param_offset; i < num_type_args; i++) {
7477 type_arg = TypeAt(i);
7478 if (!type_arg.IsTypeParameter()) {
7479 return false;
7480 }
7481 const TypeParameter& type_param = TypeParameter::Cast(type_arg);
7482 ASSERT(type_param.IsFinalized());
7483 if ((type_param.index() != i) || type_param.IsFunctionTypeParameter()) {
7484 return false;
7485 }
7486 // Instantiating nullable and legacy type parameters may change nullability
7487 // of a type, so type arguments vector containing such type parameters
7488 // cannot be substituted with instantiator type arguments, unless we check
7489 // at runtime the nullability of the first 1 or 2 type arguments of the
7490 // instantiator.
7491 // Note that the presence of non-overlapping super type arguments (i.e.
7492 // first_type_param_offset > 0) will prevent this optimization.
7493 if (type_param.IsNullable() || type_param.IsLegacy()) {
7494 if (with_runtime_check == nullptr || i >= kNullabilityMaxTypes) {
7495 return false;
7496 }
7497 *with_runtime_check = true;
7498 }
7499 }
7500 // As a second requirement, the type arguments corresponding to the super type
7501 // must be identical. Overlapping ones have already been checked starting at
7502 // first_type_param_offset.
7503 if (first_type_param_offset == 0) {
7504 return true;
7505 }
7506 Type& super_type = Type::Handle(instantiator_class.super_type());
7507 const TypeArguments& super_type_args =
7508 TypeArguments::Handle(super_type.GetInstanceTypeArguments(
7509 Thread::Current(), /*canonicalize=*/false));
7510 if (super_type_args.IsNull()) {
7512 return false;
7513 }
7514 AbstractType& super_type_arg = AbstractType::Handle();
7515 for (intptr_t i = 0; (i < first_type_param_offset) && (i < num_type_args);
7516 i++) {
7517 type_arg = TypeAt(i);
7518 super_type_arg = super_type_args.TypeAt(i);
7519 if (!type_arg.Equals(super_type_arg)) {
7521 return false;
7522 }
7523 }
7524 return true;
7525}
static Thread * Current()
Definition thread.h:361
bool IsUninstantiatedIdentity() const
Definition object.cc:7410

◆ ConcatenateTypeParameters()

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

Definition at line 6885 of file object.cc.

6887 {
6888 ASSERT(!IsNull() && !other.IsNull());
6889 const intptr_t this_len = Length();
6890 const intptr_t other_len = other.Length();
6891 const auto& result = TypeArguments::Handle(
6892 zone, TypeArguments::New(this_len + other_len, Heap::kNew));
6893 auto& type = AbstractType::Handle(zone);
6894 for (intptr_t i = 0; i < this_len; ++i) {
6895 type = TypeAt(i);
6896 result.SetTypeAt(i, type);
6897 }
6898 for (intptr_t i = 0; i < other_len; ++i) {
6899 type = other.TypeAt(i);
6900 result.SetTypeAt(this_len + i, type);
6901 }
6902 return result.ptr();
6903}
@ kNew
Definition heap.h:38
static TypeArgumentsPtr New(intptr_t len, Heap::Space space=Heap::kOld)
Definition object.cc:7733

◆ EnumerateURIs()

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

Definition at line 7877 of file object.cc.

7877 {
7878 if (IsNull()) {
7879 return;
7880 }
7881 Thread* thread = Thread::Current();
7882 Zone* zone = thread->zone();
7884 const intptr_t num_types = Length();
7885 for (intptr_t i = 0; i < num_types; i++) {
7886 type = TypeAt(i);
7887 type.EnumerateURIs(uris);
7888 }
7889}

◆ Equals()

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

Definition at line 8660 of file object.h.

8660 {
8661 return IsSubvectorEquivalent(other, 0, IsNull() ? 0 : Length(),
8663 }
bool IsSubvectorEquivalent(const TypeArguments &other, intptr_t from_index, intptr_t len, TypeEquality kind, FunctionTypeMapping *function_type_equivalence=nullptr) const
Definition object.cc:6978
TypeEquality
Definition object.h:1120

◆ FromInstanceTypeArguments()

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

Definition at line 7826 of file object.cc.

7828 {
7829 if (IsNull()) {
7830 return ptr();
7831 }
7832 const intptr_t num_type_arguments = cls.NumTypeArguments();
7833 const intptr_t num_type_parameters = cls.NumTypeParameters(thread);
7834 ASSERT(Length() >= num_type_arguments);
7835 if (Length() == num_type_parameters) {
7836 return ptr();
7837 }
7838 if (num_type_parameters == 0) {
7839 return TypeArguments::null();
7840 }
7841 Zone* zone = thread->zone();
7842 const auto& args =
7843 TypeArguments::Handle(zone, TypeArguments::New(num_type_parameters));
7844 const intptr_t offset = num_type_arguments - num_type_parameters;
7845 auto& type = AbstractType::Handle(zone);
7846 for (intptr_t i = 0; i < num_type_parameters; ++i) {
7847 type = TypeAt(offset + i);
7848 args.SetTypeAt(i, type);
7849 }
7850 return args.ptr();
7851}
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Point offset

◆ GetInstantiationMode()

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

Definition at line 6905 of file object.cc.

6907 {
6908 if (IsNull() || IsInstantiated()) {
6910 }
6911 if (function != nullptr) {
6914 }
6915 if (cls == nullptr) {
6916 cls = &Class::Handle(zone, function->Owner());
6917 }
6918 }
6919 if (cls != nullptr) {
6922 }
6923 }
6925}
bool CanShareFunctionTypeArguments(const Function &function, bool *with_runtime_check=nullptr) const
Definition object.cc:7530
bool CanShareInstantiatorTypeArguments(const Class &instantiator_class, bool *with_runtime_check=nullptr) const
Definition object.cc:7442

◆ HasCount()

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

Definition at line 7345 of file object.cc.

7345 {
7346 if (IsNull()) {
7347 return true;
7348 }
7349 return Length() == count;
7350}
int count

◆ Hash()

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

Definition at line 13370 of file object.h.

13370 {
13371 if (IsNull()) return kAllDynamicHash;
13372 intptr_t result = Smi::Value(untag()->hash());
13373 if (result != 0) {
13374 return result;
13375 }
13376 return ComputeHash();
13377}
static uint32_t hash(const SkShaderBase::GradientInfo &v)
intptr_t Value() const
Definition object.h:9969
static constexpr intptr_t kAllDynamicHash
Definition object.h:8549
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)

◆ hash_offset()

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

Definition at line 8984 of file object.h.

8984 {
8985 return OFFSET_OF(UntaggedTypeArguments, hash_);
8986 }
#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 6836 of file object.cc.

6836 {
6837 if (IsNull()) return kAllDynamicHash;
6838 if (IsRaw(from_index, len)) return kAllDynamicHash;
6839 uint32_t result = 0;
6841 for (intptr_t i = 0; i < len; i++) {
6842 type = TypeAt(from_index + i);
6843 ASSERT(!type.IsNull());
6844 result = CombineHashes(result, type.Hash());
6845 }
6847 return result;
6848}
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 7327 of file object.cc.

7327 {
7328 return instantiations() != Cache::EmptyStorage().ptr();
7329}
static const Array & EmptyStorage()
Definition object.h:8865

◆ InstanceSize() [1/2]

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

Definition at line 8962 of file object.h.

8962 {
8963 ASSERT(sizeof(UntaggedTypeArguments) ==
8964 OFFSET_OF_RETURNED_VALUE(UntaggedTypeArguments, types));
8965 return 0;
8966 }
#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 8968 of file object.h.

8968 {
8969 // Ensure that the types() is not adding to the object size, which includes
8970 // 4 fields: instantiations_, length_, hash_, and nullability_.
8971 ASSERT(sizeof(UntaggedTypeArguments) ==
8972 (sizeof(UntaggedObject) + (kNumFields * kCompressedWordSize)));
8973 ASSERT(0 <= len && len <= kMaxElements);
8974 return RoundedAllocationSize(sizeof(UntaggedTypeArguments) +
8975 (len * kBytesPerElement));
8976 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition object.h:758
static constexpr intptr_t kBytesPerElement
Definition object.h:8959
static constexpr intptr_t kMaxElements
Definition object.h:8960
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 7678 of file object.cc.

7680 {
7681 auto thread = Thread::Current();
7682 auto zone = thread->zone();
7683 SafepointMutexLocker ml(
7684 thread->isolate_group()->type_arguments_canonicalization_mutex());
7685
7687 ASSERT(instantiator_type_arguments.IsNull() ||
7688 instantiator_type_arguments.IsCanonical());
7689 ASSERT(function_type_arguments.IsNull() ||
7690 function_type_arguments.IsCanonical());
7691 // Lookup instantiators and if found, return instantiated result.
7692 Cache cache(zone, *this);
7693 auto const loc = cache.FindKeyOrUnused(instantiator_type_arguments,
7694 function_type_arguments);
7695 if (loc.present) {
7696#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
7698 TextBuffer buffer(1024);
7699 buffer.Printf("for\n");
7700 buffer.Printf(" * uninstantiated type arguments %s\n", ToCString());
7701 buffer.Printf(" * instantiation type arguments: %s (hash: %" Pu ")\n",
7702 instantiator_type_arguments.ToCString(),
7703 instantiator_type_arguments.Hash());
7704 buffer.Printf(" * function type arguments: %s (hash: %" Pu ")\n",
7705 function_type_arguments.ToCString(),
7706 function_type_arguments.Hash());
7707 buffer.Printf(" * number of occupied entries in cache: %" Pd "\n",
7708 cache.NumOccupied());
7709 buffer.Printf(" * number of total entries in cache: %" Pd "\n",
7710 cache.NumEntries());
7711 buffer.Printf("expected to find entry %" Pd
7712 " of cache in stub, but reached runtime",
7713 loc.entry);
7714 FATAL("%s", buffer.buffer());
7715 }
7716#endif
7717 return cache.Retrieve(loc.entry);
7718 }
7719 // Cache lookup failed. Instantiate the type arguments.
7720 TypeArguments& result = TypeArguments::Handle(zone);
7721 result = InstantiateFrom(instantiator_type_arguments, function_type_arguments,
7723 // Canonicalize type arguments.
7724 result = result.Canonicalize(thread);
7725 // InstantiateAndCanonicalizeFrom is not reentrant. It cannot have been called
7726 // indirectly, so the prior_instantiations array cannot have grown.
7727 ASSERT(cache.data_.ptr() == instantiations());
7728 cache.AddEntry(loc.entry, instantiator_type_arguments,
7729 function_type_arguments, result);
7730 return result.ptr();
7731}
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:7598
#define FATAL(error)
static const uint8_t buffer[]
@ kAllFree
Definition object.h:2920
bool TESTING_runtime_fail_on_existing_cache_entry
Definition object.cc:7675
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
#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 7598 of file object.cc.

7604 {
7606 if ((instantiator_type_arguments.IsNull() ||
7607 instantiator_type_arguments.Length() == Length()) &&
7609 return instantiator_type_arguments.ptr();
7610 }
7611 const intptr_t num_types = Length();
7612 TypeArguments& instantiated_array =
7613 TypeArguments::Handle(TypeArguments::New(num_types, space));
7615 for (intptr_t i = 0; i < num_types; i++) {
7616 type = TypeAt(i);
7617 // If this type argument T is null, the type A containing T in its flattened
7618 // type argument vector V is recursive and is still being finalized.
7619 // T is the type argument of a super type of A. T is being instantiated
7620 // during finalization of V, which is also the instantiator. T depends
7621 // solely on the type parameters of A and will be replaced by a non-null
7622 // type before A is marked as finalized.
7623 if (!type.IsNull() && !type.IsInstantiated()) {
7624 type = type.InstantiateFrom(
7625 instantiator_type_arguments, function_type_arguments,
7626 num_free_fun_type_params, space, function_type_mapping,
7627 num_parent_type_args_adjustment);
7628 // A returned null type indicates a failed instantiation in dead code that
7629 // must be propagated up to the caller, the optimizing compiler.
7630 if (type.IsNull()) {
7631 return Object::empty_type_arguments().ptr();
7632 }
7633 }
7634 instantiated_array.SetTypeAt(i, type);
7635 }
7636 return instantiated_array.ptr();
7637}

◆ instantiations_offset()

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

Definition at line 8955 of file object.h.

8955 {
8956 return OFFSET_OF(UntaggedTypeArguments, instantiations_);
8957 }

◆ IsEquivalent()

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

Definition at line 8665 of file object.h.

8668 {
8669 // Make a null vector a vector of dynamic as long as the other vector.
8670 return IsSubvectorEquivalent(other, 0, IsNull() ? other.Length() : Length(),
8671 kind, function_type_equivalence);
8672 }

◆ IsFinalized()

bool dart::TypeArguments::IsFinalized ( ) const

Definition at line 7585 of file object.cc.

7585 {
7586 ASSERT(!IsNull());
7588 const intptr_t num_types = Length();
7589 for (intptr_t i = 0; i < num_types; i++) {
7590 type = TypeAt(i);
7591 if (!type.IsFinalized()) {
7592 return false;
7593 }
7594 }
7595 return true;
7596}

◆ IsInstantiated()

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

Definition at line 8681 of file object.h.

8682 {
8683 return IsSubvectorInstantiated(0, Length(), genericity,
8684 num_free_fun_type_params);
8685 }
bool IsSubvectorInstantiated(intptr_t from_index, intptr_t len, Genericity genericity=kAny, intptr_t num_free_fun_type_params=kAllFree) const
Definition object.cc:7387

◆ IsRaw()

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

Definition at line 8620 of file object.h.

8620 {
8621 return IsDynamicTypes(false, from_index, len);
8622 }

◆ IsRawWhenInstantiatedFromRaw()

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

Definition at line 8630 of file object.h.

8630 {
8631 return IsDynamicTypes(true, 0, len);
8632 }

◆ 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 6978 of file object.cc.

6983 {
6984 if (this->ptr() == other.ptr()) {
6985 return true;
6986 }
6987 if (kind == TypeEquality::kCanonical) {
6988 if (IsNull() || other.IsNull()) {
6989 return false;
6990 }
6991 if (Length() != other.Length()) {
6992 return false;
6993 }
6994 }
6996 AbstractType& other_type = AbstractType::Handle();
6997 for (intptr_t i = from_index; i < from_index + len; i++) {
6998 type = IsNull() ? Type::DynamicType() : TypeAt(i);
6999 ASSERT(!type.IsNull());
7000 other_type = other.IsNull() ? Type::DynamicType() : other.TypeAt(i);
7001 ASSERT(!other_type.IsNull());
7002 if (!type.IsEquivalent(other_type, kind, function_type_equivalence)) {
7003 return false;
7004 }
7005 }
7006 return true;
7007}
static TypePtr DynamicType()
Definition object.cc:21866

◆ 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 7387 of file object.cc.

7391 {
7392 ASSERT(!IsNull());
7394 for (intptr_t i = 0; i < len; i++) {
7395 type = TypeAt(from_index + i);
7396 // If this type argument T is null, the type A containing T in its flattened
7397 // type argument vector V is recursive and is still being finalized.
7398 // T is the type argument of a super type of A. T is being instantiated
7399 // during finalization of V, which is also the instantiator. T depends
7400 // solely on the type parameters of A and will be replaced by a non-null
7401 // type before A is marked as finalized.
7402 if (!type.IsNull() &&
7403 !type.IsInstantiated(genericity, num_free_fun_type_params)) {
7404 return false;
7405 }
7406 }
7407 return true;
7408}

◆ IsUninstantiatedIdentity()

bool dart::TypeArguments::IsUninstantiatedIdentity ( ) const

Definition at line 7410 of file object.cc.

7410 {
7412 const intptr_t num_types = Length();
7413 for (intptr_t i = 0; i < num_types; i++) {
7414 type = TypeAt(i);
7415 if (type.IsNull()) {
7416 return false; // Still unfinalized, too early to tell.
7417 }
7418 if (!type.IsTypeParameter()) {
7419 return false;
7420 }
7421 const TypeParameter& type_param = TypeParameter::Cast(type);
7422 ASSERT(type_param.IsFinalized());
7423 if ((type_param.index() != i) || type_param.IsFunctionTypeParameter()) {
7424 return false;
7425 }
7426 // Instantiating nullable and legacy type parameters may change
7427 // nullability of a type, so type arguments vector containing such type
7428 // parameters cannot be substituted with instantiator type arguments.
7429 if (type_param.IsNullable() || type_param.IsLegacy()) {
7430 return false;
7431 }
7432 }
7433 return true;
7434 // Note that it is not necessary to verify at runtime that the instantiator
7435 // type vector is long enough, since this uninstantiated vector contains as
7436 // many different type parameters as it is long.
7437}

◆ Length()

intptr_t dart::TypeArguments::Length ( ) const

Definition at line 7352 of file object.cc.

7352 {
7353 if (IsNull()) {
7354 return 0;
7355 }
7356 return Smi::Value(untag()->length());
7357}
size_t length

◆ length_offset()

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

Definition at line 8554 of file object.h.

8554 {
8555 return OFFSET_OF(UntaggedTypeArguments, length_);
8556 }

◆ Name()

StringPtr dart::TypeArguments::Name ( ) const

Definition at line 6927 of file object.cc.

6927 {
6928 Thread* thread = Thread::Current();
6929 ZoneTextBuffer printer(thread->zone());
6930 PrintSubvectorName(0, Length(), kInternalName, &printer);
6931 return Symbols::New(thread, printer.buffer());
6932}
@ kInternalName
Definition object.h:622
static StringPtr New(Thread *thread, const char *cstr)
Definition symbols.h:722
void PrintSubvectorName(intptr_t from_index, intptr_t len, NameVisibility name_visibility, BaseTextBuffer *printer) const
Definition object.cc:6941

◆ New()

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

Definition at line 7733 of file object.cc.

7733 {
7734 if (len < 0 || len > kMaxElements) {
7735 // This should be caught before we reach here.
7736 FATAL("Fatal error in TypeArguments::New: invalid len %" Pd "\n", len);
7737 }
7738 TypeArguments& result = TypeArguments::Handle();
7739 {
7740 auto raw = Object::Allocate<TypeArguments>(space, len);
7741 NoSafepointScope no_safepoint;
7742 result = raw;
7743 // Length must be set before we start storing into the array.
7744 result.SetLength(len);
7745 result.SetHash(0);
7746 result.set_nullability(0);
7747 }
7748 // The array used as storage for an empty linear cache should be initialized.
7750 result.set_instantiations(Cache::EmptyStorage());
7751 return result.ptr();
7752}

◆ nullability()

intptr_t dart::TypeArguments::nullability ( ) const

Definition at line 7359 of file object.cc.

7359 {
7360 if (IsNull()) {
7361 return 0;
7362 }
7363 return Smi::Value(untag()->nullability());
7364}
intptr_t nullability() const
Definition object.cc:7359

◆ nullability_offset()

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

Definition at line 8599 of file object.h.

8599 {
8600 return OFFSET_OF(UntaggedTypeArguments, nullability_);
8601 }

◆ Prepend()

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

Definition at line 6858 of file object.cc.

6861 {
6862 if (other_length == 0) {
6864 return ptr();
6865 } else if (other_length == total_length) {
6866 ASSERT(other.IsCanonical());
6867 return other.ptr();
6868 } else if (IsNull() && other.IsNull()) {
6869 return TypeArguments::null();
6870 }
6871 const TypeArguments& result =
6874 for (intptr_t i = 0; i < other_length; i++) {
6875 type = other.IsNull() ? Type::DynamicType() : other.TypeAt(i);
6876 result.SetTypeAt(i, type);
6877 }
6878 for (intptr_t i = other_length; i < total_length; i++) {
6879 type = IsNull() ? Type::DynamicType() : TypeAt(i - other_length);
6880 result.SetTypeAt(i, type);
6881 }
6882 return result.Canonicalize(Thread::Current());
6883}

◆ PrintSubvectorName()

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

Definition at line 6941 of file object.cc.

6944 {
6945 printer->AddString("<");
6947 for (intptr_t i = 0; i < len; i++) {
6948 if (from_index + i < Length()) {
6949 type = TypeAt(from_index + i);
6950 if (type.IsNull()) {
6951 printer->AddString("null"); // Unfinalized vector.
6952 } else {
6953 type.PrintName(name_visibility, printer);
6954 }
6955 } else {
6956 printer->AddString("dynamic");
6957 }
6958 if (i < len - 1) {
6959 printer->AddString(", ");
6960 }
6961 }
6962 printer->AddString(">");
6963}

◆ PrintTo()

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

Definition at line 6965 of file object.cc.

6965 {
6966 buffer->AddString("TypeArguments: ");
6967 if (IsNull()) {
6968 return buffer->AddString("null");
6969 }
6970 buffer->Printf("(H%" Px ")", Smi::Value(untag()->hash()));
6971 auto& type_at = AbstractType::Handle();
6972 for (intptr_t i = 0; i < Length(); i++) {
6973 type_at = TypeAt(i);
6974 buffer->Printf(" [%s]", type_at.IsNull() ? "null" : type_at.ToCString());
6975 }
6976}
#define Px
Definition globals.h:410

◆ SetTypeAt()

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

Definition at line 7381 of file object.cc.

7381 {
7382 ASSERT(!IsCanonical());
7383 ASSERT((index >= 0) && (index < Length()));
7384 return untag()->set_element(index, value.ptr());
7385}
uint8_t value

◆ ToInstantiatorTypeArguments()

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

Definition at line 7853 of file object.cc.

7855 {
7856 if (IsNull()) {
7857 return ptr();
7858 }
7859 const intptr_t num_type_arguments = cls.NumTypeArguments();
7860 const intptr_t num_type_parameters = cls.NumTypeParameters(thread);
7861 ASSERT(Length() == num_type_parameters);
7862 if (num_type_arguments == num_type_parameters) {
7863 return ptr();
7864 }
7865 Zone* zone = thread->zone();
7866 const auto& args =
7867 TypeArguments::Handle(zone, TypeArguments::New(num_type_arguments));
7868 const intptr_t offset = num_type_arguments - num_type_parameters;
7869 auto& type = AbstractType::Handle(zone);
7870 for (intptr_t i = 0; i < num_type_parameters; ++i) {
7871 type = TypeAt(i);
7872 args.SetTypeAt(offset + i, type);
7873 }
7874 return args.ptr();
7875}

◆ TruncatedTo()

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

Definition at line 7572 of file object.cc.

7572 {
7573 Thread* thread = Thread::Current();
7574 Zone* zone = thread->zone();
7575 const TypeArguments& result =
7578 for (intptr_t i = 0; i < length; i++) {
7579 type = TypeAt(i);
7580 result.SetTypeAt(i, type);
7581 }
7582 return result.Canonicalize(thread);
7583}

◆ type_at_offset()

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

Definition at line 8563 of file object.h.

8563 {
8564 return types_offset() + index * kCompressedWordSize;
8565 }
static intptr_t types_offset()
Definition object.h:8560

◆ TypeAt()

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

Definition at line 7366 of file object.cc.

7366 {
7367 ASSERT(!IsNull());
7368 ASSERT((index >= 0) && (index < Length()));
7369 return untag()->element(index);
7370}

◆ TypeAtNullSafe()

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

Definition at line 7372 of file object.cc.

7372 {
7373 if (IsNull()) {
7374 // null vector represents infinite list of dynamics
7375 return Type::dynamic_type().ptr();
7376 }
7377 ASSERT((index >= 0) && (index < Length()));
7378 return TypeAt(index);
7379}

◆ types_offset()

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

Definition at line 8560 of file object.h.

8560 {
8561 return OFFSET_OF_RETURNED_VALUE(UntaggedTypeArguments, types);
8562 }

◆ 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 7639 of file object.cc.

7643 {
7644 Zone* zone = Thread::Current()->zone();
7645 TypeArguments* updated_args = nullptr;
7647 AbstractType& updated = AbstractType::Handle(zone);
7648 for (intptr_t i = 0, n = Length(); i < n; ++i) {
7649 type = TypeAt(i);
7650 updated = type.UpdateFunctionTypes(num_parent_type_args_adjustment,
7651 num_free_fun_type_params, space,
7652 function_type_mapping);
7653 if (type.ptr() != updated.ptr()) {
7654 if (updated_args == nullptr) {
7655 updated_args =
7656 &TypeArguments::Handle(zone, TypeArguments::New(n, space));
7657 for (intptr_t j = 0; j < i; ++j) {
7658 type = TypeAt(j);
7659 updated_args->SetTypeAt(j, type);
7660 }
7661 }
7662 }
7663 if (updated_args != nullptr) {
7664 updated_args->SetTypeAt(i, updated);
7665 }
7666 }
7667 return (updated_args != nullptr) ? updated_args->ptr() : ptr();
7668}
Zone * zone() const

◆ UserVisibleName()

StringPtr dart::TypeArguments::UserVisibleName ( ) const

Definition at line 6934 of file object.cc.

6934 {
6935 Thread* thread = Thread::Current();
6936 ZoneTextBuffer printer(thread->zone());
6938 return Symbols::New(thread, printer.buffer());
6939}
@ kUserVisibleName
Definition object.h:645

Friends And Related Symbol Documentation

◆ AbstractType

friend class AbstractType
friend

Definition at line 9013 of file object.h.

◆ Class

friend class Class
friend

Definition at line 9014 of file object.h.

◆ ClearTypeHashVisitor

friend class ClearTypeHashVisitor
friend

Definition at line 9015 of file object.h.

◆ Object

friend class Object
friend

Definition at line 9016 of file object.h.

Member Data Documentation

◆ kAllDynamicHash

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

Definition at line 8549 of file object.h.

◆ kBytesPerElement

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

Definition at line 8959 of file object.h.

◆ kLegacyBits

constexpr intptr_t dart::TypeArguments::kLegacyBits = 2
staticconstexpr

Definition at line 8597 of file object.h.

◆ kMaxElements

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

Definition at line 8960 of file object.h.

◆ kNonNullableBits

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

Definition at line 8595 of file object.h.

◆ kNullabilityBitsPerType

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

Definition at line 8592 of file object.h.

◆ kNullabilityMaxTypes

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

Definition at line 8593 of file object.h.

◆ kNullableBits

constexpr intptr_t dart::TypeArguments::kNullableBits = 3
staticconstexpr

Definition at line 8596 of file object.h.


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