namespace art HIDDEN { namespace mirror { class Object; template<typename MirrorType> class HeapReference;
} // namespace mirror class ArtMethod;
class ReadBarrier { public: // Enable the to-space invariant checks. This is slow and happens very often. Do not enable in // fast-debug environment.
DECLARE_RUNTIME_DEBUG_FLAG(kEnableToSpaceInvariantChecks);
// Enable the read barrier checks. This is slow and happens very often. Do not enable in // fast-debug environment.
DECLARE_RUNTIME_DEBUG_FLAG(kEnableReadBarrierInvariantChecks);
// Return the reference at ref_addr, invoking read barrier as appropriate. // Ref_addr is an address within obj. // It's up to the implementation whether the given field gets updated whereas the return value // must be an updated reference unless kAlwaysUpdateField is true. template <typename MirrorType, bool kIsVolatile,
ReadBarrierOption kReadBarrierOption = kWithReadBarrier, bool kAlwaysUpdateField = false>
ALWAYS_INLINE static MirrorType* Barrier(
mirror::Object* obj, MemberOffset offset, mirror::HeapReference<MirrorType>* ref_addr)
REQUIRES_SHARED(Locks::mutator_lock_);
// It's up to the implementation whether the given root gets updated // whereas the return value must be an updated reference. template <typename MirrorType, ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
ALWAYS_INLINE static MirrorType* BarrierForRoot(MirrorType** root,
GcRootSource* gc_root_source = nullptr)
REQUIRES_SHARED(Locks::mutator_lock_);
// It's up to the implementation whether the given root gets updated // whereas the return value must be an updated reference. template <typename MirrorType, ReadBarrierOption kReadBarrierOption = kWithReadBarrier>
ALWAYS_INLINE static MirrorType* BarrierForRoot(mirror::CompressedReference<MirrorType>* root,
GcRootSource* gc_root_source = nullptr)
REQUIRES_SHARED(Locks::mutator_lock_);
// Return the mirror Object if it is marked, or null if not. template <typename MirrorType>
ALWAYS_INLINE static MirrorType* IsMarked(MirrorType* ref)
REQUIRES_SHARED(Locks::mutator_lock_);
staticbool IsDuringStartup();
// Without the holder object. staticvoid AssertToSpaceInvariant(mirror::Object* ref)
REQUIRES_SHARED(Locks::mutator_lock_) {
AssertToSpaceInvariant(nullptr, MemberOffset(0), ref);
} // With the holder object. staticvoid AssertToSpaceInvariant(mirror::Object* obj, MemberOffset offset,
mirror::Object* ref)
REQUIRES_SHARED(Locks::mutator_lock_); // With GcRootSource. staticvoid AssertToSpaceInvariant(GcRootSource* gc_root_source, mirror::Object* ref)
REQUIRES_SHARED(Locks::mutator_lock_);
// Without the holder object, and only with the read barrier configuration (no-op otherwise). staticvoid MaybeAssertToSpaceInvariant(mirror::Object* ref)
REQUIRES_SHARED(Locks::mutator_lock_) { if (gUseReadBarrier) {
AssertToSpaceInvariant(ref);
}
}
// ALWAYS_INLINE on this caused a performance regression b/26744236. static mirror::Object* Mark(mirror::Object* obj) REQUIRES_SHARED(Locks::mutator_lock_);
// fake_address_dependency will be zero which should be bitwise-or'ed with the address of the // subsequent load to prevent the reordering of the read barrier bit load and the subsequent // object reference load (from one of `obj`'s fields). // *fake_address_dependency will be set to 0.
ALWAYS_INLINE staticbool IsGray(mirror::Object* obj, uintptr_t* fake_address_dependency)
REQUIRES_SHARED(Locks::mutator_lock_);
// This uses a load-acquire to load the read barrier bit internally to prevent the reordering of // the read barrier bit load and the subsequent load.
ALWAYS_INLINE staticbool IsGray(mirror::Object* obj)
REQUIRES_SHARED(Locks::mutator_lock_);
private: static constexpr uint32_t kNonGrayState = 0x0; // White (not marked) or black (marked through). static constexpr uint32_t kGrayState = 0x1; // Marked, but not marked through. On mark stack. static constexpr uint32_t kRBStateMask = 0x1; // The low bits for non-gray|gray.
};
} // namespace art
#endif// ART_RUNTIME_READ_BARRIER_H_
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.