From 5ffa0780a2738eed1f86efb967ea99badcbd5d9c Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Wed, 27 Jul 2016 10:45:47 -0700 Subject: Reduce unnecessary read barriers in GC Removed read barrier from IsUnprocessed, DequeuePendingReference, EnqueueReference, and a few other places. Hard to tell if GC time goes down. EAAC: Before GC slow path count: 254857 After GC slow path count: 1005 Bug: 30162165 Bug: 12687968 Test: test-art-host, volantis boot with CC Change-Id: Ic2add3a9b1e1d7561b0b167f2218b10f8dbff76c --- runtime/gc/reference_queue.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'runtime/gc/reference_queue.cc') diff --git a/runtime/gc/reference_queue.cc b/runtime/gc/reference_queue.cc index 6088a43ab1..62625c41b4 100644 --- a/runtime/gc/reference_queue.cc +++ b/runtime/gc/reference_queue.cc @@ -44,7 +44,9 @@ void ReferenceQueue::EnqueueReference(mirror::Reference* ref) { // 1 element cyclic queue, ie: Reference ref = ..; ref.pendingNext = ref; list_ = ref; } else { - mirror::Reference* head = list_->GetPendingNext(); + // The list is owned by the GC, everything that has been inserted must already be at least + // gray. + mirror::Reference* head = list_->GetPendingNext(); DCHECK(head != nullptr); ref->SetPendingNext(head); } @@ -54,14 +56,14 @@ void ReferenceQueue::EnqueueReference(mirror::Reference* ref) { mirror::Reference* ReferenceQueue::DequeuePendingReference() { DCHECK(!IsEmpty()); - mirror::Reference* ref = list_->GetPendingNext(); + mirror::Reference* ref = list_->GetPendingNext(); DCHECK(ref != nullptr); // Note: the following code is thread-safe because it is only called from ProcessReferences which // is single threaded. if (list_ == ref) { list_ = nullptr; } else { - mirror::Reference* next = ref->GetPendingNext(); + mirror::Reference* next = ref->GetPendingNext(); list_->SetPendingNext(next); } ref->SetPendingNext(nullptr); -- cgit v1.2.3-59-g8ed1b