ART: Start RuntimeCallbacks
Add a central RuntimeCallbacks structure to handle certain interesting
runtime events.
In a first iteration, add ThreadLifecycleCallback with ThreadStart and
ThreadStop. Move Dbg over to ThreadLifecycleCallback.
Add a test.
Bug: 31684920
Test: m test-art-host-gtest-runtime_callbacks_test
Test: art/tools/run-jdwp-tests.sh --mode=host
Change-Id: Ie0f77739a563207bfb4f04374e72dc6935c40b4f
diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h
index 2adeb8c..e44bdb8 100644
--- a/runtime/base/mutex.h
+++ b/runtime/base/mutex.h
@@ -111,6 +111,7 @@
kJdwpEventListLock,
kJdwpAttachLock,
kJdwpStartLock,
+ kRuntimeCallbacksLock,
kRuntimeShutdownLock,
kTraceLock,
kHeapBitmapLock,
@@ -615,8 +616,11 @@
// Guards shutdown of the runtime.
static Mutex* runtime_shutdown_lock_ ACQUIRED_AFTER(heap_bitmap_lock_);
+ // Guards accesses to runtime callback lists.
+ static ReaderWriterMutex* runtime_callbacks_lock_ ACQUIRED_AFTER(runtime_shutdown_lock_);
+
// Guards background profiler global state.
- static Mutex* profiler_lock_ ACQUIRED_AFTER(runtime_shutdown_lock_);
+ static Mutex* profiler_lock_ ACQUIRED_AFTER(runtime_callbacks_lock_);
// Guards trace (ie traceview) requests.
static Mutex* trace_lock_ ACQUIRED_AFTER(profiler_lock_);