ART: Add entries_ lock for race condition

GCDaemon thread would visit incorrect RegType content when there is
another thread initializing classes.
Add a lock to protect entries_.

https://code.google.com/p/android/issues/detail?id=159849

Change-Id: Iabaa1c7f5cc5106b60a6e3856152e0797e8a5d6d
diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h
index 3b052c0..f9e1e62 100644
--- a/runtime/base/mutex.h
+++ b/runtime/base/mutex.h
@@ -86,6 +86,7 @@
   kModifyLdtLock,
   kAllocatedThreadIdsLock,
   kMonitorPoolLock,
+  kMethodVerifiersLock,
   kClassLinkerClassesLock,
   kBreakpointLock,
   kMonitorLock,
@@ -587,9 +588,11 @@
   // Guards lists of classes within the class linker.
   static ReaderWriterMutex* classlinker_classes_lock_ ACQUIRED_AFTER(breakpoint_lock_);
 
+  static Mutex* method_verifiers_lock_ ACQUIRED_AFTER(classlinker_classes_lock_);
+
   // When declaring any Mutex add DEFAULT_MUTEX_ACQUIRED_AFTER to use annotalysis to check the code
   // doesn't try to hold a higher level Mutex.
-  #define DEFAULT_MUTEX_ACQUIRED_AFTER ACQUIRED_AFTER(Locks::classlinker_classes_lock_)
+  #define DEFAULT_MUTEX_ACQUIRED_AFTER ACQUIRED_AFTER(Locks::method_verifiers_lock_)
 
   static Mutex* allocated_monitor_ids_lock_ ACQUIRED_AFTER(classlinker_classes_lock_);