diff options
author | 2017-06-02 10:29:26 -0700 | |
---|---|---|
committer | 2017-06-05 17:32:17 -0700 | |
commit | f81e6566a4d8f6ee6160ab61e23404cf28eacb7c (patch) | |
tree | ac4ef07c7ce33ff0c5912540cd34c5639a47023a | |
parent | 596c58b3dc73a4017d49af6c5037bbd7109fd31e (diff) |
Document and use AtomicStack concurrency properties
Document the fact that most AtomicStack operations are not atomic,
and document the one case in which they are.
I initially believed, based on its implementation, that PopBackCount
was also intended to be callable concurrently with other PopBackCount
calls. But the SequentiallyConsistent requirement still made
no sense, since there can't safely be any concurrent readers.
On closer inspection, its only client assumes that it has exclusive
access to the stack. Thus this removes the unused, and probably
unusable, thread-safety overhead.
Test: Builds. TreeHugger.
Bug: 62270718
Change-Id: I38e8413fd1851af59a30313f28864496f1d9458b
-rw-r--r-- | runtime/gc/accounting/atomic_stack.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/runtime/gc/accounting/atomic_stack.h b/runtime/gc/accounting/atomic_stack.h index 351798efd1..3d0e8172b6 100644 --- a/runtime/gc/accounting/atomic_stack.h +++ b/runtime/gc/accounting/atomic_stack.h @@ -29,6 +29,13 @@ #include "mem_map.h" #include "stack_reference.h" +// This implements a double-ended queue (deque) with various flavors of PushBack operations, +// as well as PopBack and PopFront operations. We expect that all calls are performed +// by a single thread (normally the GC). There is one exception, which accounts for the +// name: +// - Multiple calls to AtomicPushBack*() and AtomicBumpBack() may be made concurrently, +// provided no other calls are made at the same time. + namespace art { namespace gc { namespace accounting { @@ -150,7 +157,7 @@ class AtomicStack { // Pop a number of elements. void PopBackCount(int32_t n) { DCHECK_GE(Size(), static_cast<size_t>(n)); - back_index_.FetchAndSubSequentiallyConsistent(n); + back_index_.StoreRelaxed(back_index_.LoadRelaxed() - n); } bool IsEmpty() const { |