No longer lock WeakGlobalsLock in FindDexCache
Since DecodeWeakGlobal is now usually lock free, it is faster to use
that instead of the locked version.
10x boot.oat compile on host -j4:
Before:
real 1m24.674s
user 3m40.446s
sys 0m15.749s
After:
real 1m14.529s
user 3m26.734s
sys 0m8.469s
Change-Id: I15bb10ad3a9bb2e6f8edb5dc0668267be821d603
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index e78914c..287aca9 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -2543,15 +2543,12 @@
bool allow_failure) {
// Search assuming unique-ness of dex file.
JavaVMExt* const vm = self->GetJniEnv()->vm;
- {
- MutexLock mu(self, vm->WeakGlobalsLock());
- for (jobject weak_root : dex_caches_) {
- DCHECK_EQ(GetIndirectRefKind(weak_root), kWeakGlobal);
- mirror::DexCache* dex_cache = down_cast<mirror::DexCache*>(
- vm->DecodeWeakGlobalLocked(self, weak_root));
- if (dex_cache != nullptr && dex_cache->GetDexFile() == &dex_file) {
- return dex_cache;
- }
+ for (jobject weak_root : dex_caches_) {
+ DCHECK_EQ(GetIndirectRefKind(weak_root), kWeakGlobal);
+ mirror::DexCache* dex_cache = down_cast<mirror::DexCache*>(
+ vm->DecodeWeakGlobal(self, weak_root));
+ if (dex_cache != nullptr && dex_cache->GetDexFile() == &dex_file) {
+ return dex_cache;
}
}
if (allow_failure) {