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

#include <raw_object.h>

Inheritance diagram for dart::UntaggedObject:
dart::UntaggedCallSiteData dart::UntaggedClass dart::UntaggedClosureData dart::UntaggedCode dart::UntaggedCodeSourceMap dart::UntaggedCompressedStackMaps dart::UntaggedContext dart::UntaggedContextScope dart::UntaggedError dart::UntaggedExceptionHandlers dart::UntaggedFfiTrampolineData dart::UntaggedField dart::UntaggedFunction dart::UntaggedInstance dart::UntaggedInstructions dart::UntaggedInstructionsSection dart::UntaggedInstructionsTable dart::UntaggedKernelProgramInfo dart::UntaggedLibrary dart::UntaggedLoadingUnit dart::UntaggedLocalVarDescriptors dart::UntaggedMonomorphicSmiableCall dart::UntaggedNamespace dart::UntaggedObjectPool dart::UntaggedPatchClass dart::UntaggedPcDescriptors dart::UntaggedScript dart::UntaggedSentinel dart::UntaggedSingleTargetCache dart::UntaggedSubtypeTestCache dart::UntaggedTypeParameters dart::UntaggedWeakArray dart::UntaggedWeakSerializationReference

Classes

class  AlwaysSetBit
 
class  CanonicalBit
 
class  CardRememberedBit
 
class  ClassIdTag
 
class  ImmutableBit
 
class  NewBit
 
class  NotMarkedBit
 
class  OldAndNotRememberedBit
 
class  ReservedBit
 
class  SizeTag
 

Public Types

enum  TagBits {
  kCardRememberedBit = 0 , kCanonicalBit = 1 , kNotMarkedBit = 2 , kNewBit = 3 ,
  kAlwaysSetBit = 4 , kOldAndNotRememberedBit = 5 , kImmutableBit = 6 , kReservedBit = 7 ,
  kSizeTagPos = kReservedBit + 1 , kSizeTagSize = 4 , kClassIdTagPos = kSizeTagPos + kSizeTagSize , kClassIdTagSize = 20 ,
  kHashTagPos = kClassIdTagPos + kClassIdTagSize , kHashTagSize = 32
}
 

Public Member Functions

 COMPILE_ASSERT (kNotMarkedBit+kBarrierOverlapShift==kAlwaysSetBit)
 
 COMPILE_ASSERT (kNewBit+kBarrierOverlapShift==kOldAndNotRememberedBit)
 
 COMPILE_ASSERT (kCardRememberedBit==0)
 
 COMPILE_ASSERT (kBitsPerByte *sizeof(ClassIdTagType) >=kClassIdTagSize)
 
 COMPILE_ASSERT (kClassIdTagMax==(1<< kClassIdTagSize) - 1)
 
bool IsNewObject () const
 
bool IsOldObject () const
 
uword tags () const
 
bool IsMarked () const
 
bool IsMarkedIgnoreRace () const
 
void SetMarkBit ()
 
void SetMarkBitUnsynchronized ()
 
void SetMarkBitRelease ()
 
void ClearMarkBit ()
 
void ClearMarkBitUnsynchronized ()
 
DART_WARN_UNUSED_RESULT bool TryAcquireMarkBit ()
 
bool IsCanonical () const
 
void SetCanonical ()
 
void ClearCanonical ()
 
bool IsImmutable () const
 
void SetImmutable ()
 
void ClearImmutable ()
 
bool InVMIsolateHeap () const
 
bool IsRemembered () const
 
bool TryAcquireRememberedBit ()
 
void ClearRememberedBit ()
 
void ClearRememberedBitUnsynchronized ()
 
DART_FORCE_INLINE void EnsureInRememberedSet (Thread *thread)
 
bool IsCardRemembered () const
 
void SetCardRememberedBitUnsynchronized ()
 
intptr_t GetClassId () const
 
intptr_t HeapSize () const
 
intptr_t HeapSize (uword tags) const
 
bool Contains (uword addr) const
 
void Validate (IsolateGroup *isolate_group) const
 
intptr_t VisitPointers (ObjectPointerVisitor *visitor)
 
template<class V >
DART_FORCE_INLINE intptr_t VisitPointersNonvirtual (V *visitor)
 
void VisitPointersPrecise (ObjectPointerVisitor *visitor)
 

Static Public Member Functions

static bool IsMarked (uword tags)
 
static ObjectPtr FromAddr (uword addr)
 
static uword ToAddr (const UntaggedObject *raw_obj)
 
static uword ToAddr (const ObjectPtr raw_obj)
 
static bool IsCanonical (intptr_t value)
 

Static Public Attributes

static constexpr intptr_t kGenerationalBarrierMask = 1 << kNewBit
 
static constexpr intptr_t kIncrementalBarrierMask = 1 << kNotMarkedBit
 
static constexpr intptr_t kBarrierOverlapShift = 2
 

Protected Member Functions

template<typename type , std::memory_order order = std::memory_order_relaxed>
type LoadPointer (type const *addr) const
 
template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
type LoadCompressedPointer (compressed_type const *addr) const
 
uword heap_base () const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
void StorePointer (type const *addr, type value)
 
template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
void StoreCompressedPointer (compressed_type const *addr, type value)
 
template<typename type >
void StorePointer (type const *addr, type value, Thread *thread)
 
template<typename type , typename compressed_type >
void StoreCompressedPointer (compressed_type const *addr, type value, Thread *thread)
 
template<typename type >
void StorePointerUnaligned (type const *addr, type value, Thread *thread)
 
template<typename type , std::memory_order order = std::memory_order_relaxed, typename value_type = type>
void StoreArrayPointer (type const *addr, value_type value)
 
template<typename type , typename value_type = type>
void StoreArrayPointer (type const *addr, value_type value, Thread *thread)
 
template<typename type , typename compressed_type , std::memory_order order>
void StoreCompressedArrayPointer (compressed_type const *addr, type value)
 
template<typename type , typename compressed_type , std::memory_order order>
void StoreCompressedArrayPointer (compressed_type const *addr, type value, Thread *thread)
 
template<typename type , typename compressed_type >
void StoreCompressedArrayPointer (compressed_type const *addr, type value, Thread *thread)
 
template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
type ExchangeCompressedPointer (compressed_type const *addr, type value)
 
template<std::memory_order order = std::memory_order_relaxed>
SmiPtr LoadSmi (SmiPtr const *addr) const
 
template<std::memory_order order = std::memory_order_relaxed>
SmiPtr LoadCompressedSmi (CompressedSmiPtr const *addr) const
 
template<typename type , std::memory_order order = std::memory_order_relaxed>
void StoreSmi (type const *addr, type value)
 
template<std::memory_order order = std::memory_order_relaxed>
void StoreCompressedSmi (CompressedSmiPtr const *addr, SmiPtr value)
 

Static Protected Member Functions

template<typename T >
static DART_FORCE_INLINE uword from_offset ()
 
template<typename T >
static DART_FORCE_INLINE uword to_offset (intptr_t length=0)
 
template<>
DART_FORCE_INLINE uword from_offset ()
 
template<>
DART_FORCE_INLINE uword to_offset (intptr_t length)
 
template<>
DART_FORCE_INLINE uword to_offset (intptr_t length)
 
template<>
DART_FORCE_INLINE uword to_offset (intptr_t length)
 

Static Protected Attributes

static constexpr bool kContainsCompressedPointers = false
 
static constexpr bool kContainsPointerFields = false
 

Friends

class StoreBufferUpdateVisitor
 
class Array
 
class ByteBuffer
 
class CidRewriteVisitor
 
class Closure
 
class Code
 
class Pointer
 
class Double
 
class DynamicLibrary
 
class ForwardPointersVisitor
 
class FreeListElement
 
class Function
 
class GCMarker
 
class GCSweeper
 
class ExternalTypedData
 
class GrowableObjectArray
 
template<bool >
class MarkingVisitorBase
 
class Mint
 
class Object
 
class OneByteString
 
class UntaggedInstance
 
class Scavenger
 
template<bool >
class ScavengerVisitorBase
 
class ImageReader
 
class ImageWriter
 
class AssemblyImageWriter
 
class BlobImageWriter
 
class Deserializer
 
class String
 
class WeakProperty
 
class Instance
 
class StackFrame
 
class CodeLookupTableBuilder
 
class ObjectLocator
 
class WriteBarrierUpdateVisitor
 
class OffsetsTable
 
class ObjectCopyBase
 
uword TagsFromUntaggedObject (UntaggedObject *)
 
void SetNewSpaceTaggingWord (ObjectPtr, classid_t, uint32_t)
 
void ReportImpossibleNullError (intptr_t cid, StackFrame *caller_frame, Thread *thread)
 

Detailed Description

Definition at line 158 of file raw_object.h.

Member Enumeration Documentation

◆ TagBits

Enumerator
kCardRememberedBit 
kCanonicalBit 
kNotMarkedBit 
kNewBit 
kAlwaysSetBit 
kOldAndNotRememberedBit 
kImmutableBit 
kReservedBit 
kSizeTagPos 
kSizeTagSize 
kClassIdTagPos 
kClassIdTagSize 
kHashTagPos 
kHashTagSize 

Definition at line 162 of file raw_object.h.

162 {
164 kCanonicalBit = 1,
165 kNotMarkedBit = 2, // Incremental barrier target.
166 kNewBit = 3, // Generational barrier target.
167 kAlwaysSetBit = 4, // Incremental barrier source.
168 kOldAndNotRememberedBit = 5, // Generational barrier source.
169 kImmutableBit = 6,
170 kReservedBit = 7,
171
172 kSizeTagPos = kReservedBit + 1, // = 8
173 kSizeTagSize = 4,
175 kClassIdTagSize = 20,
177 kHashTagSize = 32,
178 };

Member Function Documentation

◆ ClearCanonical()

void dart::UntaggedObject::ClearCanonical ( )
inline

Definition at line 331 of file raw_object.h.

331{ tags_.UpdateBool<CanonicalBit>(false); }
void UpdateBool(bool value)
Definition bitfield.h:58

◆ ClearImmutable()

void dart::UntaggedObject::ClearImmutable ( )
inline

Definition at line 335 of file raw_object.h.

335{ tags_.UpdateBool<ImmutableBit>(false); }

◆ ClearMarkBit()

void dart::UntaggedObject::ClearMarkBit ( )
inline

Definition at line 315 of file raw_object.h.

315 {
316 ASSERT(IsMarked());
317 tags_.UpdateBool<NotMarkedBit>(true);
318 }
bool IsMarked() const
Definition raw_object.h:299
#define ASSERT(E)

◆ ClearMarkBitUnsynchronized()

void dart::UntaggedObject::ClearMarkBitUnsynchronized ( )
inline

Definition at line 319 of file raw_object.h.

319 {
320 ASSERT(IsMarked());
321 tags_.UpdateUnsynchronized<NotMarkedBit>(true);
322 }
void UpdateUnsynchronized(typename TargetBitField::Type value)
Definition bitfield.h:82

◆ ClearRememberedBit()

void dart::UntaggedObject::ClearRememberedBit ( )
inline

Definition at line 348 of file raw_object.h.

348 {
350 tags_.UpdateBool<OldAndNotRememberedBit>(true);
351 }
bool IsOldObject() const
Definition raw_object.h:289

◆ ClearRememberedBitUnsynchronized()

void dart::UntaggedObject::ClearRememberedBitUnsynchronized ( )
inline

Definition at line 352 of file raw_object.h.

352 {
354 tags_.UpdateUnsynchronized<OldAndNotRememberedBit>(true);
355 }

◆ COMPILE_ASSERT() [1/5]

dart::UntaggedObject::COMPILE_ASSERT ( kBitsPerByte *sizeof(ClassIdTagType) >=  kClassIdTagSize)

◆ COMPILE_ASSERT() [2/5]

dart::UntaggedObject::COMPILE_ASSERT ( kCardRememberedBit  = =0)

◆ COMPILE_ASSERT() [3/5]

dart::UntaggedObject::COMPILE_ASSERT ( kClassIdTagMax  = =(1<< kClassIdTagSize) - 1)

◆ COMPILE_ASSERT() [4/5]

dart::UntaggedObject::COMPILE_ASSERT ( kNewBit kBarrierOverlapShift = =kOldAndNotRememberedBit)

◆ COMPILE_ASSERT() [5/5]

dart::UntaggedObject::COMPILE_ASSERT ( kNotMarkedBit kBarrierOverlapShift = =kAlwaysSetBit)

◆ Contains()

bool dart::UntaggedObject::Contains ( uword  addr) const
inline

Definition at line 415 of file raw_object.h.

415 {
416 intptr_t this_size = HeapSize();
417 uword this_addr = UntaggedObject::ToAddr(this);
418 return (addr >= this_addr) && (addr < (this_addr + this_size));
419 }
static uword ToAddr(const UntaggedObject *raw_obj)
Definition raw_object.h:501
intptr_t HeapSize() const
Definition raw_object.h:380
uintptr_t uword
Definition globals.h:501

◆ EnsureInRememberedSet()

DART_FORCE_INLINE void dart::UntaggedObject::EnsureInRememberedSet ( Thread thread)
inline

Definition at line 358 of file raw_object.h.

358 {
360 thread->StoreBufferAddObject(ObjectPtr(this));
361 }
362 }
bool TryAcquireRememberedBit()
Definition raw_object.h:344

◆ ExchangeCompressedPointer()

template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
type dart::UntaggedObject::ExchangeCompressedPointer ( compressed_type const *  addr,
type  value 
)
inlineprotected

Definition at line 675 of file raw_object.h.

675 {
676 compressed_type previous_value =
677 reinterpret_cast<std::atomic<compressed_type>*>(
678 const_cast<compressed_type*>(addr))
679 ->exchange(static_cast<compressed_type>(value), order);
680 if (value.IsHeapObject()) {
681 CheckHeapPointerStore(value, Thread::Current());
682 }
683 return static_cast<type>(previous_value.Decompress(heap_base()));
684 }
static Thread * Current()
Definition thread.h:361
uword heap_base() const
Definition raw_object.h:569
uint8_t value

◆ from_offset() [1/2]

template<typename T >
DART_FORCE_INLINE uword dart::UntaggedObject::from_offset ( )
staticprotected

Definition at line 839 of file raw_object.h.

839 {
840 if constexpr (T::kContainsPointerFields) {
841 return reinterpret_cast<uword>(reinterpret_cast<T*>(kOffsetOfPtr)->from()) -
843 } else {
844 // Non-zero to ensure to_offset() < from_offset() in this case, as
845 // to_offset() is the offset to the last pointer field, not past it.
846 return sizeof(UntaggedObject);
847 }
848}
const intptr_t kOffsetOfPtr
Definition globals.h:136
#define T

◆ from_offset() [2/2]

template<>
DART_FORCE_INLINE uword dart::UntaggedObject::from_offset ( )
staticprotected

Definition at line 1823 of file raw_object.h.

1823 {
1824 return OFFSET_OF(UntaggedWeakArray, next_seen_by_gc_);
1825}
#define OFFSET_OF(type, field)
Definition globals.h:138

◆ FromAddr()

static ObjectPtr dart::UntaggedObject::FromAddr ( uword  addr)
inlinestatic

Definition at line 495 of file raw_object.h.

495 {
496 // We expect the untagged address here.
497 ASSERT((addr & kSmiTagMask) != kHeapObjectTag);
498 return static_cast<ObjectPtr>(addr + kHeapObjectTag);
499 }
@ kHeapObjectTag

◆ GetClassId()

intptr_t dart::UntaggedObject::GetClassId ( ) const
inline

Definition at line 371 of file raw_object.h.

371{ return tags_.Read<ClassIdTag>(); }
TargetBitField::Type Read() const
Definition bitfield.h:47

◆ heap_base()

uword dart::UntaggedObject::heap_base ( ) const
inlineprotected

Definition at line 569 of file raw_object.h.

569 {
570 return reinterpret_cast<uword>(this) & kHeapBaseMask;
571 }
static constexpr uintptr_t kHeapBaseMask

◆ HeapSize() [1/2]

intptr_t dart::UntaggedObject::HeapSize ( ) const
inline

Definition at line 380 of file raw_object.h.

380 {
381 uword tags = tags_;
382 intptr_t result = SizeTag::decode(tags);
383 if (result != 0) {
384#if defined(DEBUG)
385 // TODO(22501) Array::MakeFixedLength has a race with this code: we might
386 // have loaded tags field and then MakeFixedLength could have updated it
387 // leading to inconsistency between HeapSizeFromClass() and
388 // SizeTag::decode(tags). We are working around it by reloading tags_ and
389 // recomputing size from tags.
390 const intptr_t size_from_class = HeapSizeFromClass(tags);
391 if ((result > size_from_class) && (GetClassId() == kArrayCid) &&
392 (tags_ != tags)) {
393 result = SizeTag::decode(tags_);
394 }
395 ASSERT(result == size_from_class);
396#endif
397 return result;
398 }
399 result = HeapSizeFromClass(tags);
401 return result;
402 }
static constexpr intptr_t kMaxSizeTag
Definition raw_object.h:198
static constexpr uword decode(uword tag)
Definition raw_object.h:205
uword tags() const
Definition raw_object.h:294
intptr_t GetClassId() const
Definition raw_object.h:371
GAsyncResult * result

◆ HeapSize() [2/2]

intptr_t dart::UntaggedObject::HeapSize ( uword  tags) const
inline

Definition at line 405 of file raw_object.h.

405 {
406 intptr_t result = SizeTag::decode(tags);
407 if (result != 0) {
408 return result;
409 }
410 result = HeapSizeFromClass(tags);
412 return result;
413 }

◆ InVMIsolateHeap()

bool dart::UntaggedObject::InVMIsolateHeap ( ) const

Definition at line 20 of file raw_object.cc.

20 {
21 // All "vm-isolate" objects are pre-marked and in old space
22 // (see [Object::FinalizeVMIsolate]).
23 if (!IsOldObject() || !IsMarked()) return false;
24
25 auto heap = Dart::vm_isolate_group()->heap();
26 ASSERT(heap->UsedInWords(Heap::kNew) == 0);
27 return heap->old_space()->ContainsUnsafe(ToAddr(this));
28}
static IsolateGroup * vm_isolate_group()
Definition dart.h:69
@ kNew
Definition heap.h:38
Heap * heap() const
Definition isolate.h:295

◆ IsCanonical() [1/2]

bool dart::UntaggedObject::IsCanonical ( ) const
inline

Definition at line 329 of file raw_object.h.

329{ return tags_.Read<CanonicalBit>(); }

◆ IsCanonical() [2/2]

static bool dart::UntaggedObject::IsCanonical ( intptr_t  value)
inlinestatic

Definition at line 508 of file raw_object.h.

508 {
509 return CanonicalBit::decode(value);
510 }
static constexpr bool decode(uword value)
Definition bitfield.h:173

◆ IsCardRemembered()

bool dart::UntaggedObject::IsCardRemembered ( ) const
inline

Definition at line 364 of file raw_object.h.

364{ return tags_.Read<CardRememberedBit>(); }

◆ IsImmutable()

bool dart::UntaggedObject::IsImmutable ( ) const
inline

Definition at line 333 of file raw_object.h.

333{ return tags_.Read<ImmutableBit>(); }

◆ IsMarked() [1/2]

bool dart::UntaggedObject::IsMarked ( ) const
inline

Definition at line 299 of file raw_object.h.

299{ return !tags_.Read<NotMarkedBit>(); }

◆ IsMarked() [2/2]

static bool dart::UntaggedObject::IsMarked ( uword  tags)
inlinestatic

Definition at line 298 of file raw_object.h.

298{ return !NotMarkedBit::decode(tags); }

◆ IsMarkedIgnoreRace()

bool dart::UntaggedObject::IsMarkedIgnoreRace ( ) const
inline

Definition at line 300 of file raw_object.h.

300 {
301 return !tags_.ReadIgnoreRace<NotMarkedBit>();
302 }
NO_SANITIZE_THREAD TargetBitField::Type ReadIgnoreRace() const
Definition bitfield.h:52

◆ IsNewObject()

bool dart::UntaggedObject::IsNewObject ( ) const
inline

Definition at line 284 of file raw_object.h.

284 {
285 uword addr = reinterpret_cast<uword>(this);
287 }
static constexpr intptr_t kNewObjectAlignmentOffset
static constexpr intptr_t kObjectAlignmentMask

◆ IsOldObject()

bool dart::UntaggedObject::IsOldObject ( ) const
inline

Definition at line 289 of file raw_object.h.

289 {
290 uword addr = reinterpret_cast<uword>(this);
292 }
static constexpr intptr_t kOldObjectAlignmentOffset

◆ IsRemembered()

bool dart::UntaggedObject::IsRemembered ( ) const
inline

Definition at line 340 of file raw_object.h.

340 {
342 return !tags_.Read<OldAndNotRememberedBit>();
343 }

◆ LoadCompressedPointer()

template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
type dart::UntaggedObject::LoadCompressedPointer ( compressed_type const *  addr) const
inlineprotected

Definition at line 562 of file raw_object.h.

562 {
563 compressed_type v = reinterpret_cast<std::atomic<compressed_type>*>(
564 const_cast<compressed_type*>(addr))
565 ->load(order);
566 return static_cast<type>(v.Decompress(heap_base()));
567 }

◆ LoadCompressedSmi()

template<std::memory_order order = std::memory_order_relaxed>
SmiPtr dart::UntaggedObject::LoadCompressedSmi ( CompressedSmiPtr const *  addr) const
inlineprotected

Definition at line 692 of file raw_object.h.

692 {
693 return static_cast<SmiPtr>(reinterpret_cast<std::atomic<CompressedSmiPtr>*>(
694 const_cast<CompressedSmiPtr*>(addr))
695 ->load(order)
696 .DecompressSmi());
697 }

◆ LoadPointer()

template<typename type , std::memory_order order = std::memory_order_relaxed>
type dart::UntaggedObject::LoadPointer ( type const *  addr) const
inlineprotected

Definition at line 555 of file raw_object.h.

555 {
556 return reinterpret_cast<std::atomic<type>*>(const_cast<type*>(addr))
557 ->load(order);
558 }

◆ LoadSmi()

template<std::memory_order order = std::memory_order_relaxed>
SmiPtr dart::UntaggedObject::LoadSmi ( SmiPtr const *  addr) const
inlineprotected

Definition at line 687 of file raw_object.h.

687 {
688 return reinterpret_cast<std::atomic<SmiPtr>*>(const_cast<SmiPtr*>(addr))
689 ->load(order);
690 }

◆ SetCanonical()

void dart::UntaggedObject::SetCanonical ( )
inline

Definition at line 330 of file raw_object.h.

330{ tags_.UpdateBool<CanonicalBit>(true); }

◆ SetCardRememberedBitUnsynchronized()

void dart::UntaggedObject::SetCardRememberedBitUnsynchronized ( )
inline

Definition at line 365 of file raw_object.h.

365 {
368 tags_.UpdateUnsynchronized<CardRememberedBit>(true);
369 }
bool IsCardRemembered() const
Definition raw_object.h:364
bool IsRemembered() const
Definition raw_object.h:340

◆ SetImmutable()

void dart::UntaggedObject::SetImmutable ( )
inline

Definition at line 334 of file raw_object.h.

334{ tags_.UpdateBool<ImmutableBit>(true); }

◆ SetMarkBit()

void dart::UntaggedObject::SetMarkBit ( )
inline

Definition at line 303 of file raw_object.h.

303 {
304 ASSERT(!IsMarked());
305 tags_.UpdateBool<NotMarkedBit>(false);
306 }

◆ SetMarkBitRelease()

void dart::UntaggedObject::SetMarkBitRelease ( )
inline

Definition at line 311 of file raw_object.h.

311 {
312 ASSERT(!IsMarked());
313 tags_.UpdateBool<NotMarkedBit, std::memory_order_release>(false);
314 }

◆ SetMarkBitUnsynchronized()

void dart::UntaggedObject::SetMarkBitUnsynchronized ( )
inline

Definition at line 307 of file raw_object.h.

307 {
308 ASSERT(!IsMarked());
309 tags_.UpdateUnsynchronized<NotMarkedBit>(false);
310 }

◆ StoreArrayPointer() [1/2]

template<typename type , std::memory_order order = std::memory_order_relaxed, typename value_type = type>
void dart::UntaggedObject::StoreArrayPointer ( type const *  addr,
value_type  value 
)
inlineprotected

Definition at line 624 of file raw_object.h.

624 {
625 reinterpret_cast<std::atomic<type>*>(const_cast<type*>(addr))
626 ->store(type(value), order);
627 if (value->IsHeapObject()) {
628 CheckArrayPointerStore(addr, value, Thread::Current());
629 }
630 }

◆ StoreArrayPointer() [2/2]

template<typename type , typename value_type = type>
void dart::UntaggedObject::StoreArrayPointer ( type const *  addr,
value_type  value,
Thread thread 
)
inlineprotected

Definition at line 633 of file raw_object.h.

633 {
634 *const_cast<type*>(addr) = value;
635 if (value->IsHeapObject()) {
636 CheckArrayPointerStore(addr, value, thread);
637 }
638 }

◆ StoreCompressedArrayPointer() [1/3]

template<typename type , typename compressed_type , std::memory_order order>
void dart::UntaggedObject::StoreCompressedArrayPointer ( compressed_type const *  addr,
type  value 
)
inlineprotected

Definition at line 641 of file raw_object.h.

641 {
642 reinterpret_cast<std::atomic<compressed_type>*>(
643 const_cast<compressed_type*>(addr))
644 ->store(static_cast<compressed_type>(value), order);
645 if (value->IsHeapObject()) {
646 CheckArrayPointerStore(addr, value, Thread::Current());
647 }
648 }

◆ StoreCompressedArrayPointer() [2/3]

template<typename type , typename compressed_type , std::memory_order order>
void dart::UntaggedObject::StoreCompressedArrayPointer ( compressed_type const *  addr,
type  value,
Thread thread 
)
inlineprotected

Definition at line 651 of file raw_object.h.

653 {
654 reinterpret_cast<std::atomic<compressed_type>*>(
655 const_cast<compressed_type*>(addr))
656 ->store(static_cast<compressed_type>(value), order);
657 if (value->IsHeapObject()) {
658 CheckArrayPointerStore(addr, value, thread);
659 }
660 }

◆ StoreCompressedArrayPointer() [3/3]

template<typename type , typename compressed_type >
void dart::UntaggedObject::StoreCompressedArrayPointer ( compressed_type const *  addr,
type  value,
Thread thread 
)
inlineprotected

Definition at line 663 of file raw_object.h.

665 {
666 *const_cast<compressed_type*>(addr) = value;
667 if (value->IsHeapObject()) {
668 CheckArrayPointerStore(addr, value, thread);
669 }
670 }

◆ StoreCompressedPointer() [1/2]

template<typename type , typename compressed_type , std::memory_order order = std::memory_order_relaxed>
void dart::UntaggedObject::StoreCompressedPointer ( compressed_type const *  addr,
type  value 
)
inlineprotected

Definition at line 585 of file raw_object.h.

585 {
586 reinterpret_cast<std::atomic<compressed_type>*>(
587 const_cast<compressed_type*>(addr))
588 ->store(static_cast<compressed_type>(value), order);
589 if (value.IsHeapObject()) {
590 CheckHeapPointerStore(value, Thread::Current());
591 }
592 }

◆ StoreCompressedPointer() [2/2]

template<typename type , typename compressed_type >
void dart::UntaggedObject::StoreCompressedPointer ( compressed_type const *  addr,
type  value,
Thread thread 
)
inlineprotected

Definition at line 603 of file raw_object.h.

605 {
606 *const_cast<compressed_type*>(addr) = value;
607 if (value.IsHeapObject()) {
608 CheckHeapPointerStore(value, thread);
609 }
610 }

◆ StoreCompressedSmi()

template<std::memory_order order = std::memory_order_relaxed>
void dart::UntaggedObject::StoreCompressedSmi ( CompressedSmiPtr const *  addr,
SmiPtr  value 
)
inlineprotected

Definition at line 709 of file raw_object.h.

709 {
710 // Can't use Contains, as array length is initialized through this method.
711 ASSERT(reinterpret_cast<uword>(addr) >= UntaggedObject::ToAddr(this));
712 reinterpret_cast<std::atomic<CompressedSmiPtr>*>(
713 const_cast<CompressedSmiPtr*>(addr))
714 ->store(static_cast<CompressedSmiPtr>(value), order);
715 }

◆ StorePointer() [1/2]

template<typename type , std::memory_order order = std::memory_order_relaxed>
void dart::UntaggedObject::StorePointer ( type const *  addr,
type  value 
)
inlineprotected

Definition at line 574 of file raw_object.h.

574 {
575 reinterpret_cast<std::atomic<type>*>(const_cast<type*>(addr))
576 ->store(value, order);
577 if (value.IsHeapObject()) {
578 CheckHeapPointerStore(value, Thread::Current());
579 }
580 }

◆ StorePointer() [2/2]

template<typename type >
void dart::UntaggedObject::StorePointer ( type const *  addr,
type  value,
Thread thread 
)
inlineprotected

Definition at line 595 of file raw_object.h.

595 {
596 *const_cast<type*>(addr) = value;
597 if (value.IsHeapObject()) {
598 CheckHeapPointerStore(value, thread);
599 }
600 }

◆ StorePointerUnaligned()

template<typename type >
void dart::UntaggedObject::StorePointerUnaligned ( type const *  addr,
type  value,
Thread thread 
)
inlineprotected

Definition at line 613 of file raw_object.h.

613 {
614 StoreUnaligned(const_cast<type*>(addr), value);
615 if (value->IsHeapObject()) {
616 CheckHeapPointerStore(value, thread);
617 }
618 }
static void StoreUnaligned(T *ptr, T value)
Definition unaligned.h:22

◆ StoreSmi()

template<typename type , std::memory_order order = std::memory_order_relaxed>
void dart::UntaggedObject::StoreSmi ( type const *  addr,
type  value 
)
inlineprotected

Definition at line 702 of file raw_object.h.

702 {
703 // Can't use Contains, as array length is initialized through this method.
704 ASSERT(reinterpret_cast<uword>(addr) >= UntaggedObject::ToAddr(this));
705 reinterpret_cast<std::atomic<type>*>(const_cast<type*>(addr))
706 ->store(value, order);
707 }

◆ tags()

uword dart::UntaggedObject::tags ( ) const
inline

Definition at line 294 of file raw_object.h.

294{ return tags_; }

◆ to_offset() [1/4]

template<>
DART_FORCE_INLINE uword dart::UntaggedObject::to_offset ( intptr_t  length)
staticprotected

Definition at line 3564 of file raw_object.h.

3565 {
3566 return OFFSET_OF(UntaggedWeakProperty, next_seen_by_gc_);
3567}

◆ to_offset() [2/4]

template<>
DART_FORCE_INLINE uword dart::UntaggedObject::to_offset ( intptr_t  length)
staticprotected

Definition at line 3598 of file raw_object.h.

3599 {
3600 return OFFSET_OF(UntaggedWeakReference, next_seen_by_gc_);
3601}

◆ to_offset() [3/4]

template<>
DART_FORCE_INLINE uword dart::UntaggedObject::to_offset ( intptr_t  length)
staticprotected

Definition at line 3710 of file raw_object.h.

3711 {
3712 return OFFSET_OF(UntaggedFinalizerEntry, next_seen_by_gc_);
3713}

◆ to_offset() [4/4]

template<typename T >
DART_FORCE_INLINE uword dart::UntaggedObject::to_offset ( intptr_t  length = 0)
staticprotected

Definition at line 851 of file raw_object.h.

851 {
852 if constexpr (T::kContainsPointerFields) {
853 return reinterpret_cast<uword>(
854 reinterpret_cast<T*>(kOffsetOfPtr)->to(length)) -
856 } else {
857 USE(length);
858 // Zero to ensure to_offset() < from_offset() in this case, as
859 // from_offset() is guaranteed to return an offset after the header tags.
860 return 0;
861 }
862}
size_t length
static void USE(T &&)
Definition globals.h:618

◆ ToAddr() [1/2]

static uword dart::UntaggedObject::ToAddr ( const ObjectPtr  raw_obj)
inlinestatic

Definition at line 504 of file raw_object.h.

504 {
505 return static_cast<uword>(raw_obj) - kHeapObjectTag;
506 }

◆ ToAddr() [2/2]

static uword dart::UntaggedObject::ToAddr ( const UntaggedObject raw_obj)
inlinestatic

Definition at line 501 of file raw_object.h.

501 {
502 return reinterpret_cast<uword>(raw_obj);
503 }

◆ TryAcquireMarkBit()

DART_WARN_UNUSED_RESULT bool dart::UntaggedObject::TryAcquireMarkBit ( )
inline

Definition at line 325 of file raw_object.h.

325{ return tags_.TryClear<NotMarkedBit>(); }

◆ TryAcquireRememberedBit()

bool dart::UntaggedObject::TryAcquireRememberedBit ( )
inline

Definition at line 344 of file raw_object.h.

344 {
346 return tags_.TryClear<OldAndNotRememberedBit>();
347 }

◆ Validate()

void dart::UntaggedObject::Validate ( IsolateGroup isolate_group) const

Definition at line 42 of file raw_object.cc.

42 {
43 if (static_cast<uword>(Object::void_class_) == kHeapObjectTag) {
44 // Validation relies on properly initialized class classes. Skip if the
45 // VM is still being initialized.
46 return;
47 }
48 // Validate that the tags_ field is sensible.
49 uword tags = tags_;
50 if (IsNewObject()) {
51 if (!NewBit::decode(tags)) {
52 FATAL("New object missing kNewBit: %" Px "\n", tags);
53 }
55 FATAL("New object has kOldAndNotRememberedBit: %" Px "\n", tags);
56 }
57 } else {
58 if (NewBit::decode(tags)) {
59 FATAL("Old object has kNewBit: %" Px "\n", tags);
60 }
61 }
62 const intptr_t class_id = ClassIdTag::decode(tags);
63 if (!isolate_group->class_table()->IsValidIndex(class_id)) {
64 FATAL("Invalid class id encountered %" Pd "\n", class_id);
65 }
66 if (class_id == kNullCid &&
67 isolate_group->class_table()->HasValidClassAt(class_id)) {
68 // Null class not yet initialized; skip.
69 return;
70 }
71 intptr_t size_from_tags = SizeTag::decode(tags);
72 intptr_t size_from_class = HeapSizeFromClass(tags);
73 if ((size_from_tags != 0) && (size_from_tags != size_from_class)) {
74 FATAL(
75 "Inconsistent size encountered "
76 "cid: %" Pd ", size_from_tags: %" Pd ", size_from_class: %" Pd "\n",
77 class_id, size_from_tags, size_from_class);
78 }
79}
bool IsNewObject() const
Definition raw_object.h:284
#define FATAL(error)
@ kNullCid
Definition class_id.h:252
#define Px
Definition globals.h:410
#define Pd
Definition globals.h:408

◆ VisitPointers()

intptr_t dart::UntaggedObject::VisitPointers ( ObjectPointerVisitor visitor)
inline

Definition at line 426 of file raw_object.h.

426 {
427 // Fall back to virtual variant for predefined classes
428 intptr_t class_id = GetClassId();
429 if (class_id < kNumPredefinedCids) {
430 return VisitPointersPredefined(visitor, class_id);
431 }
432
433 // Calculate the first and last raw object pointer fields.
434 intptr_t instance_size = HeapSize();
435 uword obj_addr = ToAddr(this);
436 uword from = obj_addr + sizeof(UntaggedObject);
437 uword to = obj_addr + instance_size - kCompressedWordSize;
438 const auto first = reinterpret_cast<CompressedObjectPtr*>(from);
439 const auto last = reinterpret_cast<CompressedObjectPtr*>(to);
440
441 const auto unboxed_fields_bitmap =
442 visitor->class_table()->GetUnboxedFieldsMapAt(class_id);
443
444 if (!unboxed_fields_bitmap.IsEmpty()) {
445 intptr_t bit = sizeof(UntaggedObject) / kCompressedWordSize;
446 for (CompressedObjectPtr* current = first; current <= last; current++) {
447 if (!unboxed_fields_bitmap.Get(bit++)) {
448 visitor->VisitCompressedPointers(heap_base(), current, current);
449 }
450 }
451 } else {
452 visitor->VisitCompressedPointers(heap_base(), first, last);
453 }
454
455 return instance_size;
456 }
@ kNumPredefinedCids
Definition class_id.h:257
static constexpr intptr_t kCompressedWordSize
Definition globals.h:42
ObjectPtr CompressedObjectPtr

◆ VisitPointersNonvirtual()

template<class V >
DART_FORCE_INLINE intptr_t dart::UntaggedObject::VisitPointersNonvirtual ( V visitor)
inline

Definition at line 459 of file raw_object.h.

459 {
460 // Fall back to virtual variant for predefined classes
461 intptr_t class_id = GetClassId();
462 if (class_id < kNumPredefinedCids) {
463 return VisitPointersPredefined(visitor, class_id);
464 }
465
466 // Calculate the first and last raw object pointer fields.
467 intptr_t instance_size = HeapSize();
468 uword obj_addr = ToAddr(this);
469 uword from = obj_addr + sizeof(UntaggedObject);
470 uword to = obj_addr + instance_size - kCompressedWordSize;
471 const auto first = reinterpret_cast<CompressedObjectPtr*>(from);
472 const auto last = reinterpret_cast<CompressedObjectPtr*>(to);
473
474 const auto unboxed_fields_bitmap =
475 visitor->class_table()->GetUnboxedFieldsMapAt(class_id);
476
477 if (!unboxed_fields_bitmap.IsEmpty()) {
478 intptr_t bit = sizeof(UntaggedObject) / kCompressedWordSize;
479 for (CompressedObjectPtr* current = first; current <= last; current++) {
480 if (!unboxed_fields_bitmap.Get(bit++)) {
481 visitor->V::VisitCompressedPointers(heap_base(), current, current);
482 }
483 }
484 } else {
485 visitor->V::VisitCompressedPointers(heap_base(), first, last);
486 }
487
488 return instance_size;
489 }

◆ VisitPointersPrecise()

void dart::UntaggedObject::VisitPointersPrecise ( ObjectPointerVisitor visitor)

Definition at line 375 of file raw_object.cc.

375 {
376 intptr_t class_id = GetClassId();
377 if ((class_id != kInstanceCid) && (class_id < kNumPredefinedCids)) {
378 VisitPointersPredefined(visitor, class_id);
379 return;
380 }
381
382 // N.B.: Not using the heap size!
383 uword next_field_offset = visitor->class_table()
384 ->At(class_id)
385 ->untag()
386 ->host_next_field_offset_in_words_
388 ASSERT(next_field_offset > 0);
389 uword obj_addr = UntaggedObject::ToAddr(this);
390 uword from = obj_addr + sizeof(UntaggedObject);
391 uword to = obj_addr + next_field_offset - kCompressedWordSize;
392 const auto first = reinterpret_cast<CompressedObjectPtr*>(from);
393 const auto last = reinterpret_cast<CompressedObjectPtr*>(to);
394
395 const auto unboxed_fields_bitmap =
396 visitor->class_table()->GetUnboxedFieldsMapAt(class_id);
397
398 if (!unboxed_fields_bitmap.IsEmpty()) {
399 intptr_t bit = sizeof(UntaggedObject) / kCompressedWordSize;
400 for (CompressedObjectPtr* current = first; current <= last; current++) {
401 if (!unboxed_fields_bitmap.Get(bit++)) {
402 visitor->VisitCompressedPointers(heap_base(), current, current);
403 }
404 }
405 } else {
406 visitor->VisitCompressedPointers(heap_base(), first, last);
407 }
408}
static constexpr intptr_t kCompressedWordSizeLog2
Definition globals.h:43

Friends And Related Symbol Documentation

◆ Array

friend class Array
friend

Definition at line 784 of file raw_object.h.

◆ AssemblyImageWriter

friend class AssemblyImageWriter
friend

Definition at line 810 of file raw_object.h.

◆ BlobImageWriter

friend class BlobImageWriter
friend

Definition at line 811 of file raw_object.h.

◆ ByteBuffer

friend class ByteBuffer
friend

Definition at line 785 of file raw_object.h.

◆ CidRewriteVisitor

friend class CidRewriteVisitor
friend

Definition at line 786 of file raw_object.h.

◆ Closure

friend class Closure
friend

Definition at line 787 of file raw_object.h.

◆ Code

friend class Code
friend

Definition at line 788 of file raw_object.h.

◆ CodeLookupTableBuilder

friend class CodeLookupTableBuilder
friend

Definition at line 817 of file raw_object.h.

◆ Deserializer

friend class Deserializer
friend

Definition at line 812 of file raw_object.h.

◆ Double

friend class Double
friend

Definition at line 790 of file raw_object.h.

◆ DynamicLibrary

friend class DynamicLibrary
friend

Definition at line 791 of file raw_object.h.

◆ ExternalTypedData

friend class ExternalTypedData
friend

Definition at line 797 of file raw_object.h.

◆ ForwardPointersVisitor

friend class ForwardPointersVisitor
friend

Definition at line 792 of file raw_object.h.

◆ FreeListElement

friend class FreeListElement
friend

Definition at line 793 of file raw_object.h.

◆ Function

friend class Function
friend

Definition at line 794 of file raw_object.h.

◆ GCMarker

friend class GCMarker
friend

Definition at line 795 of file raw_object.h.

◆ GCSweeper

friend class GCSweeper
friend

Definition at line 796 of file raw_object.h.

◆ GrowableObjectArray

friend class GrowableObjectArray
friend

Definition at line 798 of file raw_object.h.

◆ ImageReader

friend class ImageReader
friend

Definition at line 808 of file raw_object.h.

◆ ImageWriter

friend class ImageWriter
friend

Definition at line 809 of file raw_object.h.

◆ Instance

friend class Instance
friend

Definition at line 815 of file raw_object.h.

◆ MarkingVisitorBase

template<bool >
friend class MarkingVisitorBase
friend

Definition at line 800 of file raw_object.h.

◆ Mint

friend class Mint
friend

Definition at line 801 of file raw_object.h.

◆ Object

Object
friend

Definition at line 802 of file raw_object.h.

◆ ObjectCopyBase

friend class ObjectCopyBase
friend

Definition at line 824 of file raw_object.h.

◆ ObjectLocator

friend class ObjectLocator
friend

Definition at line 818 of file raw_object.h.

◆ OffsetsTable

friend class OffsetsTable
friend

Definition at line 820 of file raw_object.h.

◆ OneByteString

friend class OneByteString
friend

Definition at line 803 of file raw_object.h.

◆ Pointer

friend class Pointer
friend

Definition at line 789 of file raw_object.h.

◆ ReportImpossibleNullError

void ReportImpossibleNullError ( intptr_t  cid,
StackFrame caller_frame,
Thread thread 
)
friend

Definition at line 273 of file runtime_entry.cc.

275 {
276 TextBuffer buffer(512);
277 buffer.Printf("hit null error with cid %" Pd ", caller context: ", cid);
278
279 const intptr_t kMaxSlotsCollected = 5;
280 const auto slots = reinterpret_cast<ObjectPtr*>(caller_frame->sp());
281 const intptr_t num_slots_in_frame =
282 reinterpret_cast<ObjectPtr*>(caller_frame->fp()) - slots;
283 const auto num_slots_to_collect =
284 Utils::Maximum(kMaxSlotsCollected, num_slots_in_frame);
285 bool comma = false;
286 for (intptr_t i = 0; i < num_slots_to_collect; i++) {
287 const ObjectPtr ptr = slots[i];
288 buffer.Printf("%s[sp+%" Pd "] %" Pp "", comma ? ", " : "", i,
289 static_cast<uword>(ptr));
290 if (ptr->IsHeapObject() &&
293 thread->heap()->Contains(UntaggedObject::ToAddr(ptr)))) {
294 buffer.Printf("(%" Pp ")", static_cast<uword>(ptr->untag()->tags_));
295 }
296 comma = true;
297 }
298
299 const char* message = buffer.buffer();
300 FATAL("%s", message);
301}
bool Contains(uword addr) const
Definition heap.cc:238
static constexpr T Maximum(T x, T y)
Definition utils.h:26
static const uint8_t buffer[]
Win32Message message
const intptr_t cid
#define Pp
Definition globals.h:425

◆ Scavenger

friend class Scavenger
friend

Definition at line 805 of file raw_object.h.

◆ ScavengerVisitorBase

template<bool >
friend class ScavengerVisitorBase
friend

Definition at line 807 of file raw_object.h.

◆ SetNewSpaceTaggingWord

void SetNewSpaceTaggingWord ( ObjectPtr  to,
classid_t  cid,
uint32_t  size 
)
friend

Definition at line 229 of file object_graph_copy.cc.

229 {
230 uword tags = 0;
231
241#if defined(HASH_IN_OBJECT_HEADER)
242 tags = UntaggedObject::HashTag::update(0, tags);
243#endif
244 to.untag()->tags_ = tags;
245}
static constexpr uword update(ClassIdTagType value, uword original)
Definition bitfield.h:190
static constexpr uword update(intptr_t size, uword tag)
Definition raw_object.h:209
bool IsUnmodifiableTypedDataViewClassId(intptr_t index)
Definition class_id.h:453

◆ StackFrame

friend class StackFrame
friend

Definition at line 816 of file raw_object.h.

◆ StoreBufferUpdateVisitor

friend class StoreBufferUpdateVisitor
friend

Definition at line 778 of file raw_object.h.

◆ String

friend class String
friend

Definition at line 813 of file raw_object.h.

◆ TagsFromUntaggedObject

uword TagsFromUntaggedObject ( UntaggedObject obj)
friend

Definition at line 224 of file object_graph_copy.cc.

224 {
225 return obj->tags_;
226}

◆ UntaggedInstance

friend class UntaggedInstance
friend

Definition at line 804 of file raw_object.h.

◆ WeakProperty

friend class WeakProperty
friend

Definition at line 814 of file raw_object.h.

◆ WriteBarrierUpdateVisitor

friend class WriteBarrierUpdateVisitor
friend

Definition at line 819 of file raw_object.h.

Member Data Documentation

◆ kBarrierOverlapShift

constexpr intptr_t dart::UntaggedObject::kBarrierOverlapShift = 2
staticconstexpr

Definition at line 182 of file raw_object.h.

◆ kContainsCompressedPointers

constexpr bool dart::UntaggedObject::kContainsCompressedPointers = false
staticconstexprprotected

Definition at line 527 of file raw_object.h.

◆ kContainsPointerFields

constexpr bool dart::UntaggedObject::kContainsPointerFields = false
staticconstexprprotected

Definition at line 529 of file raw_object.h.

◆ kGenerationalBarrierMask

constexpr intptr_t dart::UntaggedObject::kGenerationalBarrierMask = 1 << kNewBit
staticconstexpr

Definition at line 180 of file raw_object.h.

◆ kIncrementalBarrierMask

constexpr intptr_t dart::UntaggedObject::kIncrementalBarrierMask = 1 << kNotMarkedBit
staticconstexpr

Definition at line 181 of file raw_object.h.


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