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::ICData Class Reference

#include <object.h>

Inheritance diagram for dart::ICData:
dart::CallSiteData dart::Object

Public Types

enum  DeoptReasonId
 
enum  DeoptFlags { kHoisted = 1 << 0 , kGeneralized = 1 << 1 }
 
enum  RebindRule { kNumRebindRules }
 
enum  { kCachedICDataZeroArgTestedWithoutExactnessTrackingIdx = 0 , kCachedICDataMaxArgsTestedWithoutExactnessTracking = 2 , kCachedICDataOneArgWithExactnessTrackingIdx , kCachedICDataArrayCount = kCachedICDataOneArgWithExactnessTrackingIdx + 1 }
 
- 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

FunctionPtr Owner () const
 
ICDataPtr Original () const
 
void SetOriginal (const ICData &value) const
 
bool IsOriginal () const
 
intptr_t NumArgsTested () const
 
intptr_t deopt_id () const
 
bool IsImmutable () const
 
AbstractTypePtr receivers_static_type () const
 
bool is_tracking_exactness () const
 
bool HasDeoptReasons () const
 
uint32_t DeoptReasons () const
 
void SetDeoptReasons (uint32_t reasons) const
 
bool HasDeoptReason (ICData::DeoptReasonId reason) const
 
void AddDeoptReason (ICData::DeoptReasonId reason) const
 
RebindRule rebind_rule () const
 
void set_is_megamorphic (bool value) const
 
intptr_t Length () const
 
intptr_t NumberOfChecks () const
 
intptr_t NumberOfUsedChecks () const
 
bool NumberOfChecksIs (intptr_t n) const
 
bool IsValidEntryIndex (intptr_t index) const
 
void Clear (const CallSiteResetter &proof_of_reload) const
 
void TruncateTo (intptr_t num_checks, const CallSiteResetter &proof_of_reload) const
 
void ClearCountAt (intptr_t index, const CallSiteResetter &proof_of_reload) const
 
void ClearAndSetStaticTarget (const Function &func, const CallSiteResetter &proof_of_reload) const
 
void DebugDump () const
 
void EnsureHasCheck (const GrowableArray< intptr_t > &class_ids, const Function &target, intptr_t count=1) const
 
void AddCheck (const GrowableArray< intptr_t > &class_ids, const Function &target, intptr_t count=1) const
 
StaticTypeExactnessState GetExactnessAt (intptr_t count) const
 
void EnsureHasReceiverCheck (intptr_t receiver_class_id, const Function &target, intptr_t count=1, StaticTypeExactnessState exactness=StaticTypeExactnessState::NotTracking()) const
 
void AddReceiverCheck (intptr_t receiver_class_id, const Function &target, intptr_t count=1, StaticTypeExactnessState exactness=StaticTypeExactnessState::NotTracking()) const
 
void GetCheckAt (intptr_t index, GrowableArray< intptr_t > *class_ids, Function *target) const
 
void GetClassIdsAt (intptr_t index, GrowableArray< intptr_t > *class_ids) const
 
void GetOneClassCheckAt (intptr_t index, intptr_t *class_id, Function *target) const
 
intptr_t GetCidAt (intptr_t index) const
 
intptr_t GetReceiverClassIdAt (intptr_t index) const
 
intptr_t GetClassIdAt (intptr_t index, intptr_t arg_nr) const
 
FunctionPtr GetTargetAt (intptr_t index) const
 
void IncrementCountAt (intptr_t index, intptr_t value) const
 
void SetCountAt (intptr_t index, intptr_t value) const
 
intptr_t GetCountAt (intptr_t index) const
 
intptr_t AggregateCount () const
 
ICDataPtr AsUnaryClassChecksForArgNr (intptr_t arg_nr) const
 
ICDataPtr AsUnaryClassChecks () const
 
ICDataPtr AsUnaryClassChecksSortedByCount () const
 
UnlinkedCallPtr AsUnlinkedCall () const
 
bool HasReceiverClassId (intptr_t class_id) const
 
bool IsUsedAt (intptr_t i) const
 
void PrintToJSONArray (const JSONArray &jsarray, TokenPosition token_pos) const
 
bool is_static_call () const
 
intptr_t FindCheck (const GrowableArray< intptr_t > &cids) const
 
ArrayPtr entries () const
 
bool receiver_cannot_be_smi () const
 
void set_receiver_cannot_be_smi (bool value) const
 
uword Hash () const
 
- Public Member Functions inherited from dart::CallSiteData
StringPtr target_name () const
 
ArrayPtr arguments_descriptor () const
 
intptr_t TypeArgsLen () const
 
intptr_t CountWithTypeArgs () const
 
intptr_t CountWithoutTypeArgs () const
 
intptr_t SizeWithoutTypeArgs () const
 
intptr_t SizeWithTypeArgs () 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 const char * RebindRuleToCString (RebindRule r)
 
static bool ParseRebindRule (const char *str, RebindRule *out)
 
static intptr_t InstanceSize ()
 
static intptr_t state_bits_offset ()
 
static intptr_t NumArgsTestedShift ()
 
static intptr_t NumArgsTestedMask ()
 
static intptr_t entries_offset ()
 
static intptr_t owner_offset ()
 
static intptr_t receivers_static_type_offset ()
 
static ICDataPtr New (const Function &owner, const String &target_name, const Array &arguments_descriptor, intptr_t deopt_id, intptr_t num_args_tested, RebindRule rebind_rule, const AbstractType &receiver_type=Object::null_abstract_type())
 
static ICDataPtr NewWithCheck (const Function &owner, const String &target_name, const Array &arguments_descriptor, intptr_t deopt_id, intptr_t num_args_tested, RebindRule rebind_rule, GrowableArray< intptr_t > *cids, const Function &target, const AbstractType &receiver_type=Object::null_abstract_type())
 
static ICDataPtr NewForStaticCall (const Function &owner, const Function &target, const Array &arguments_descriptor, intptr_t deopt_id, intptr_t num_args_tested, RebindRule rebind_rule)
 
static ICDataPtr NewFrom (const ICData &from, intptr_t num_args_tested)
 
static ICDataPtr Clone (const ICData &from)
 
static ICDataPtr ICDataOfEntriesArray (const Array &array)
 
static intptr_t TestEntryLengthFor (intptr_t num_args, bool tracking_exactness)
 
static intptr_t CountIndexFor (intptr_t num_args)
 
static intptr_t EntryPointIndexFor (intptr_t num_args)
 
static intptr_t TargetIndexFor (intptr_t num_args)
 
static intptr_t CodeIndexFor (intptr_t num_args)
 
static intptr_t ExactnessIndexFor (intptr_t num_args)
 
static void Init ()
 
static void Cleanup ()
 
- Static Public Member Functions inherited from dart::CallSiteData
static intptr_t target_name_offset ()
 
static intptr_t arguments_descriptor_offset ()
 
- 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 kLastRecordedDeoptReason = kDeoptUnknown - 1
 
- Static Public Attributes inherited from dart::Object
static constexpr intptr_t kHashBits = 30
 
static const ClassId kClassId = kObjectCid
 

Friends

class CallSiteResetter
 
class CallTargets
 
class Class
 
class VMDeserializationRoots
 
class ICDataTestTask
 
class VMSerializationRoots
 

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

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kCachedICDataZeroArgTestedWithoutExactnessTrackingIdx 
kCachedICDataMaxArgsTestedWithoutExactnessTracking 
kCachedICDataOneArgWithExactnessTrackingIdx 
kCachedICDataArrayCount 

Definition at line 2750 of file object.h.

◆ DeoptFlags

Enumerator
kHoisted 
kGeneralized 

Definition at line 2500 of file object.h.

2500 {
2501 // Deoptimization is caused by an optimistically hoisted instruction.
2502 kHoisted = 1 << 0,
2503
2504 // Deoptimization is caused by an optimistically generalized bounds check.
2505 kGeneralized = 1 << 1
2506 };

◆ DeoptReasonId

Definition at line 2492 of file object.h.

2492 {
2493#define DEFINE_ENUM_LIST(name) kDeopt##name,
2495#undef DEFINE_ENUM_LIST
2496 };
#define DEFINE_ENUM_LIST(class_name, function_name, enum_name, fp)
#define DEOPT_REASONS(V)
Definition object.h:2473

◆ RebindRule

Enumerator
kNumRebindRules 

Definition at line 2525 of file object.h.

2525 {
2526#define REBIND_ENUM_DEF(name) k##name,
2528#undef REBIND_ENUM_DEF
2530 };
@ kNumRebindRules
Definition object.h:2529
#define FOR_EACH_REBIND_RULE(V)
Definition object.h:2517
#define REBIND_ENUM_DEF(name)
Definition object.h:2526

Member Function Documentation

◆ AddCheck()

void dart::ICData::AddCheck ( const GrowableArray< intptr_t > &  class_ids,
const Function target,
intptr_t  count = 1 
) const

Definition at line 16831 of file object.cc.

16833 {
16834 SafepointMutexLocker ml(IsolateGroup::Current()->type_feedback_mutex());
16835 AddCheckInternal(class_ids, target, count);
16836}
int count
static IsolateGroup * Current()
Definition isolate.h:534
uint32_t * target

◆ AddDeoptReason()

void dart::ICData::AddDeoptReason ( ICData::DeoptReasonId  reason) const

Definition at line 16565 of file object.cc.

16565 {
16566 if (reason <= kLastRecordedDeoptReason) {
16567 untag()->state_bits_.FetchOr<DeoptReasonBits>(1 << reason);
16568 }
16569}
static constexpr intptr_t kLastRecordedDeoptReason
Definition object.h:2498
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)

◆ AddReceiverCheck()

void dart::ICData::AddReceiverCheck ( intptr_t  receiver_class_id,
const Function target,
intptr_t  count = 1,
StaticTypeExactnessState  exactness = StaticTypeExactnessState::NotTracking() 
) const

Definition at line 16936 of file object.cc.

16939 {
16940 SafepointMutexLocker ml(IsolateGroup::Current()->type_feedback_mutex());
16941 AddReceiverCheckInternal(receiver_class_id, target, count, exactness);
16942}

◆ AggregateCount()

intptr_t dart::ICData::AggregateCount ( ) const

Definition at line 17131 of file object.cc.

17131 {
17132 if (IsNull()) return 0;
17133 const intptr_t len = NumberOfChecks();
17134 intptr_t count = 0;
17135 for (intptr_t i = 0; i < len; i++) {
17136 count += GetCountAt(i);
17137 }
17138 return count;
17139}
intptr_t GetCountAt(intptr_t index) const
Definition object.cc:17110
intptr_t NumberOfChecks() const
Definition object.cc:16624
bool IsNull() const
Definition object.h:363

◆ AsUnaryClassChecks()

ICDataPtr dart::ICData::AsUnaryClassChecks ( ) const
inline

Definition at line 2671 of file object.h.

2671{ return AsUnaryClassChecksForArgNr(0); }
ICDataPtr AsUnaryClassChecksForArgNr(intptr_t arg_nr) const
Definition object.cc:17142

◆ AsUnaryClassChecksForArgNr()

ICDataPtr dart::ICData::AsUnaryClassChecksForArgNr ( intptr_t  arg_nr) const

Definition at line 17142 of file object.cc.

17142 {
17143 ASSERT(!IsNull());
17144 ASSERT(NumArgsTested() > arg_nr);
17145 if ((arg_nr == 0) && (NumArgsTested() == 1)) {
17146 // Frequent case.
17147 return ptr();
17148 }
17149 const intptr_t kNumArgsTested = 1;
17150 ICData& result = ICData::Handle(ICData::NewFrom(*this, kNumArgsTested));
17151 const intptr_t len = NumberOfChecks();
17152 for (intptr_t i = 0; i < len; i++) {
17153 const intptr_t class_id = GetClassIdAt(i, arg_nr);
17154 const intptr_t count = GetCountAt(i);
17155 if (count == 0) {
17156 continue;
17157 }
17158 intptr_t duplicate_class_id = -1;
17159 const intptr_t result_len = result.NumberOfChecks();
17160 for (intptr_t k = 0; k < result_len; k++) {
17161 if (class_id == result.GetReceiverClassIdAt(k)) {
17162 duplicate_class_id = k;
17163 break;
17164 }
17165 }
17166 if (duplicate_class_id >= 0) {
17167 // This check is valid only when checking the receiver.
17168 ASSERT((arg_nr != 0) ||
17169 (result.GetTargetAt(duplicate_class_id) == GetTargetAt(i)));
17170 result.IncrementCountAt(duplicate_class_id, count);
17171 } else {
17172 // This will make sure that Smi is first if it exists.
17173 result.AddReceiverCheckInternal(class_id,
17176 }
17177 }
17178
17179 return result.ptr();
17180}
friend class ICData
Definition object.h:2379
intptr_t NumArgsTested() const
Definition object.cc:16518
FunctionPtr GetTargetAt(intptr_t index) const
Definition object.cc:17076
static ICDataPtr NewFrom(const ICData &from, intptr_t num_args_tested)
Definition object.cc:17471
intptr_t GetClassIdAt(intptr_t index, intptr_t arg_nr) const
Definition object.cc:17061
ObjectPtr ptr() const
Definition object.h:332
static Object & Handle()
Definition object.h:407
static StaticTypeExactnessState NotTracking()
#define ASSERT(E)
GAsyncResult * result

◆ AsUnaryClassChecksSortedByCount()

ICDataPtr dart::ICData::AsUnaryClassChecksSortedByCount ( ) const

Definition at line 17201 of file object.cc.

17201 {
17202 ASSERT(!IsNull());
17203 const intptr_t kNumArgsTested = 1;
17204 const intptr_t len = NumberOfChecks();
17205 if (len <= 1) {
17206 // No sorting needed.
17207 return AsUnaryClassChecks();
17208 }
17209 GrowableArray<CidCount> aggregate;
17210 for (intptr_t i = 0; i < len; i++) {
17211 const intptr_t class_id = GetClassIdAt(i, 0);
17212 const intptr_t count = GetCountAt(i);
17213 if (count == 0) {
17214 continue;
17215 }
17216 bool found = false;
17217 for (intptr_t r = 0; r < aggregate.length(); r++) {
17218 if (aggregate[r].cid == class_id) {
17219 aggregate[r].count += count;
17220 found = true;
17221 break;
17222 }
17223 }
17224 if (!found) {
17225 aggregate.Add(
17226 CidCount(class_id, count, &Function::ZoneHandle(GetTargetAt(i))));
17227 }
17228 }
17229 aggregate.Sort(CidCount::HighestCountFirst);
17230
17231 ICData& result = ICData::Handle(ICData::NewFrom(*this, kNumArgsTested));
17232 ASSERT(result.NumberOfChecksIs(0));
17233 // Room for all entries and the sentinel.
17234 const intptr_t data_len = result.TestEntryLength() * (aggregate.length() + 1);
17235 // Allocate the array but do not assign it to result until we have populated
17236 // it with the aggregate data and the terminating sentinel.
17237 const Array& data = Array::Handle(Array::New(data_len, Heap::kOld));
17238 intptr_t pos = 0;
17239 for (intptr_t i = 0; i < aggregate.length(); i++) {
17240 data.SetAt(pos + 0, Smi::Handle(Smi::New(aggregate[i].cid)));
17241 data.SetAt(pos + TargetIndexFor(1), *aggregate[i].function);
17242 data.SetAt(pos + CountIndexFor(1),
17243 Smi::Handle(Smi::New(aggregate[i].count)));
17244
17245 pos += result.TestEntryLength();
17246 }
17247 WriteSentinel(data, result.TestEntryLength(), result);
17248 result.set_entries(data);
17249 ASSERT(result.NumberOfChecksIs(aggregate.length()));
17250 return result.ptr();
17251}
SkPoint pos
static ArrayPtr New(intptr_t len, Heap::Space space=Heap::kNew)
Definition object.h:10933
@ kOld
Definition heap.h:39
static intptr_t TargetIndexFor(intptr_t num_args)
Definition object.h:2732
ICDataPtr AsUnaryClassChecks() const
Definition object.h:2671
static intptr_t CountIndexFor(intptr_t num_args)
Definition object.h:2729
static Object & ZoneHandle()
Definition object.h:419
static SmiPtr New(intptr_t value)
Definition object.h:9985
Dart_NativeFunction function
Definition fuchsia.cc:51
const intptr_t cid
static int8_t data[kExtLength]
static int HighestCountFirst(const CidCount *a, const CidCount *b)
Definition object.cc:17194

◆ AsUnlinkedCall()

UnlinkedCallPtr dart::ICData::AsUnlinkedCall ( ) const

Definition at line 17253 of file object.cc.

17253 {
17254 ASSERT(NumArgsTested() == 1);
17256 const UnlinkedCall& result = UnlinkedCall::Handle(UnlinkedCall::New());
17257 result.set_target_name(String::Handle(target_name()));
17258 result.set_arguments_descriptor(Array::Handle(arguments_descriptor()));
17259 result.set_can_patch_to_monomorphic(!FLAG_precompiled_mode ||
17261 return result.ptr();
17262}
StringPtr target_name() const
Definition object.h:2352
ArrayPtr arguments_descriptor() const
Definition object.h:2353
bool receiver_cannot_be_smi() const
Definition object.h:2767
bool is_tracking_exactness() const
Definition object.h:2463
static UnlinkedCallPtr New()
Definition object.cc:16390

◆ Cleanup()

void dart::ICData::Cleanup ( )
static

Definition at line 17306 of file object.cc.

17306 {
17307 for (int i = 0; i < kCachedICDataArrayCount; ++i) {
17308 cached_icdata_arrays_[i] = nullptr;
17309 }
17310}

◆ Clear()

void dart::ICData::Clear ( const CallSiteResetter proof_of_reload) const
inline

Definition at line 2583 of file object.h.

2583 {
2584 TruncateTo(0, proof_of_reload);
2585 }
void TruncateTo(intptr_t num_checks, const CallSiteResetter &proof_of_reload) const
Definition object.cc:16737

◆ ClearAndSetStaticTarget()

void dart::ICData::ClearAndSetStaticTarget ( const Function func,
const CallSiteResetter proof_of_reload 
) const

Definition at line 16777 of file object.cc.

16779 {
16780 USE(proof_of_reload); // This method can only be called during reload.
16781
16782 // The final entry is always the sentinel.
16783 DEBUG_ONLY(AssertInvariantsAreSatisfied());
16784
16785 if (IsImmutable()) return;
16786 if (NumberOfChecks() == 0) return;
16787
16788 // Leave one entry.
16789 TruncateTo(/*num_checks=*/1, proof_of_reload);
16790
16791 // Reinitialize the one and only entry.
16792 const intptr_t num_args = NumArgsTested();
16793 Thread* thread = Thread::Current();
16795 Array& data = thread->ArrayHandle();
16796 data = entries();
16797 const Smi& object_cid = Smi::Handle(Smi::New(kObjectCid));
16798 for (intptr_t i = 0; i < num_args; i++) {
16799 data.SetAt(i, object_cid);
16800 }
16801 data.SetAt(TargetIndexFor(num_args), func);
16802 data.SetAt(CountIndexFor(num_args), Object::smi_zero());
16803}
ArrayPtr entries() const
Definition object.h:2763
bool IsImmutable() const
Definition object.cc:17377
static Thread * Current()
Definition thread.h:361
static void USE(T &&)
Definition globals.h:618
#define DEBUG_ONLY(code)
Definition globals.h:141
#define REUSABLE_ARRAY_HANDLESCOPE(thread)

◆ ClearCountAt()

void dart::ICData::ClearCountAt ( intptr_t  index,
const CallSiteResetter proof_of_reload 
) const

Definition at line 16768 of file object.cc.

16769 {
16770 USE(proof_of_reload); // This method can only be called during reload.
16771
16772 ASSERT(index >= 0);
16773 ASSERT(index < NumberOfChecks());
16774 SetCountAt(index, 0);
16775}
void SetCountAt(intptr_t index, intptr_t value) const
Definition object.cc:17097

◆ Clone()

ICDataPtr dart::ICData::Clone ( const ICData from)
static

Definition at line 17486 of file object.cc.

17486 {
17487 Zone* zone = Thread::Current()->zone();
17488
17489 // We have to check the megamorphic bit before accessing the entries of the
17490 // ICData to ensure all writes to the entries have been flushed and are
17491 // visible at this point.
17492 //
17493 // This will allow us to maintain the invariant that if the megamorphic bit is
17494 // set, the number of entries in the ICData have reached the limit.
17495 const bool is_megamorphic = from.is_megamorphic();
17496
17497 const ICData& result = ICData::Handle(
17498 zone, ICData::NewDescriptor(
17499 zone, Function::Handle(zone, from.Owner()),
17500 String::Handle(zone, from.target_name()),
17501 Array::Handle(zone, from.arguments_descriptor()),
17502 from.deopt_id(), from.NumArgsTested(), from.rebind_rule(),
17503 AbstractType::Handle(zone, from.receivers_static_type())));
17504 // Clone entry array.
17505 const Array& from_array = Array::Handle(zone, from.entries());
17506 if (ICData::IsCachedEmptyEntry(from_array)) {
17507 result.set_entries(from_array);
17508 } else {
17509 const intptr_t len = from_array.Length();
17510 const Array& cloned_array =
17511 Array::Handle(zone, Array::New(len, Heap::kOld));
17512 Object& obj = Object::Handle(zone);
17513 for (intptr_t i = 0; i < len; i++) {
17514 obj = from_array.At(i);
17515 cloned_array.SetAt(i, obj);
17516 }
17517 // Update backref in our clone.
17518 cloned_array.SetAt(cloned_array.Length() - 1, result);
17519 result.set_entries(cloned_array);
17520 }
17521 // Copy deoptimization reasons.
17522 result.SetDeoptReasons(from.DeoptReasons());
17523 result.set_is_megamorphic(is_megamorphic);
17524
17525 RELEASE_ASSERT(!is_megamorphic ||
17526 result.NumberOfChecks() >= FLAG_max_polymorphic_checks);
17527
17528 DEBUG_ONLY(result.AssertInvariantsAreSatisfied());
17529
17530 return result.ptr();
17531}
#define RELEASE_ASSERT(cond)
Definition assert.h:327
Zone * zone() const

◆ CodeIndexFor()

static intptr_t dart::ICData::CodeIndexFor ( intptr_t  num_args)
inlinestatic

Definition at line 2733 of file object.h.

2733{ return num_args + 1; }

◆ CountIndexFor()

static intptr_t dart::ICData::CountIndexFor ( intptr_t  num_args)
inlinestatic

Definition at line 2729 of file object.h.

2729{ return num_args; }

◆ DebugDump()

void dart::ICData::DebugDump ( ) const

Definition at line 16904 of file object.cc.

16904 {
16905 const Function& owner = Function::Handle(Owner());
16906 THR_Print("ICData::DebugDump\n");
16907 THR_Print("Owner = %s [deopt=%" Pd "]\n", owner.ToCString(), deopt_id());
16908 THR_Print("NumArgsTested = %" Pd "\n", NumArgsTested());
16909 THR_Print("Length = %" Pd "\n", Length());
16910 THR_Print("NumberOfChecks = %" Pd "\n", NumberOfChecks());
16911
16912 GrowableArray<intptr_t> class_ids;
16913 for (intptr_t i = 0; i < NumberOfChecks(); i++) {
16914 THR_Print("Check[%" Pd "]:", i);
16915 GetClassIdsAt(i, &class_ids);
16916 for (intptr_t c = 0; c < class_ids.length(); c++) {
16917 THR_Print(" %" Pd "", class_ids[c]);
16918 }
16919 THR_Print("--- %" Pd " hits\n", GetCountAt(i));
16920 }
16921}
intptr_t deopt_id() const
Definition object.h:2448
void GetClassIdsAt(intptr_t index, GrowableArray< intptr_t > *class_ids) const
Definition object.cc:17020
intptr_t Length() const
Definition object.cc:16620
FunctionPtr Owner() const
Definition object.cc:16470
#define THR_Print(format,...)
Definition log.h:20
#define Pd
Definition globals.h:408

◆ deopt_id()

intptr_t dart::ICData::deopt_id ( ) const
inline

Definition at line 2448 of file object.h.

2448 {
2449#if defined(DART_PRECOMPILED_RUNTIME)
2450 UNREACHABLE();
2451 return -1;
2452#else
2453 return untag()->deopt_id_;
2454#endif
2455 }
#define UNREACHABLE()
Definition assert.h:248

◆ DeoptReasons()

uint32_t dart::ICData::DeoptReasons ( ) const

Definition at line 16552 of file object.cc.

16552 {
16553 return untag()->state_bits_.Read<DeoptReasonBits>();
16554}

◆ EnsureHasCheck()

void dart::ICData::EnsureHasCheck ( const GrowableArray< intptr_t > &  class_ids,
const Function target,
intptr_t  count = 1 
) const

Definition at line 16822 of file object.cc.

16824 {
16825 SafepointMutexLocker ml(IsolateGroup::Current()->type_feedback_mutex());
16826
16827 if (FindCheck(class_ids) != -1) return;
16828 AddCheckInternal(class_ids, target, count);
16829}
intptr_t FindCheck(const GrowableArray< intptr_t > &cids) const
Definition object.cc:16717

◆ EnsureHasReceiverCheck()

void dart::ICData::EnsureHasReceiverCheck ( intptr_t  receiver_class_id,
const Function target,
intptr_t  count = 1,
StaticTypeExactnessState  exactness = StaticTypeExactnessState::NotTracking() 
) const

Definition at line 16923 of file object.cc.

16926 {
16927 SafepointMutexLocker ml(IsolateGroup::Current()->type_feedback_mutex());
16928
16929 GrowableArray<intptr_t> class_ids(1);
16930 class_ids.Add(receiver_class_id);
16931 if (FindCheck(class_ids) != -1) return;
16932
16933 AddReceiverCheckInternal(receiver_class_id, target, count, exactness);
16934}

◆ entries()

ArrayPtr dart::ICData::entries ( ) const
inline

Definition at line 2763 of file object.h.

2763 {
2764 return untag()->entries<std::memory_order_acquire>();
2765 }

◆ entries_offset()

static intptr_t dart::ICData::entries_offset ( )
inlinestatic

Definition at line 2570 of file object.h.

2570 {
2571 return OFFSET_OF(UntaggedICData, entries_);
2572 }
#define OFFSET_OF(type, field)
Definition globals.h:138

◆ EntryPointIndexFor()

static intptr_t dart::ICData::EntryPointIndexFor ( intptr_t  num_args)
inlinestatic

Definition at line 2730 of file object.h.

2730{ return num_args; }

◆ ExactnessIndexFor()

static intptr_t dart::ICData::ExactnessIndexFor ( intptr_t  num_args)
inlinestatic

Definition at line 2735 of file object.h.

2735{ return num_args + 2; }

◆ FindCheck()

intptr_t dart::ICData::FindCheck ( const GrowableArray< intptr_t > &  cids) const

Definition at line 16717 of file object.cc.

16717 {
16718 const intptr_t len = NumberOfChecks();
16719 GrowableArray<intptr_t> class_ids;
16720 for (intptr_t i = 0; i < len; i++) {
16721 GetClassIdsAt(i, &class_ids);
16722 bool matches = true;
16723 for (intptr_t k = 0; k < class_ids.length(); k++) {
16724 ASSERT(class_ids[k] != kIllegalCid);
16725 if (class_ids[k] != cids[k]) {
16726 matches = false;
16727 break;
16728 }
16729 }
16730 if (matches) {
16731 return i;
16732 }
16733 }
16734 return -1;
16735}
@ kIllegalCid
Definition class_id.h:214

◆ GetCheckAt()

void dart::ICData::GetCheckAt ( intptr_t  index,
GrowableArray< intptr_t > *  class_ids,
Function target 
) const

Definition at line 17002 of file object.cc.

17004 {
17005 ASSERT(index < NumberOfChecks());
17006 ASSERT(class_ids != nullptr);
17007 ASSERT(target != nullptr);
17008 class_ids->Clear();
17009 Thread* thread = Thread::Current();
17011 Array& data = thread->ArrayHandle();
17012 data = entries();
17013 intptr_t data_pos = index * TestEntryLength();
17014 for (intptr_t i = 0; i < NumArgsTested(); i++) {
17015 class_ids->Add(Smi::Value(Smi::RawCast(data.At(data_pos + i))));
17016 }
17017 (*target) ^= data.At(data_pos + TargetIndexFor(NumArgsTested()));
17018}
void Add(const T &value)
static ObjectPtr RawCast(ObjectPtr obj)
Definition object.h:325
intptr_t Value() const
Definition object.h:9969

◆ GetCidAt()

intptr_t dart::ICData::GetCidAt ( intptr_t  index) const

Definition at line 17051 of file object.cc.

17051 {
17052 ASSERT(NumArgsTested() == 1);
17053 Thread* thread = Thread::Current();
17055 Array& data = thread->ArrayHandle();
17056 data = entries();
17057 const intptr_t data_pos = index * TestEntryLength();
17058 return Smi::Value(Smi::RawCast(data.At(data_pos)));
17059}

◆ GetClassIdAt()

intptr_t dart::ICData::GetClassIdAt ( intptr_t  index,
intptr_t  arg_nr 
) const

Definition at line 17061 of file object.cc.

17061 {
17062 GrowableArray<intptr_t> class_ids;
17063 GetClassIdsAt(index, &class_ids);
17064 return class_ids[arg_nr];
17065}

◆ GetClassIdsAt()

void dart::ICData::GetClassIdsAt ( intptr_t  index,
GrowableArray< intptr_t > *  class_ids 
) const

Definition at line 17020 of file object.cc.

17021 {
17022 ASSERT(index < Length());
17023 ASSERT(class_ids != nullptr);
17024 ASSERT(IsValidEntryIndex(index));
17025 class_ids->Clear();
17026 Thread* thread = Thread::Current();
17028 Array& data = thread->ArrayHandle();
17029 data = entries();
17030 intptr_t data_pos = index * TestEntryLength();
17031 for (intptr_t i = 0; i < NumArgsTested(); i++) {
17032 class_ids->Add(Smi::Value(Smi::RawCast(data.At(data_pos++))));
17033 }
17034}
bool IsValidEntryIndex(intptr_t index) const
Definition object.h:2552

◆ GetCountAt()

intptr_t dart::ICData::GetCountAt ( intptr_t  index) const

Definition at line 17110 of file object.cc.

17110 {
17111#if defined(DART_PRECOMPILED_RUNTIME)
17112 UNREACHABLE();
17113 return 0;
17114#else
17115 Thread* thread = Thread::Current();
17117 Array& data = thread->ArrayHandle();
17118 data = entries();
17119 const intptr_t data_pos =
17120 index * TestEntryLength() + CountIndexFor(NumArgsTested());
17121 intptr_t value = Smi::Value(Smi::RawCast(data.At(data_pos)));
17122 if (value >= 0) return value;
17123
17124 // The counter very rarely overflows to a negative value, but if it does, we
17125 // would rather just reset it to zero.
17126 SetCountAt(index, 0);
17127 return 0;
17128#endif
17129}
uint8_t value

◆ GetExactnessAt()

StaticTypeExactnessState dart::ICData::GetExactnessAt ( intptr_t  count) const

Definition at line 16988 of file object.cc.

16988 {
16989 if (!is_tracking_exactness()) {
16991 }
16992 Thread* thread = Thread::Current();
16994 Array& data = thread->ArrayHandle();
16995 data = entries();
16996 intptr_t data_pos =
16997 index * TestEntryLength() + ExactnessIndexFor(NumArgsTested());
16999 Smi::Value(Smi::RawCast(data.At(data_pos))));
17000}
static intptr_t ExactnessIndexFor(intptr_t num_args)
Definition object.h:2735
static StaticTypeExactnessState Decode(int8_t value)

◆ GetOneClassCheckAt()

void dart::ICData::GetOneClassCheckAt ( intptr_t  index,
intptr_t *  class_id,
Function target 
) const

Definition at line 17036 of file object.cc.

17038 {
17039 ASSERT(class_id != nullptr);
17040 ASSERT(target != nullptr);
17041 ASSERT(NumArgsTested() == 1);
17042 Thread* thread = Thread::Current();
17044 Array& data = thread->ArrayHandle();
17045 data = entries();
17046 const intptr_t data_pos = index * TestEntryLength();
17047 *class_id = Smi::Value(Smi::RawCast(data.At(data_pos)));
17048 *target ^= data.At(data_pos + TargetIndexFor(NumArgsTested()));
17049}

◆ GetReceiverClassIdAt()

intptr_t dart::ICData::GetReceiverClassIdAt ( intptr_t  index) const

Definition at line 17067 of file object.cc.

17067 {
17068 ASSERT(index < Length());
17069 ASSERT(IsValidEntryIndex(index));
17070 const intptr_t data_pos = index * TestEntryLength();
17071 NoSafepointScope no_safepoint;
17072 ArrayPtr raw_data = entries();
17073 return Smi::Value(Smi::RawCast(raw_data->untag()->element(data_pos)));
17074}

◆ GetTargetAt()

FunctionPtr dart::ICData::GetTargetAt ( intptr_t  index) const

Definition at line 17076 of file object.cc.

17076 {
17077#if defined(DART_PRECOMPILED_RUNTIME)
17078 UNREACHABLE();
17079 return nullptr;
17080#else
17081 const intptr_t data_pos =
17082 index * TestEntryLength() + TargetIndexFor(NumArgsTested());
17083 ASSERT(Object::Handle(Array::Handle(entries()).At(data_pos)).IsFunction());
17084
17085 NoSafepointScope no_safepoint;
17086 ArrayPtr raw_data = entries();
17087 return static_cast<FunctionPtr>(raw_data->untag()->element(data_pos));
17088#endif
17089}

◆ HasDeoptReason()

bool dart::ICData::HasDeoptReason ( ICData::DeoptReasonId  reason) const

Definition at line 16560 of file object.cc.

16560 {
16562 return (DeoptReasons() & (1 << reason)) != 0;
16563}
uint32_t DeoptReasons() const
Definition object.cc:16552

◆ HasDeoptReasons()

bool dart::ICData::HasDeoptReasons ( ) const
inline

Definition at line 2508 of file object.h.

2508{ return DeoptReasons() != 0; }

◆ Hash()

uword dart::ICData::Hash ( ) const

Definition at line 16457 of file object.cc.

16457 {
16459}
static uword HashRawSymbol(const StringPtr symbol)
Definition object.h:10226

◆ HasReceiverClassId()

bool dart::ICData::HasReceiverClassId ( intptr_t  class_id) const

Definition at line 17264 of file object.cc.

17264 {
17265 ASSERT(NumArgsTested() > 0);
17266 const intptr_t len = NumberOfChecks();
17267 for (intptr_t i = 0; i < len; i++) {
17268 if (IsUsedAt(i)) {
17269 const intptr_t test_class_id = GetReceiverClassIdAt(i);
17270 if (test_class_id == class_id) {
17271 return true;
17272 }
17273 }
17274 }
17275 return false;
17276}
intptr_t GetReceiverClassIdAt(intptr_t index) const
Definition object.cc:17067
bool IsUsedAt(intptr_t i) const
Definition object.cc:17279

◆ ICDataOfEntriesArray()

ICDataPtr dart::ICData::ICDataOfEntriesArray ( const Array array)
static

Definition at line 17534 of file object.cc.

17534 {
17535 const auto& back_ref = Object::Handle(array.At(array.Length() - 1));
17536 if (back_ref.ptr() == smi_illegal_cid().ptr()) {
17537 ASSERT(IsCachedEmptyEntry(array));
17538 return ICData::null();
17539 }
17540
17541 const auto& ic_data = ICData::Cast(back_ref);
17542 DEBUG_ONLY(ic_data.AssertInvariantsAreSatisfied());
17543 return ic_data.ptr();
17544}
static ObjectPtr null()
Definition object.h:433

◆ IncrementCountAt()

void dart::ICData::IncrementCountAt ( intptr_t  index,
intptr_t  value 
) const

Definition at line 17091 of file object.cc.

17091 {
17092 ASSERT(0 <= value);
17093 ASSERT(value <= Smi::kMaxValue);
17094 SetCountAt(index, Utils::Minimum(GetCountAt(index) + value, Smi::kMaxValue));
17095}
static constexpr intptr_t kMaxValue
Definition object.h:9966
static T Minimum(T x, T y)
Definition utils.h:21

◆ Init()

void dart::ICData::Init ( )
static

Definition at line 17295 of file object.cc.

17295 {
17297 i++) {
17298 cached_icdata_arrays_
17300 ICData::NewNonCachedEmptyICDataArray(i, false);
17301 }
17302 cached_icdata_arrays_[kCachedICDataOneArgWithExactnessTrackingIdx] =
17303 ICData::NewNonCachedEmptyICDataArray(1, true);
17304}

◆ InstanceSize()

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

Definition at line 2556 of file object.h.

2556 {
2557 return RoundedAllocationSize(sizeof(UntaggedICData));
2558 }
static constexpr intptr_t RoundedAllocationSize(intptr_t size)
Definition object.h:758

◆ is_static_call()

bool dart::ICData::is_static_call ( ) const

Definition at line 16602 of file object.cc.

16602 {
16603 return rebind_rule() != kInstance;
16604}
RebindRule rebind_rule() const
Definition object.cc:16594

◆ is_tracking_exactness()

bool dart::ICData::is_tracking_exactness ( ) const
inline

Definition at line 2463 of file object.h.

2463 {
2464 return untag()->state_bits_.Read<TrackingExactnessBit>();
2465 }

◆ IsImmutable()

bool dart::ICData::IsImmutable ( ) const

Definition at line 17377 of file object.cc.

17377 {
17378 return entries()->IsImmutableArray();
17379}

◆ IsOriginal()

bool dart::ICData::IsOriginal ( ) const
inline

Definition at line 2444 of file object.h.

2444{ return Original() == this->ptr(); }
ICDataPtr Original() const
Definition object.cc:16484

◆ IsUsedAt()

bool dart::ICData::IsUsedAt ( intptr_t  i) const

Definition at line 17279 of file object.cc.

17279 {
17280 if (GetCountAt(i) <= 0) {
17281 // Do not mistake unoptimized static call ICData for unused.
17282 // See ICData::AddTarget.
17283 // TODO(srdjan): Make this test more robust.
17284 if (NumArgsTested() > 0) {
17285 const intptr_t cid = GetReceiverClassIdAt(i);
17286 if (cid == kObjectCid) {
17287 return true;
17288 }
17289 }
17290 return false;
17291 }
17292 return true;
17293}

◆ IsValidEntryIndex()

bool dart::ICData::IsValidEntryIndex ( intptr_t  index) const
inline

Definition at line 2552 of file object.h.

2552 {
2553 return 0 <= index && index < NumberOfChecks();
2554 }

◆ Length()

intptr_t dart::ICData::Length ( ) const

Definition at line 16620 of file object.cc.

16620 {
16621 return (Smi::Value(entries()->untag()->length()) / TestEntryLength());
16622}
size_t length

◆ New()

ICDataPtr dart::ICData::New ( const Function owner,
const String target_name,
const Array arguments_descriptor,
intptr_t  deopt_id,
intptr_t  num_args_tested,
RebindRule  rebind_rule,
const AbstractType receiver_type = Object::null_abstract_type() 
)
static

Definition at line 17389 of file object.cc.

17395 {
17396 Zone* zone = Thread::Current()->zone();
17397 const ICData& result = ICData::Handle(
17398 zone,
17399 NewDescriptor(zone, owner, target_name, arguments_descriptor, deopt_id,
17400 num_args_tested, rebind_rule, receivers_static_type));
17401 result.set_entries(Array::Handle(
17402 zone,
17403 CachedEmptyICDataArray(num_args_tested, result.is_tracking_exactness())));
17404 return result.ptr();
17405}
AbstractTypePtr receivers_static_type() const
Definition object.h:2460

◆ NewForStaticCall()

ICDataPtr dart::ICData::NewForStaticCall ( const Function owner,
const Function target,
const Array arguments_descriptor,
intptr_t  deopt_id,
intptr_t  num_args_tested,
RebindRule  rebind_rule 
)
static

Definition at line 17448 of file object.cc.

17453 {
17454 // See `MethodRecognizer::NumArgsCheckedForStaticCall`.
17455 ASSERT(num_args_tested == 0 || num_args_tested == 2);
17456 ASSERT(!target.IsNull());
17457
17458 Zone* zone = Thread::Current()->zone();
17459 const auto& target_name = String::Handle(zone, target.name());
17460 GrowableArray<intptr_t> cids(num_args_tested);
17461 if (num_args_tested == 2) {
17462 cids.Add(kObjectCid);
17463 cids.Add(kObjectCid);
17464 }
17466 deopt_id, num_args_tested, rebind_rule, &cids,
17467 target, Object::null_abstract_type());
17468}
static ICDataPtr NewWithCheck(const Function &owner, const String &target_name, const Array &arguments_descriptor, intptr_t deopt_id, intptr_t num_args_tested, RebindRule rebind_rule, GrowableArray< intptr_t > *cids, const Function &target, const AbstractType &receiver_type=Object::null_abstract_type())
Definition object.cc:17407

◆ NewFrom()

ICDataPtr dart::ICData::NewFrom ( const ICData from,
intptr_t  num_args_tested 
)
static

Definition at line 17471 of file object.cc.

17471 {
17472 // See comment in [ICData::Clone] why we access the megamorphic bit first.
17473 const bool is_megamorphic = from.is_megamorphic();
17474
17475 const ICData& result = ICData::Handle(ICData::New(
17476 Function::Handle(from.Owner()), String::Handle(from.target_name()),
17477 Array::Handle(from.arguments_descriptor()), from.deopt_id(),
17478 num_args_tested, from.rebind_rule(),
17479 AbstractType::Handle(from.receivers_static_type())));
17480 // Copy deoptimization reasons.
17481 result.SetDeoptReasons(from.DeoptReasons());
17482 result.set_is_megamorphic(is_megamorphic);
17483 return result.ptr();
17484}

◆ NewWithCheck()

ICDataPtr dart::ICData::NewWithCheck ( const Function owner,
const String target_name,
const Array arguments_descriptor,
intptr_t  deopt_id,
intptr_t  num_args_tested,
RebindRule  rebind_rule,
GrowableArray< intptr_t > *  cids,
const Function target,
const AbstractType receiver_type = Object::null_abstract_type() 
)
static

Definition at line 17407 of file object.cc.

17415 {
17416 ASSERT((cids != nullptr) && !target.IsNull());
17417 ASSERT(cids->length() == num_args_tested);
17418
17419 Zone* zone = Thread::Current()->zone();
17420 const auto& result = ICData::Handle(
17421 zone,
17422 NewDescriptor(zone, owner, target_name, arguments_descriptor, deopt_id,
17423 num_args_tested, rebind_rule, receiver_type));
17424
17425 const intptr_t kNumEntries = 2; // 1 entry and a sentinel.
17426 const intptr_t entry_len =
17427 TestEntryLengthFor(num_args_tested, result.is_tracking_exactness());
17428 const auto& array =
17429 Array::Handle(zone, Array::New(kNumEntries * entry_len, Heap::kOld));
17430
17431 auto& cid = Smi::Handle(zone);
17432 for (intptr_t i = 0; i < num_args_tested; ++i) {
17433 cid = Smi::New((*cids)[i]);
17434 array.SetAt(i, cid);
17435 }
17436
17437 SetTargetAtPos(array, 0, num_args_tested, target);
17438#if !defined(DART_PRECOMPILED_RUNTIME)
17439 array.SetAt(CountIndexFor(num_args_tested), Object::smi_zero());
17440#endif
17441 WriteSentinel(array, entry_len, result);
17442
17443 result.set_entries(array);
17444
17445 return result.ptr();
17446}
intptr_t length() const
static intptr_t TestEntryLengthFor(intptr_t num_args, bool tracking_exactness)
Definition object.cc:16610

◆ NumArgsTested()

intptr_t dart::ICData::NumArgsTested ( ) const

Definition at line 16518 of file object.cc.

16518 {
16519 return untag()->state_bits_.Read<NumArgsTestedBits>();
16520}

◆ NumArgsTestedMask()

static intptr_t dart::ICData::NumArgsTestedMask ( )
inlinestatic

Definition at line 2566 of file object.h.

2566 {
2567 return ((1 << kNumArgsTestedSize) - 1) << kNumArgsTestedPos;
2568 }

◆ NumArgsTestedShift()

static intptr_t dart::ICData::NumArgsTestedShift ( )
inlinestatic

Definition at line 2564 of file object.h.

2564{ return kNumArgsTestedPos; }

◆ NumberOfChecks()

intptr_t dart::ICData::NumberOfChecks ( ) const

Definition at line 16624 of file object.cc.

16624 {
16625 DEBUG_ONLY(AssertInvariantsAreSatisfied());
16626 return Length() - 1;
16627}

◆ NumberOfChecksIs()

bool dart::ICData::NumberOfChecksIs ( intptr_t  n) const

Definition at line 16629 of file object.cc.

16629 {
16630 DEBUG_ONLY(AssertInvariantsAreSatisfied());
16631 return NumberOfChecks() == n;
16632}

◆ NumberOfUsedChecks()

intptr_t dart::ICData::NumberOfUsedChecks ( ) const

Definition at line 16687 of file object.cc.

16687 {
16688 const intptr_t n = NumberOfChecks();
16689 intptr_t count = 0;
16690 for (intptr_t i = 0; i < n; i++) {
16691 if (GetCountAt(i) > 0) {
16692 count++;
16693 }
16694 }
16695 return count;
16696}

◆ Original()

ICDataPtr dart::ICData::Original ( ) const

Definition at line 16484 of file object.cc.

16484 {
16485 if (IsNull()) {
16486 return ICData::null();
16487 }
16488 if (untag()->owner()->IsICData()) {
16489 return static_cast<ICDataPtr>(untag()->owner());
16490 }
16491 return this->ptr();
16492}

◆ Owner()

FunctionPtr dart::ICData::Owner ( ) const

Definition at line 16470 of file object.cc.

16470 {
16471 Object& obj = Object::Handle(untag()->owner());
16472 if (obj.IsNull()) {
16474 return Function::null();
16475 } else if (obj.IsFunction()) {
16476 return Function::Cast(obj).ptr();
16477 } else {
16478 ICData& original = ICData::Handle();
16479 original ^= obj.ptr();
16480 return original.Owner();
16481 }
16482}
static Snapshot::Kind vm_snapshot_kind()
Definition dart.h:95

◆ owner_offset()

static intptr_t dart::ICData::owner_offset ( )
inlinestatic

Definition at line 2574 of file object.h.

2574{ return OFFSET_OF(UntaggedICData, owner_); }

◆ ParseRebindRule()

bool dart::ICData::ParseRebindRule ( const char *  str,
RebindRule out 
)
static

Definition at line 16583 of file object.cc.

16583 {
16584#define RULE_CASE(Name) \
16585 if (strcmp(str, #Name) == 0) { \
16586 *out = RebindRule::k##Name; \
16587 return true; \
16588 }
16590#undef RULE_CASE
16591 return false;
16592}
#define RULE_CASE(Name)

◆ PrintToJSONArray()

void dart::ICData::PrintToJSONArray ( const JSONArray jsarray,
TokenPosition  token_pos 
) const

Definition at line 993 of file object_service.cc.

994 {
995 auto class_table = IsolateGroup::Current()->class_table();
996 Class& cls = Class::Handle();
997 Function& func = Function::Handle();
998
999 JSONObject jsobj(&jsarray);
1000 jsobj.AddProperty("name", String::Handle(target_name()).ToCString());
1001 jsobj.AddProperty("tokenPos", static_cast<intptr_t>(token_pos.Serialize()));
1002 // TODO(rmacnak): Figure out how to stringify DeoptReasons().
1003 // jsobj.AddProperty("deoptReasons", ...);
1004
1005 JSONArray cache_entries(&jsobj, "cacheEntries");
1006 for (intptr_t i = 0; i < NumberOfChecks(); i++) {
1007 JSONObject cache_entry(&cache_entries);
1008 func = GetTargetAt(i);
1009 intptr_t count = GetCountAt(i);
1010 if (!is_static_call()) {
1011 intptr_t cid = GetReceiverClassIdAt(i);
1012 cls = class_table->At(cid);
1013 cache_entry.AddProperty("receiver", cls);
1014 }
1015 cache_entry.AddProperty("target", func);
1016 cache_entry.AddProperty("count", count);
1017 }
1018}
bool is_static_call() const
Definition object.cc:16602
friend class Class
Definition object.h:2898
ClassTable * class_table() const
Definition isolate.h:491
virtual const char * ToCString() const
Definition object.h:366

◆ rebind_rule()

ICData::RebindRule dart::ICData::rebind_rule ( ) const

Definition at line 16594 of file object.cc.

16594 {
16595 return RebindRule(untag()->state_bits_.Read<RebindRuleBits>());
16596}

◆ RebindRuleToCString()

const char * dart::ICData::RebindRuleToCString ( RebindRule  r)
static

Definition at line 16571 of file object.cc.

16571 {
16572 switch (r) {
16573#define RULE_CASE(Name) \
16574 case RebindRule::k##Name: \
16575 return #Name;
16577#undef RULE_CASE
16578 default:
16579 return nullptr;
16580 }
16581}

◆ receiver_cannot_be_smi()

bool dart::ICData::receiver_cannot_be_smi ( ) const
inline

Definition at line 2767 of file object.h.

2767 {
2768 return untag()->state_bits_.Read<ReceiverCannotBeSmiBit>();
2769 }

◆ receivers_static_type()

AbstractTypePtr dart::ICData::receivers_static_type ( ) const
inline

Definition at line 2460 of file object.h.

2460 {
2461 return untag()->receivers_static_type();
2462 }

◆ receivers_static_type_offset()

static intptr_t dart::ICData::receivers_static_type_offset ( )
inlinestatic

Definition at line 2577 of file object.h.

2577 {
2578 return OFFSET_OF(UntaggedICData, receivers_static_type_);
2579 }

◆ set_is_megamorphic()

void dart::ICData::set_is_megamorphic ( bool  value) const
inline

Definition at line 2535 of file object.h.

2535 {
2536 untag()->state_bits_.UpdateBool<MegamorphicBit, std::memory_order_release>(
2537 value);
2538 }

◆ set_receiver_cannot_be_smi()

void dart::ICData::set_receiver_cannot_be_smi ( bool  value) const
inline

Definition at line 2771 of file object.h.

2771 {
2772 untag()->state_bits_.UpdateBool<ReceiverCannotBeSmiBit>(value);
2773 }

◆ SetCountAt()

void dart::ICData::SetCountAt ( intptr_t  index,
intptr_t  value 
) const

Definition at line 17097 of file object.cc.

17097 {
17098 ASSERT(0 <= value);
17099 ASSERT(value <= Smi::kMaxValue);
17100
17101 Thread* thread = Thread::Current();
17103 Array& data = thread->ArrayHandle();
17104 data = entries();
17105 const intptr_t data_pos =
17106 index * TestEntryLength() + CountIndexFor(NumArgsTested());
17107 data.SetAt(data_pos, Smi::Handle(Smi::New(value)));
17108}

◆ SetDeoptReasons()

void dart::ICData::SetDeoptReasons ( uint32_t  reasons) const

Definition at line 16556 of file object.cc.

16556 {
16557 untag()->state_bits_.Update<DeoptReasonBits>(reasons);
16558}

◆ SetOriginal()

void dart::ICData::SetOriginal ( const ICData value) const

Definition at line 16494 of file object.cc.

16494 {
16495 ASSERT(value.IsOriginal());
16496 ASSERT(!value.IsNull());
16497 untag()->set_owner(static_cast<ObjectPtr>(value.ptr()));
16498}

◆ state_bits_offset()

static intptr_t dart::ICData::state_bits_offset ( )
inlinestatic

Definition at line 2560 of file object.h.

2560 {
2561 return OFFSET_OF(UntaggedICData, state_bits_);
2562 }

◆ TargetIndexFor()

static intptr_t dart::ICData::TargetIndexFor ( intptr_t  num_args)
inlinestatic

Definition at line 2732 of file object.h.

2732{ return num_args + 1; }

◆ TestEntryLengthFor()

intptr_t dart::ICData::TestEntryLengthFor ( intptr_t  num_args,
bool  tracking_exactness 
)
static

Definition at line 16610 of file object.cc.

16611 {
16612 return num_args + 1 /* target function*/ + 1 /* frequency */ +
16613 (tracking_exactness ? 1 : 0) /* exactness state */;
16614}

◆ TruncateTo()

void dart::ICData::TruncateTo ( intptr_t  num_checks,
const CallSiteResetter proof_of_reload 
) const

Definition at line 16737 of file object.cc.

16738 {
16739 USE(proof_of_reload); // This method can only be called during reload.
16740
16741 DEBUG_ONLY(AssertInvariantsAreSatisfied());
16742 ASSERT(num_checks <= NumberOfChecks());
16743
16744 // Nothing to do.
16745 if (NumberOfChecks() == num_checks) return;
16746
16747 auto thread = Thread::Current();
16749 auto& array = thread->ArrayHandle();
16750
16751 // If we make the ICData empty, use the pre-allocated shared backing stores.
16752 const intptr_t num_args = NumArgsTested();
16753 if (num_checks == 0) {
16754 array = ICData::CachedEmptyICDataArray(num_args, is_tracking_exactness());
16755 set_entries(array);
16756 return;
16757 }
16758
16759 // Otherwise truncate array and initialize sentinel.
16760 // Use kSmiCid for all slots in the entry except the last, which is a backref
16761 // to ICData.
16762 const intptr_t entry_length = TestEntryLength();
16763 array = entries();
16764 array.Truncate((num_checks + 1) * entry_length);
16765 WriteSentinel(array, entry_length, *this);
16766}

Friends And Related Symbol Documentation

◆ CallSiteResetter

friend class CallSiteResetter
friend

Definition at line 2896 of file object.h.

◆ CallTargets

friend class CallTargets
friend

Definition at line 2897 of file object.h.

◆ Class

friend class Class
friend

Definition at line 2898 of file object.h.

◆ ICDataTestTask

friend class ICDataTestTask
friend

Definition at line 2900 of file object.h.

◆ VMDeserializationRoots

friend class VMDeserializationRoots
friend

Definition at line 2899 of file object.h.

◆ VMSerializationRoots

friend class VMSerializationRoots
friend

Definition at line 2901 of file object.h.

Member Data Documentation

◆ kLastRecordedDeoptReason

constexpr intptr_t dart::ICData::kLastRecordedDeoptReason = kDeoptUnknown - 1
staticconstexpr

Definition at line 2498 of file object.h.


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