diff options
author | Ian Rogers <irogers@google.com> | 2014-10-22 22:06:39 -0700 |
---|---|---|
committer | Ian Rogers <irogers@google.com> | 2014-10-22 22:21:57 -0700 |
commit | cf7f19135f0e273f7b0136315633c2abfc715343 (patch) | |
tree | ffa4d9efd9c45f4b6789acc1f534bb9327052b7e /runtime/base/mutex-inl.h | |
parent | aea6888b056be21adf762e066c7f33b8939b8a06 (diff) | |
download | art-cf7f19135f0e273f7b0136315633c2abfc715343.zip art-cf7f19135f0e273f7b0136315633c2abfc715343.tar.gz art-cf7f19135f0e273f7b0136315633c2abfc715343.tar.bz2 |
C++11 related clean-up of DISALLOW_..
Move DISALLOW_COPY_AND_ASSIGN to delete functions. By no having declarations
with no definitions this prompts better warning messages so deal with these
by correcting the code.
Add a DISALLOW_ALLOCATION and use for ValueObject and mirror::Object.
Make X86 assembly operand types ValueObjects to fix compilation errors.
Tidy the use of iostream and ostream.
Avoid making cutils a dependency via mutex-inl.h for tests that link against
libart. Push tracing dependencies into appropriate files and mutex.cc.
x86 32-bit host symbols size is increased for libarttest, avoid copying this
in run-test 115 by using symlinks and remove this test's higher than normal
ulimit.
Fix the RunningOnValgrind test in RosAllocSpace to not use GetHeap as it
returns NULL when the heap is under construction by Runtime.
Change-Id: Ia246f7ac0c11f73072b30d70566a196e9b78472b
Diffstat (limited to 'runtime/base/mutex-inl.h')
-rw-r--r-- | runtime/base/mutex-inl.h | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/runtime/base/mutex-inl.h b/runtime/base/mutex-inl.h index f70db35..e066787 100644 --- a/runtime/base/mutex-inl.h +++ b/runtime/base/mutex-inl.h @@ -21,11 +21,8 @@ #include "mutex.h" -#define ATRACE_TAG ATRACE_TAG_DALVIK - -#include "cutils/trace.h" - #include "base/stringprintf.h" +#include "base/value_object.h" #include "runtime.h" #include "thread.h" @@ -44,35 +41,6 @@ static inline int futex(volatile int *uaddr, int op, int val, const struct times } #endif // ART_USE_FUTEXES -class ScopedContentionRecorder { - public: - ScopedContentionRecorder(BaseMutex* mutex, uint64_t blocked_tid, uint64_t owner_tid) - : mutex_(kLogLockContentions ? mutex : NULL), - blocked_tid_(kLogLockContentions ? blocked_tid : 0), - owner_tid_(kLogLockContentions ? owner_tid : 0), - start_nano_time_(kLogLockContentions ? NanoTime() : 0) { - if (ATRACE_ENABLED()) { - std::string msg = StringPrintf("Lock contention on %s (owner tid: %" PRIu64 ")", - mutex->GetName(), owner_tid); - ATRACE_BEGIN(msg.c_str()); - } - } - - ~ScopedContentionRecorder() { - ATRACE_END(); - if (kLogLockContentions) { - uint64_t end_nano_time = NanoTime(); - mutex_->RecordContention(blocked_tid_, owner_tid_, end_nano_time - start_nano_time_); - } - } - - private: - BaseMutex* const mutex_; - const uint64_t blocked_tid_; - const uint64_t owner_tid_; - const uint64_t start_nano_time_; -}; - static inline uint64_t SafeGetTid(const Thread* self) { if (self != NULL) { return static_cast<uint64_t>(self->GetTid()); @@ -158,15 +126,7 @@ inline void ReaderWriterMutex::SharedLock(Thread* self) { // Add as an extra reader. done = state_.CompareExchangeWeakAcquire(cur_state, cur_state + 1); } else { - // Owner holds it exclusively, hang up. - ScopedContentionRecorder scr(this, GetExclusiveOwnerTid(), SafeGetTid(self)); - ++num_pending_readers_; - if (futex(state_.Address(), FUTEX_WAIT, cur_state, NULL, NULL, 0) != 0) { - if (errno != EAGAIN) { - PLOG(FATAL) << "futex wait failed for " << name_; - } - } - --num_pending_readers_; + HandleSharedLockContention(self, cur_state); } } while (!done); #else |