Re-arrange code to avoid recursive locking of the JIT lock.
Creating a profiling info requires the lock, so don't hold it before
calling ProfilingInfo::Create.
Test: test.py
Change-Id: Ib217052c09274665cbfa7572540ee391858dd342
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 945600a..299a3d3 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -1616,12 +1616,15 @@
}
}
- MutexLock mu(self, *Locks::jit_lock_);
- if (osr && (osr_code_map_.find(method) != osr_code_map_.end())) {
- return false;
+ if (osr) {
+ MutexLock mu(self, *Locks::jit_lock_);
+ if (osr_code_map_.find(method) != osr_code_map_.end()) {
+ return false;
+ }
}
if (UNLIKELY(method->IsNative())) {
+ MutexLock mu(self, *Locks::jit_lock_);
JniStubKey key(method);
auto it = jni_stubs_map_.find(key);
bool new_compilation = false;
@@ -1666,6 +1669,7 @@
return false;
}
} else {
+ MutexLock mu(self, *Locks::jit_lock_);
if (info->IsMethodBeingCompiled(osr)) {
return false;
}