Make lock debug checks optional.

Move all locking checks behing kDebugLocking. Disable locking checks
when not DEBUG. Will enable later so that we can get some idea of the
performance overhead. We want locking checks to be the default for a
while to make sure we solve any remaining potential deadlock issues.

Change-Id: I4d7622750cc29f9933c84259796de5a2df02b783
diff --git a/src/mutex.h b/src/mutex.h
index 5154d45..85d75ab 100644
--- a/src/mutex.h
+++ b/src/mutex.h
@@ -24,7 +24,6 @@
 #include <string>
 
 #include "globals.h"
-#include "gtest/gtest.h"
 #include "logging.h"
 #include "macros.h"
 
@@ -37,6 +36,8 @@
 
 namespace art {
 
+const bool kDebugLocking = kIsDebugBuild;
+
 class LOCKABLE Mutex;
 class LOCKABLE ReaderWriterMutex;
 
@@ -216,7 +217,7 @@
 
   // Assert that the Mutex is exclusively held by the current thread.
   void AssertExclusiveHeld() {
-    if (kIsDebugBuild) {
+    if (kDebugLocking) {
       CHECK(IsExclusiveHeld());
     }
   }
@@ -224,7 +225,7 @@
 
   // Assert that the Mutex is not held by the current thread.
   void AssertNotHeldExclusive() {
-    if (kIsDebugBuild) {
+    if (kDebugLocking) {
       CHECK(!IsExclusiveHeld());
     }
   }
@@ -300,7 +301,7 @@
 
   // Assert the current thread has exclusive access to the ReaderWriterMutex.
   void AssertExclusiveHeld() {
-    if (kIsDebugBuild) {
+    if (kDebugLocking) {
       CHECK(IsExclusiveHeld());
     }
   }
@@ -308,7 +309,7 @@
 
   // Assert the current thread doesn't have exclusive access to the ReaderWriterMutex.
   void AssertNotExclusiveHeld() {
-    if (kIsDebugBuild) {
+    if (kDebugLocking) {
       CHECK(!IsExclusiveHeld());
     }
   }
@@ -319,7 +320,7 @@
 
   // Assert the current thread has shared access to the ReaderWriterMutex.
   void AssertSharedHeld() {
-    if (kIsDebugBuild) {
+    if (kDebugLocking) {
       CHECK(IsSharedHeld());
     }
   }
@@ -328,7 +329,7 @@
   // Assert the current thread doesn't hold this ReaderWriterMutex either in shared or exclusive
   // mode.
   void AssertNotHeld() {
-    if (kIsDebugBuild) {
+    if (kDebugLocking) {
       CHECK(!IsSharedHeld());
     }
   }