diff options
author | 2019-04-19 17:34:31 -0700 | |
---|---|---|
committer | 2019-04-25 16:06:24 +0000 | |
commit | 81dc7ab1df59021463757e06a95b2abc937a73db (patch) | |
tree | 3ae773ed2d58546cfd0bfd8c07f659985d75bdd6 /runtime/base/mutex-inl.h | |
parent | fe9181db92a778c4ef3c4d25e0302553bf970e26 (diff) |
Speed up and slightly simplify Mutex
Eliminate the separate seqentially consistent contention counter load
in Mutex::ExclusiveUnlock by putting the contenion counter in the
Mutex's state word.
Replace some CHECK_GE checks with CHECK_GT. We were checking quantities
intended to be non-negative against >= 0 just before decrementing them.
Remove a pointless volatile declaration.
Introduce constants for the first FUTEX_WAKE argument. Remove all uses
of -1 as that argument, everywhere in ART. It appears to work, but the
documentation says it's wrong.
This does not yet address the ReaderWriterMutex issue, which is handled
in a different way in a separate CL.
Benchmark runs with and without this CL weakly suggest a tiny, not
statistically significant, improvement in both time and space with this
CL.
Bug: 111835365
Test: Build and boot AOSP. TreeHugger.
Change-Id: Ie53c65f2ce774a8cb4d224e2c1b3a110eb880f0c
Diffstat (limited to 'runtime/base/mutex-inl.h')
-rw-r--r-- | runtime/base/mutex-inl.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/runtime/base/mutex-inl.h b/runtime/base/mutex-inl.h index 98e23b4036..22b76d231b 100644 --- a/runtime/base/mutex-inl.h +++ b/runtime/base/mutex-inl.h @@ -209,7 +209,7 @@ inline void ReaderWriterMutex::SharedUnlock(Thread* self) { if (done && (cur_state - 1) == 0) { // Weak CAS may fail spuriously. if (num_contenders_.load(std::memory_order_seq_cst) > 0) { // Wake any exclusive waiters as there are now no readers. - futex(state_.Address(), FUTEX_WAKE_PRIVATE, -1, nullptr, nullptr, 0); + futex(state_.Address(), FUTEX_WAKE_PRIVATE, kWakeAll, nullptr, nullptr, 0); } } } else { |