summaryrefslogtreecommitdiff
path: root/runtime/gc/reference_queue.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/gc/reference_queue.cc')
-rw-r--r--runtime/gc/reference_queue.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/runtime/gc/reference_queue.cc b/runtime/gc/reference_queue.cc
index 1c751e1fbd..1e3cf93495 100644
--- a/runtime/gc/reference_queue.cc
+++ b/runtime/gc/reference_queue.cc
@@ -152,10 +152,12 @@ void ReferenceQueue::ClearWhiteReferences(ReferenceQueue* cleared_references,
}
}
-void ReferenceQueue::EnqueueFinalizerReferences(ReferenceQueue* cleared_references,
+FinalizerStats ReferenceQueue::EnqueueFinalizerReferences(ReferenceQueue* cleared_references,
collector::GarbageCollector* collector) {
+ uint32_t num_refs(0), num_enqueued(0);
while (!IsEmpty()) {
ObjPtr<mirror::FinalizerReference> ref = DequeuePendingReference()->AsFinalizerReference();
+ ++num_refs;
mirror::HeapReference<mirror::Object>* referent_addr = ref->GetReferentReferenceAddr();
// do_atomic_update is false because this happens during the reference processing phase where
// Reference.clear() would block.
@@ -170,17 +172,20 @@ void ReferenceQueue::EnqueueFinalizerReferences(ReferenceQueue* cleared_referenc
ref->ClearReferent<false>();
}
cleared_references->EnqueueReference(ref);
+ ++num_enqueued;
}
// Delay disabling the read barrier until here so that the ClearReferent call above in
// transaction mode will trigger the read barrier.
DisableReadBarrierForReference(ref->AsReference());
}
+ return FinalizerStats(num_refs, num_enqueued);
}
-void ReferenceQueue::ForwardSoftReferences(MarkObjectVisitor* visitor) {
+uint32_t ReferenceQueue::ForwardSoftReferences(MarkObjectVisitor* visitor) {
if (UNLIKELY(IsEmpty())) {
- return;
+ return 0;
}
+ uint32_t num_refs(0);
const ObjPtr<mirror::Reference> head = list_;
ObjPtr<mirror::Reference> ref = head;
do {
@@ -189,9 +194,11 @@ void ReferenceQueue::ForwardSoftReferences(MarkObjectVisitor* visitor) {
// do_atomic_update is false because mutators can't access the referent due to the weak ref
// access blocking.
visitor->MarkHeapReference(referent_addr, /*do_atomic_update=*/ false);
+ ++num_refs;
}
ref = ref->GetPendingNext();
} while (LIKELY(ref != head));
+ return num_refs;
}
void ReferenceQueue::UpdateRoots(IsMarkedVisitor* visitor) {