// Used to temporarily store java.lang.ref.Reference(s) during GC and prior to queueing on the // appropriate java.lang.ref.ReferenceQueue. The linked list is maintained as an unordered, // circular, and singly-linked list using the pendingNext fields of the java.lang.ref.Reference // objects. class ReferenceQueue { public: explicit ReferenceQueue(Mutex* lock);
// Enqueue a reference if it is unprocessed. Thread safe to call from multiple // threads since it uses a lock to avoid a race between checking for the references presence and // adding it. void AtomicEnqueueIfNotEnqueued(Thread* self, ObjPtr<mirror::Reference> ref)
REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!*lock_);
// Enqueue a reference. The reference must be unprocessed. // Not thread safe, used when mutators are paused to minimize lock overhead. void EnqueueReference(ObjPtr<mirror::Reference> ref) REQUIRES_SHARED(Locks::mutator_lock_);
// Dequeue a reference from the queue and return that dequeued reference. // Call DisableReadBarrierForReference for the reference that's returned from this function.
ObjPtr<mirror::Reference> DequeuePendingReference() REQUIRES_SHARED(Locks::mutator_lock_);
// If applicable, disable the read barrier for the reference after its referent is handled (see // ConcurrentCopying::ProcessMarkStackRef.) This must be called for a reference that's dequeued // from pending queue (DequeuePendingReference). 'order' is expected to be // 'release' if called outside 'weak-ref access disabled' critical section. // Otherwise 'relaxed' order will suffice. void DisableReadBarrierForReference(ObjPtr<mirror::Reference> ref, std::memory_order order)
REQUIRES_SHARED(Locks::mutator_lock_);
// Enqueues finalizer references with white referents. White referents are blackened, moved to // the zombie field, and the referent field is cleared.
FinalizerStats EnqueueFinalizerReferences(ReferenceQueue* cleared_references,
collector::GarbageCollector* collector)
REQUIRES_SHARED(Locks::mutator_lock_);
// Walks the reference list marking and dequeuing any references subject to the reference // clearing policy. References with a black referent are removed from the list. References // with white referents biased toward saving are blackened and also removed from the list. // Returns the number of non-null soft references. May be called concurrently with // AtomicEnqueueIfNotEnqueued().
uint32_t ForwardSoftReferences(MarkObjectVisitor* visitor)
REQUIRES(!*lock_)
REQUIRES_SHARED(Locks::mutator_lock_);
// Unlink the reference list clearing references objects with white referents. Cleared references // registered to a reference queue are scheduled for appending by the heap worker thread. void ClearWhiteReferences(ReferenceQueue* cleared_references,
collector::GarbageCollector* collector, bool report_cleared = false)
REQUIRES_SHARED(Locks::mutator_lock_);
// Visits list_, currently only used for the mark compact GC. void UpdateRoots(IsMarkedVisitor* visitor)
REQUIRES_SHARED(Locks::mutator_lock_);
private: // Lock, used for parallel GC reference enqueuing. It allows for multiple threads simultaneously // calling AtomicEnqueueIfNotEnqueued.
Mutex* const lock_; // The actual reference list. Only a root for the mark compact GC since it // will be null during root marking for other GC types. Not an ObjPtr since it // is accessed from multiple threads. Points to a singly-linked circular list // using the pendingNext field.
mirror::Reference* list_;
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.