diff options
Diffstat (limited to 'runtime/base/mutex.cc')
-rw-r--r-- | runtime/base/mutex.cc | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc index 5b74bee279..728dc842c2 100644 --- a/runtime/base/mutex.cc +++ b/runtime/base/mutex.cc @@ -246,12 +246,11 @@ void BaseMutex::DumpAll(std::ostream& os) { } void BaseMutex::CheckSafeToWait(Thread* self) { - if (!kDebugLocking) { - return; - } if (self == nullptr) { CheckUnattachedThread(level_); - } else { + return; + } + if (kDebugLocking) { CHECK(self->GetHeldMutex(level_) == this || level_ == kMonitorLock) << "Waiting on unacquired mutex: " << name_; bool bad_mutexes_held = false; @@ -571,7 +570,6 @@ bool Mutex::IsDumpFrequent(Thread* thread, uint64_t try_times) { } } -template <bool kCheck> bool Mutex::ExclusiveTryLock(Thread* self) { DCHECK(self == nullptr || self == Thread::Current()); if (kDebugLocking && !recursive_) { @@ -602,7 +600,7 @@ bool Mutex::ExclusiveTryLock(Thread* self) { #endif DCHECK_EQ(GetExclusiveOwnerTid(), 0); exclusive_owner_.store(SafeGetTid(self), std::memory_order_relaxed); - RegisterAsLocked(self, kCheck); + RegisterAsLocked(self); } recursion_count_++; if (kDebugLocking) { @@ -613,9 +611,6 @@ bool Mutex::ExclusiveTryLock(Thread* self) { return true; } -template bool Mutex::ExclusiveTryLock<false>(Thread* self); -template bool Mutex::ExclusiveTryLock<true>(Thread* self); - bool Mutex::ExclusiveTryLockWithSpinning(Thread* self) { // Spin a small number of times, since this affects our ability to respond to suspension // requests. We spin repeatedly only if the mutex repeatedly becomes available and unavailable @@ -722,12 +717,11 @@ void Mutex::ExclusiveUnlock(Thread* self) { } void Mutex::Dump(std::ostream& os) const { - os << (recursive_ ? "recursive " : "non-recursive ") << name_ - << " level=" << static_cast<int>(level_) << " rec=" << recursion_count_ -#if ART_USE_FUTEXES - << " state_and_contenders = " << std::hex << state_and_contenders_ << std::dec -#endif - << " owner=" << GetExclusiveOwnerTid() << " "; + os << (recursive_ ? "recursive " : "non-recursive ") + << name_ + << " level=" << static_cast<int>(level_) + << " rec=" << recursion_count_ + << " owner=" << GetExclusiveOwnerTid() << " "; DumpContention(os); } @@ -929,7 +923,7 @@ void ReaderWriterMutex::HandleSharedLockContention(Thread* self, int32_t cur_sta } #endif -bool ReaderWriterMutex::SharedTryLock(Thread* self, bool check) { +bool ReaderWriterMutex::SharedTryLock(Thread* self) { DCHECK(self == nullptr || self == Thread::Current()); #if ART_USE_FUTEXES bool done = false; @@ -953,7 +947,7 @@ bool ReaderWriterMutex::SharedTryLock(Thread* self, bool check) { PLOG(FATAL) << "pthread_mutex_trylock failed for " << name_; } #endif - RegisterAsLocked(self, check); + RegisterAsLocked(self); AssertSharedHeld(self); return true; } |