OSDN Git Service

ART: Make less lock-level noise on abort
authorAndreas Gampe <agampe@google.com>
Tue, 18 Apr 2017 04:40:28 +0000 (21:40 -0700)
committerAndreas Gampe <agampe@google.com>
Tue, 18 Apr 2017 04:40:28 +0000 (21:40 -0700)
The lock-level violations with the abort lock aren't really all
that interesting.

Test: m test-art-host
Change-Id: I8a5fc687009db914ec8f60d86068d87e71f8a894

runtime/base/mutex-inl.h

index 44a84c8..08b370e 100644 (file)
@@ -89,13 +89,14 @@ inline void BaseMutex::RegisterAsLocked(Thread* self) {
     // Check if a bad Mutex of this level or lower is held.
     bool bad_mutexes_held = false;
     for (int i = level_; i >= 0; --i) {
-      BaseMutex* held_mutex = self->GetHeldMutex(static_cast<LockLevel>(i));
-      if (UNLIKELY(held_mutex != nullptr)) {
+      LockLevel lock_level_i = static_cast<LockLevel>(i);
+      BaseMutex* held_mutex = self->GetHeldMutex(lock_level_i);
+      if (UNLIKELY(held_mutex != nullptr) && lock_level_i != kAbortLock) {
         LOG(ERROR) << "Lock level violation: holding \"" << held_mutex->name_ << "\" "
-                   << "(level " << LockLevel(i) << " - " << i
+                   << "(level " << lock_level_i << " - " << i
                    << ") while locking \"" << name_ << "\" "
                    << "(level " << level_ << " - " << static_cast<int>(level_) << ")";
-        if (i > kAbortLock) {
+        if (lock_level_i > kAbortLock) {
           // Only abort in the check below if this is more than abort level lock.
           bad_mutexes_held = true;
         }