Revert "Revert "Unload oat files""
Fixed a race where two threads calling OatFile::Open could both use
dlopen on the host.
Bug: 22720414
This reverts commit 72da5e7461fec3b1e116050f2e6f233efb9c54f3.
Change-Id: I1636045b724944d2a09417527280784967957095
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index 30bfb4a..70bd398 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -51,6 +51,7 @@
MutatorMutex* Locks::mutator_lock_ = nullptr;
Mutex* Locks::profiler_lock_ = nullptr;
ReaderWriterMutex* Locks::oat_file_manager_lock_ = nullptr;
+ReaderWriterMutex* Locks::oat_file_count_lock_ = nullptr;
Mutex* Locks::reference_processor_lock_ = nullptr;
Mutex* Locks::reference_queue_cleared_references_lock_ = nullptr;
Mutex* Locks::reference_queue_finalizer_references_lock_ = nullptr;
@@ -942,6 +943,7 @@
DCHECK(deoptimization_lock_ != nullptr);
DCHECK(heap_bitmap_lock_ != nullptr);
DCHECK(oat_file_manager_lock_ != nullptr);
+ DCHECK(oat_file_count_lock_ != nullptr);
DCHECK(intern_table_lock_ != nullptr);
DCHECK(jni_libraries_lock_ != nullptr);
DCHECK(logging_lock_ != nullptr);
@@ -1034,6 +1036,10 @@
DCHECK(oat_file_manager_lock_ == nullptr);
oat_file_manager_lock_ = new ReaderWriterMutex("OatFile manager lock", current_lock_level);
+ UPDATE_CURRENT_LOCK_LEVEL(kOatFileCountLock);
+ DCHECK(oat_file_count_lock_ == nullptr);
+ oat_file_count_lock_ = new ReaderWriterMutex("OatFile count lock", current_lock_level);
+
UPDATE_CURRENT_LOCK_LEVEL(kInternTableLock);
DCHECK(intern_table_lock_ == nullptr);
intern_table_lock_ = new Mutex("InternTable lock", current_lock_level);