Reduce lock contention when debugging
Uses a ReaderWriterMutex for the breakpoint lock to reduce contention during
debugging session.
Also adds missing thread safety annotations on fields and methods related to
instrumentation and debugging.
Bug: 16814665
Bug: 11667502
(cherry picked from commit 59d9d668d4f4286813afe2b4e7c6db839222ce96)
Change-Id: I5f1156da8c6cc8316d6db16e6cfb2470fe289ad3
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index abe0aa0..23caefc 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -32,7 +32,7 @@
Mutex* Locks::abort_lock_ = nullptr;
Mutex* Locks::allocated_monitor_ids_lock_ = nullptr;
Mutex* Locks::allocated_thread_ids_lock_ = nullptr;
-Mutex* Locks::breakpoint_lock_ = nullptr;
+ReaderWriterMutex* Locks::breakpoint_lock_ = nullptr;
ReaderWriterMutex* Locks::classlinker_classes_lock_ = nullptr;
ReaderWriterMutex* Locks::heap_bitmap_lock_ = nullptr;
Mutex* Locks::jni_libraries_lock_ = nullptr;
@@ -886,7 +886,7 @@
UPDATE_CURRENT_LOCK_LEVEL(kBreakpointLock);
DCHECK(breakpoint_lock_ == nullptr);
- breakpoint_lock_ = new Mutex("breakpoint lock", current_lock_level);
+ breakpoint_lock_ = new ReaderWriterMutex("breakpoint lock", current_lock_level);
UPDATE_CURRENT_LOCK_LEVEL(kClassLinkerClassesLock);
DCHECK(classlinker_classes_lock_ == nullptr);