Fix thread race when fetching the ProfilingInfo object.
Problem is:
1) Compiler fetches the ProfilingInfo of A, it's null.
2) Mutator creates the ProfilingInfo.
3) Compiler notifies it's not using A anymore, calls
ProfilingInfo::DecrementInlineUse -> Crash as we expected
ProfilingInfo::IncrementUse to be called before.
Also update some namings to better reflect what is going on.
Change-Id: I55ea4c5d81988131467095e18a0d13a8be9d0ef7
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 050bb68..af47da6 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -928,20 +928,20 @@
return true;
}
-void JitCodeCache::NotifyInliningOf(ArtMethod* method, Thread* self) {
+ProfilingInfo* JitCodeCache::NotifyCompilerUse(ArtMethod* method, Thread* self) {
MutexLock mu(self, lock_);
ProfilingInfo* info = method->GetProfilingInfo(sizeof(void*));
if (info != nullptr) {
info->IncrementInlineUse();
}
+ return info;
}
-void JitCodeCache::DoneInlining(ArtMethod* method, Thread* self) {
+void JitCodeCache::DoneCompilerUse(ArtMethod* method, Thread* self) {
MutexLock mu(self, lock_);
ProfilingInfo* info = method->GetProfilingInfo(sizeof(void*));
- if (info != nullptr) {
- info->DecrementInlineUse();
- }
+ DCHECK(info != nullptr);
+ info->DecrementInlineUse();
}
void JitCodeCache::DoneCompiling(ArtMethod* method, Thread* self ATTRIBUTE_UNUSED) {