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

#include <object.h>

Inheritance diagram for dart::SubtypeTestCache:
dart::Object

Public Types

enum  Entries {
  kInstanceCidOrSignature = 0 , kInstanceTypeArguments = 1 , kInstantiatorTypeArguments = 2 , kFunctionTypeArguments = 3 ,
  kInstanceParentFunctionTypeArguments = 4 , kInstanceDelayedFunctionTypeArguments = 5 , kDestinationType = 6 , kTestResult = 7 ,
  kTestEntryLength = 8
}
 
- Public Types inherited from dart::Object
enum  NameVisibility { kInternalName = 0 , kScrubbedName , kUserVisibleName }
 
enum class  NameDisambiguation { kYes , kNo }
 
using UntaggedObjectType = UntaggedObject
 
using ObjectPtrType = ObjectPtr
 

Public Member Functions

intptr_t NumberOfChecks () const
 
intptr_t NumEntries () const
 
intptr_t AddCheck (const Object &instance_class_id_or_signature, const AbstractType &destination_type, const TypeArguments &instance_type_arguments, const TypeArguments &instantiator_type_arguments, const TypeArguments &function_type_arguments, const TypeArguments &instance_parent_function_type_arguments, const TypeArguments &instance_delayed_type_arguments, const Bool &test_result) const
 
void GetCheck (intptr_t ix, Object *instance_class_id_or_signature, AbstractType *destination_type, TypeArguments *instance_type_arguments, TypeArguments *instantiator_type_arguments, TypeArguments *function_type_arguments, TypeArguments *instance_parent_function_type_arguments, TypeArguments *instance_delayed_type_arguments, Bool *test_result) const
 
void GetCurrentCheck (intptr_t ix, Object *instance_class_id_or_signature, AbstractType *destination_type, TypeArguments *instance_type_arguments, TypeArguments *instantiator_type_arguments, TypeArguments *function_type_arguments, TypeArguments *instance_parent_function_type_arguments, TypeArguments *instance_delayed_type_arguments, Bool *test_result) const
 
bool GetNextCheck (intptr_t *ix, Object *instance_class_id_or_signature, AbstractType *destination_type, TypeArguments *instance_type_arguments, TypeArguments *instantiator_type_arguments, TypeArguments *function_type_arguments, TypeArguments *instance_parent_function_type_arguments, TypeArguments *instance_delayed_type_arguments, Bool *test_result) const
 
bool HasCheck (const Object &instance_class_id_or_signature, const AbstractType &destination_type, const TypeArguments &instance_type_arguments, const TypeArguments &instantiator_type_arguments, const TypeArguments &function_type_arguments, const TypeArguments &instance_parent_function_type_arguments, const TypeArguments &instance_delayed_type_arguments, intptr_t *index, Bool *result) const
 
void WriteEntryToBuffer (Zone *zone, BaseTextBuffer *buffer, intptr_t index, const char *line_prefix=nullptr) const
 
void WriteToBuffer (Zone *zone, BaseTextBuffer *buffer, const char *line_prefix=nullptr) const
 
void Reset () const
 
bool Equals (const SubtypeTestCache &other) const
 
bool IsHash () const
 
SubtypeTestCachePtr Copy (Thread *thread) const
 
ArrayPtr cache () const
 
intptr_t num_inputs () const
 
intptr_t num_occupied () const
 
bool IsOccupied (intptr_t index) 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 SubtypeTestCachePtr New (intptr_t num_inputs)
 
static intptr_t InstanceSize ()
 
static intptr_t cache_offset ()
 
static intptr_t num_inputs_offset ()
 
static intptr_t UsedInputsForType (const AbstractType &type)
 
static constexpr intptr_t MaxEntriesForCacheAllocatedFor (intptr_t count)
 
- 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 kMaxInputs = kTestResult
 
static constexpr intptr_t kMaxLinearCacheEntries = 30
 
static constexpr intptr_t kMaxLinearCacheSize
 
- Static Public Attributes inherited from dart::Object
static constexpr intptr_t kHashBits = 30
 
static const ClassId kClassId = kObjectCid
 

Friends

class Class
 
class FieldInvalidator
 
class VMSerializationRoots
 
class VMDeserializationRoots
 

Additional Inherited Members

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

Member Enumeration Documentation

◆ Entries

Enumerator
kInstanceCidOrSignature 
kInstanceTypeArguments 
kInstantiatorTypeArguments 
kFunctionTypeArguments 
kInstanceParentFunctionTypeArguments 
kInstanceDelayedFunctionTypeArguments 
kDestinationType 
kTestResult 
kTestEntryLength 

Definition at line 7659 of file object.h.

Member Function Documentation

◆ AddCheck()

intptr_t dart::SubtypeTestCache::AddCheck ( const Object instance_class_id_or_signature,
const AbstractType destination_type,
const TypeArguments instance_type_arguments,
const TypeArguments instantiator_type_arguments,
const TypeArguments function_type_arguments,
const TypeArguments instance_parent_function_type_arguments,
const TypeArguments instance_delayed_type_arguments,
const Bool test_result 
) const

Definition at line 19028 of file object.cc.

19036 {
19038 ->isolate_group()
19039 ->subtype_test_cache_mutex()
19040 ->IsOwnedByCurrentThread());
19041 ASSERT(!test_result.IsNull());
19042 ASSERT(Smi::New(kRecordCid) != instance_class_id_or_signature.ptr());
19043
19044 const intptr_t old_num = NumberOfChecks();
19045 Zone* const zone = Thread::Current()->zone();
19046 Array& data = Array::Handle(zone, cache());
19047 bool was_grown;
19048 data = EnsureCapacity(zone, data, old_num + 1, &was_grown);
19049 ASSERT(data.ptr() != Object::empty_subtype_test_cache_array().ptr());
19050
19051 const auto& loc = FindKeyOrUnused(
19052 data, num_inputs(), instance_class_id_or_signature, destination_type,
19053 instance_type_arguments, instantiator_type_arguments,
19054 function_type_arguments, instance_parent_function_type_arguments,
19055 instance_delayed_type_arguments);
19056 SubtypeTestCacheTable entries(data);
19057 const auto& entry = entries[loc.entry];
19058 if (loc.present) {
19059 if (entry.Get<kTestResult>() != test_result.ptr()) {
19060 const auto& old_result = Bool::Handle(zone, entry.Get<kTestResult>());
19061 FATAL("Existing subtype test cache entry has result %s, not %s",
19062 old_result.ToCString(), test_result.ToCString());
19063 }
19064 return loc.entry;
19065 }
19066
19067 // Set the used elements in the entry in reverse order, so that the instance
19068 // cid or signature is last, then increment the number of entries.
19069 entry.Set<kTestResult>(test_result);
19070 switch (num_inputs()) {
19071 case 7:
19072 entry.Set<kDestinationType>(destination_type);
19074 case 6:
19076 instance_delayed_type_arguments);
19078 case 5:
19080 instance_parent_function_type_arguments);
19082 case 4:
19083 entry.Set<kFunctionTypeArguments>(function_type_arguments);
19085 case 3:
19086 entry.Set<kInstantiatorTypeArguments>(instantiator_type_arguments);
19088 case 2:
19089 entry.Set<kInstanceTypeArguments>(instance_type_arguments);
19091 case 1:
19092 // If this is a new backing array, we don't need store-release barriers,
19093 // as no reader has access to the array until it is set as the backing
19094 // store (which is done with a store-release barrier).
19095 //
19096 // Otherwise, the instance cid or signature must be set last with a
19097 // store-release barrier, so concurrent readers can depend on a non-null
19098 // value meaning the rest of the entry is safe to load without barriers.
19099 if (was_grown) {
19100 entry.Set<kInstanceCidOrSignature>(instance_class_id_or_signature);
19101 } else {
19102 entry.Set<kInstanceCidOrSignature, std::memory_order_release>(
19103 instance_class_id_or_signature);
19104 }
19105 break;
19106 default:
19107 UNREACHABLE();
19108 }
19109 set_num_occupied(old_num + 1);
19110 if (was_grown) {
19111 set_cache(data);
19112 }
19113 return loc.entry;
19114}
#define UNREACHABLE()
Definition assert.h:248
static Object & Handle()
Definition object.h:407
static SmiPtr New(intptr_t value)
Definition object.h:9985
ArrayPtr cache() const
Definition object.cc:18988
intptr_t num_inputs() const
Definition object.h:7790
intptr_t NumberOfChecks() const
Definition object.cc:19004
Zone * zone() const
static Thread * Current()
Definition thread.h:361
#define ASSERT(E)
#define FATAL(error)
ArrayOfTuplesView< SubtypeTestCache::Entries, std::tuple< Object, TypeArguments, TypeArguments, TypeArguments, TypeArguments, TypeArguments, AbstractType, Bool > > SubtypeTestCacheTable
Definition object.h:13532
static int8_t data[kExtLength]
#define FALL_THROUGH
Definition globals.h:15

◆ cache()

ArrayPtr dart::SubtypeTestCache::cache ( ) const

Definition at line 18988 of file object.cc.

18988 {
18989 return untag()->cache<std::memory_order_acquire>();
18990}
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)

◆ cache_offset()

static intptr_t dart::SubtypeTestCache::cache_offset ( )
inlinestatic

Definition at line 7782 of file object.h.

7782 {
7783 return OFFSET_OF(UntaggedSubtypeTestCache, cache_);
7784 }
#define OFFSET_OF(type, field)
Definition globals.h:138

◆ Copy()

SubtypeTestCachePtr dart::SubtypeTestCache::Copy ( Thread thread) const

Definition at line 19689 of file object.cc.

19689 {
19690 ASSERT(thread->isolate_group()
19691 ->subtype_test_cache_mutex()
19692 ->IsOwnedByCurrentThread());
19693 if (IsNull()) {
19694 return SubtypeTestCache::null();
19695 }
19696 Zone* const zone = thread->zone();
19697 // STC caches are only copied on write if there are not enough unoccupied
19698 // entries to store a new one, so we need to copy the array.
19699 const auto& result =
19701 auto& entry_cache = Array::Handle(zone, cache());
19702 entry_cache = entry_cache.Copy();
19703 result.set_cache(entry_cache);
19704 result.set_num_occupied(num_occupied());
19705 return result.ptr();
19706}
static ObjectPtr null()
Definition object.h:433
bool IsNull() const
Definition object.h:363
intptr_t num_occupied() const
Definition object.h:7792
static SubtypeTestCachePtr New(intptr_t num_inputs)
Definition object.cc:18974
GAsyncResult * result

◆ Equals()

bool dart::SubtypeTestCache::Equals ( const SubtypeTestCache other) const

Definition at line 19676 of file object.cc.

19676 {
19678 ->isolate_group()
19679 ->subtype_test_cache_mutex()
19680 ->IsOwnedByCurrentThread());
19681 if (ptr() == other.ptr()) {
19682 return true;
19683 }
19684 if (num_inputs() != other.num_inputs()) return false;
19685 if (num_occupied() != other.num_occupied()) return false;
19686 return Array::Handle(cache()).Equals(Array::Handle(other.cache()));
19687}
ObjectPtr ptr() const
Definition object.h:332

◆ GetCheck()

void dart::SubtypeTestCache::GetCheck ( intptr_t  ix,
Object instance_class_id_or_signature,
AbstractType destination_type,
TypeArguments instance_type_arguments,
TypeArguments instantiator_type_arguments,
TypeArguments function_type_arguments,
TypeArguments instance_parent_function_type_arguments,
TypeArguments instance_delayed_type_arguments,
Bool test_result 
) const

Definition at line 19396 of file object.cc.

19405 {
19407 ->isolate_group()
19408 ->subtype_test_cache_mutex()
19409 ->IsOwnedByCurrentThread());
19410 GetCurrentCheck(ix, instance_class_id_or_signature, destination_type,
19411 instance_type_arguments, instantiator_type_arguments,
19412 function_type_arguments,
19413 instance_parent_function_type_arguments,
19414 instance_delayed_type_arguments, test_result);
19415}
void GetCurrentCheck(intptr_t ix, Object *instance_class_id_or_signature, AbstractType *destination_type, TypeArguments *instance_type_arguments, TypeArguments *instantiator_type_arguments, TypeArguments *function_type_arguments, TypeArguments *instance_parent_function_type_arguments, TypeArguments *instance_delayed_type_arguments, Bool *test_result) const
Definition object.cc:19417

◆ GetCurrentCheck()

void dart::SubtypeTestCache::GetCurrentCheck ( intptr_t  ix,
Object instance_class_id_or_signature,
AbstractType destination_type,
TypeArguments instance_type_arguments,
TypeArguments instantiator_type_arguments,
TypeArguments function_type_arguments,
TypeArguments instance_parent_function_type_arguments,
TypeArguments instance_delayed_type_arguments,
Bool test_result 
) const

Definition at line 19417 of file object.cc.

19426 {
19427 const Array& array = Array::Handle(cache());
19428 GetCheckFromArray(array, num_inputs(), ix, instance_class_id_or_signature,
19429 destination_type, instance_type_arguments,
19430 instantiator_type_arguments, function_type_arguments,
19431 instance_parent_function_type_arguments,
19432 instance_delayed_type_arguments, test_result);
19433}

◆ GetNextCheck()

bool dart::SubtypeTestCache::GetNextCheck ( intptr_t *  ix,
Object instance_class_id_or_signature,
AbstractType destination_type,
TypeArguments instance_type_arguments,
TypeArguments instantiator_type_arguments,
TypeArguments function_type_arguments,
TypeArguments instance_parent_function_type_arguments,
TypeArguments instance_delayed_type_arguments,
Bool test_result 
) const

Definition at line 19485 of file object.cc.

19494 {
19495 ASSERT(ix != nullptr);
19496 for (intptr_t i = *ix; i < NumEntries(); i++) {
19498 ->isolate_group()
19499 ->subtype_test_cache_mutex()
19500 ->IsOwnedByCurrentThread());
19501 if (IsOccupied(i)) {
19502 GetCurrentCheck(i, instance_class_id_or_signature, destination_type,
19503 instance_type_arguments, instantiator_type_arguments,
19504 function_type_arguments,
19505 instance_parent_function_type_arguments,
19506 instance_delayed_type_arguments, test_result);
19507 *ix = i + 1;
19508 return true;
19509 }
19510 }
19511 return false;
19512}
intptr_t NumEntries() const
Definition object.cc:19009
bool IsOccupied(intptr_t index) const
Definition object.cc:19708

◆ HasCheck()

bool dart::SubtypeTestCache::HasCheck ( const Object instance_class_id_or_signature,
const AbstractType destination_type,
const TypeArguments instance_type_arguments,
const TypeArguments instantiator_type_arguments,
const TypeArguments function_type_arguments,
const TypeArguments instance_parent_function_type_arguments,
const TypeArguments instance_delayed_type_arguments,
intptr_t *  index,
Bool result 
) const

Definition at line 19514 of file object.cc.

19523 {
19524 const auto& data = Array::Handle(cache());
19525 auto loc = FindKeyOrUnused(
19526 data, num_inputs(), instance_class_id_or_signature, destination_type,
19527 instance_type_arguments, instantiator_type_arguments,
19528 function_type_arguments, instance_parent_function_type_arguments,
19529 instance_delayed_type_arguments);
19530 if (loc.present) {
19531 if (index != nullptr) {
19532 *index = loc.entry;
19533 }
19534 if (result != nullptr) {
19535 SubtypeTestCacheTable entries(data);
19536 const auto& entry = entries[loc.entry];
19537 // A positive result from FindKeyOrUnused means that load-acquire is not
19538 // needed, as an occupied entry never changes for a given backing array.
19539 *result = entry.Get<kTestResult>();
19540 ASSERT(!result->IsNull());
19541 }
19542 }
19543 return loc.present;
19544}

◆ InstanceSize()

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

Definition at line 7778 of file object.h.

7778 {
7779 return RoundedAllocationSize(sizeof(UntaggedSubtypeTestCache));
7780 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition object.h:758

◆ IsHash()

bool dart::SubtypeTestCache::IsHash ( ) const

Definition at line 19019 of file object.cc.

19019 {
19020 if (IsNull()) return false;
19022}
static intptr_t LengthOf(const ArrayPtr array)
Definition object.h:10809
static constexpr intptr_t kMaxLinearCacheSize
Definition object.h:7883

◆ IsOccupied()

bool dart::SubtypeTestCache::IsOccupied ( intptr_t  index) const

Definition at line 19708 of file object.cc.

19708 {
19709 ASSERT(!IsNull());
19710 ASSERT(index < NumEntries());
19711 const intptr_t cache_index =
19713 NoSafepointScope no_safepoint;
19714 return cache()->untag()->element<std::memory_order_acquire>(cache_index) !=
19715 Object::null();
19716}

◆ MaxEntriesForCacheAllocatedFor()

static constexpr intptr_t dart::SubtypeTestCache::MaxEntriesForCacheAllocatedFor ( intptr_t  count)
inlinestaticconstexpr

Definition at line 7814 of file object.h.

7814 {
7815 // If the cache would be linear, just return the count unchanged.
7816 if (count <= kMaxLinearCacheEntries) return count;
7817 intptr_t allocated_entries = Utils::RoundUpToPowerOfTwo(count);
7818 if (LoadFactor(count, allocated_entries) >= kMaxLoadFactor) {
7819 allocated_entries *= 2;
7820 }
7821 const intptr_t max_entries =
7822 static_cast<intptr_t>(kMaxLoadFactor * allocated_entries);
7823 assert(LoadFactor(max_entries, allocated_entries) < kMaxLoadFactor);
7824 assert(max_entries >= count);
7825 return max_entries;
7826 }
int count
static constexpr intptr_t kMaxLinearCacheEntries
Definition object.h:7801
static constexpr uintptr_t RoundUpToPowerOfTwo(uintptr_t x)
Definition utils.h:120

◆ New()

SubtypeTestCachePtr dart::SubtypeTestCache::New ( intptr_t  num_inputs)
static

Definition at line 18974 of file object.cc.

18974 {
18976 ASSERT(num_inputs >= 1);
18978 // SubtypeTestCache objects are long living objects, allocate them in the
18979 // old generation.
18980 const auto& result =
18981 SubtypeTestCache::Handle(Object::Allocate<SubtypeTestCache>(Heap::kOld));
18982 ASSERT_EQUAL(result.num_occupied(), 0);
18983 result.untag()->num_inputs_ = num_inputs;
18984 result.set_cache(Object::empty_subtype_test_cache_array());
18985 return result.ptr();
18986}
#define ASSERT_EQUAL(expected, actual)
Definition assert.h:309
@ kOld
Definition heap.h:39
static ClassPtr subtypetestcache_class()
Definition object.h:565
static constexpr intptr_t kMaxInputs
Definition object.h:7676

◆ num_inputs()

intptr_t dart::SubtypeTestCache::num_inputs ( ) const
inline

Definition at line 7790 of file object.h.

7790{ return untag()->num_inputs_; }

◆ num_inputs_offset()

static intptr_t dart::SubtypeTestCache::num_inputs_offset ( )
inlinestatic

Definition at line 7787 of file object.h.

7787 {
7788 return OFFSET_OF(UntaggedSubtypeTestCache, num_inputs_);
7789 }

◆ num_occupied()

intptr_t dart::SubtypeTestCache::num_occupied ( ) const
inline

Definition at line 7792 of file object.h.

7792{ return untag()->num_occupied_; }

◆ NumberOfChecks()

intptr_t dart::SubtypeTestCache::NumberOfChecks ( ) const

Definition at line 19004 of file object.cc.

19004 {
19005 ASSERT(!IsNull());
19006 return num_occupied();
19007}

◆ NumEntries()

intptr_t dart::SubtypeTestCache::NumEntries ( ) const

Definition at line 19009 of file object.cc.

19009 {
19010 ASSERT(!IsNull());
19012}

◆ Reset()

void dart::SubtypeTestCache::Reset ( ) const

Definition at line 19671 of file object.cc.

19671 {
19672 set_num_occupied(0);
19673 set_cache(Object::empty_subtype_test_cache_array());
19674}

◆ UsedInputsForType()

intptr_t dart::SubtypeTestCache::UsedInputsForType ( const AbstractType type)
static

Definition at line 19718 of file object.cc.

19718 {
19719 if (type.IsType()) {
19720 if (type.IsInstantiated()) return 2;
19721 if (type.IsInstantiated(kFunctions)) return 3;
19722 return 4;
19723 }
19724 // Default to all inputs except for the destination type, which must be
19725 // statically known, otherwise this method wouldn't be called.
19726 static_assert(kDestinationType == kMaxInputs - 1,
19727 "destination type is not last input");
19728 return kMaxInputs - 1;
19729}
@ kFunctions
Definition object.h:2231

◆ WriteEntryToBuffer()

void dart::SubtypeTestCache::WriteEntryToBuffer ( Zone zone,
BaseTextBuffer buffer,
intptr_t  index,
const char *  line_prefix = nullptr 
) const

Definition at line 19546 of file object.cc.

19549 {
19551 ->isolate_group()
19552 ->subtype_test_cache_mutex()
19553 ->IsOwnedByCurrentThread());
19554 WriteCurrentEntryToBuffer(zone, buffer, index, line_prefix);
19555}
static const uint8_t buffer[]

◆ WriteToBuffer()

void dart::SubtypeTestCache::WriteToBuffer ( Zone zone,
BaseTextBuffer buffer,
const char *  line_prefix = nullptr 
) const

Definition at line 19557 of file object.cc.

19559 {
19561 ->isolate_group()
19562 ->subtype_test_cache_mutex()
19563 ->IsOwnedByCurrentThread());
19564 WriteToBufferUnlocked(zone, buffer, line_prefix);
19565}

Friends And Related Symbol Documentation

◆ Class

friend class Class
friend

Definition at line 7930 of file object.h.

◆ FieldInvalidator

friend class FieldInvalidator
friend

Definition at line 7931 of file object.h.

◆ VMDeserializationRoots

friend class VMDeserializationRoots
friend

Definition at line 7933 of file object.h.

◆ VMSerializationRoots

friend class VMSerializationRoots
friend

Definition at line 7932 of file object.h.

Member Data Documentation

◆ kMaxInputs

constexpr intptr_t dart::SubtypeTestCache::kMaxInputs = kTestResult
staticconstexpr

Definition at line 7676 of file object.h.

◆ kMaxLinearCacheEntries

constexpr intptr_t dart::SubtypeTestCache::kMaxLinearCacheEntries = 30
staticconstexpr

Definition at line 7801 of file object.h.

◆ kMaxLinearCacheSize

constexpr intptr_t dart::SubtypeTestCache::kMaxLinearCacheSize
staticconstexpr
Initial value:

Definition at line 7883 of file object.h.


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