Save profile information in a separate thread.
Previously we would save the profiling information only when the app
was sent to background. This missed on an important number of updates
on the jit code cache and it didn't work for background processes.
Bug: 26080105
Change-Id: I84075629870e69b3ed372f00f4806af1e9391e0f
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 033a8f0..08eac0e 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -317,7 +317,7 @@
// code.
GetLiveBitmap()->AtomicTestAndSet(FromCodeToAllocation(code_ptr));
}
- last_update_time_ns_ = NanoTime();
+ last_update_time_ns_.StoreRelease(NanoTime());
VLOG(jit)
<< "JIT added "
<< PrettyMethod(method) << "@" << method
@@ -689,18 +689,17 @@
}
void JitCodeCache::GetCompiledArtMethods(const std::set<const std::string>& dex_base_locations,
- std::set<ArtMethod*>& methods) {
+ std::vector<ArtMethod*>& methods) {
MutexLock mu(Thread::Current(), lock_);
for (auto it : method_code_map_) {
if (ContainsElement(dex_base_locations, it.second->GetDexFile()->GetBaseLocation())) {
- methods.insert(it.second);
+ methods.push_back(it.second);
}
}
}
-uint64_t JitCodeCache::GetLastUpdateTimeNs() {
- MutexLock mu(Thread::Current(), lock_);
- return last_update_time_ns_;
+uint64_t JitCodeCache::GetLastUpdateTimeNs() const {
+ return last_update_time_ns_.LoadAcquire();
}
bool JitCodeCache::NotifyCompilationOf(ArtMethod* method, Thread* self) {