diff options
Diffstat (limited to 'runtime/jit/jit_code_cache.cc')
-rw-r--r-- | runtime/jit/jit_code_cache.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index 7545829700..9d9a7d3bd4 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -615,7 +615,12 @@ static void ClearMethodCounter(ArtMethod* method, bool was_warm) if (was_warm) { method->SetPreviouslyWarm(); } - method->ResetCounter(); + // We reset the counter to 1 so that the profile knows that the method was executed at least once. + // This is required for layout purposes. + // We also need to make sure we'll pass the warmup threshold again, so we set to 0 if + // the warmup threshold is 1. + uint16_t jit_warmup_threshold = Runtime::Current()->GetJITOptions()->GetWarmupThreshold(); + method->SetCounter(std::min(jit_warmup_threshold - 1, 1)); } void JitCodeCache::WaitForPotentialCollectionToCompleteRunnable(Thread* self) { @@ -789,7 +794,7 @@ bool JitCodeCache::RemoveMethod(ArtMethod* method, bool release_memory) { return false; } - ClearMethodCounter(method, /* was_warm= */ false); + method->SetCounter(0); Runtime::Current()->GetInstrumentation()->UpdateMethodsCode( method, GetQuickToInterpreterBridge()); VLOG(jit) @@ -1163,13 +1168,14 @@ void JitCodeCache::GarbageCollectCache(Thread* self) { if (!data.IsCompiled() || IsInZygoteExecSpace(data.GetCode())) { continue; } + // Make sure a single invocation of the GenericJNI trampoline tries to recompile. + uint16_t new_counter = Runtime::Current()->GetJit()->HotMethodThreshold() - 1u; const OatQuickMethodHeader* method_header = OatQuickMethodHeader::FromCodePointer(data.GetCode()); for (ArtMethod* method : data.GetMethods()) { if (method->GetEntryPointFromQuickCompiledCode() == method_header->GetEntryPoint()) { // Don't call Instrumentation::UpdateMethodsCode(), same as for normal methods above. - // Make sure a single invocation of the GenericJNI trampoline tries to recompile. - method->SetHotCounter(); + method->SetCounter(new_counter); method->SetEntryPointFromQuickCompiledCode(GetQuickGenericJniStub()); } } @@ -1294,7 +1300,6 @@ void JitCodeCache::DoCollection(Thread* self, bool collect_profiling_info) { OatQuickMethodHeader* method_header = OatQuickMethodHeader::FromEntryPoint(entry_point); if (CodeInfo::IsBaseline(method_header->GetOptimizedCodeInfoPtr())) { - info->GetMethod()->ResetCounter(); info->GetMethod()->SetEntryPointFromQuickCompiledCode(GetQuickToInterpreterBridge()); } } @@ -1484,6 +1489,7 @@ void JitCodeCache::GetProfiledMethods(const std::set<std::string>& dex_base_loca WaitUntilInlineCacheAccessible(self); MutexLock mu(self, *Locks::jit_lock_); ScopedTrace trace(__FUNCTION__); + uint16_t jit_compile_threshold = Runtime::Current()->GetJITOptions()->GetCompileThreshold(); for (auto it : profiling_infos_) { ProfilingInfo* info = it.second; ArtMethod* method = info->GetMethod(); @@ -1495,13 +1501,10 @@ void JitCodeCache::GetProfiledMethods(const std::set<std::string>& dex_base_loca } std::vector<ProfileMethodInfo::ProfileInlineCache> inline_caches; - // If the method is still baseline compiled, don't save the inline caches. + // If the method didn't reach the compilation threshold don't save the inline caches. // They might be incomplete and cause unnecessary deoptimizations. // If the inline cache is empty the compiler will generate a regular invoke virtual/interface. - const void* entry_point = method->GetEntryPointFromQuickCompiledCode(); - if (ContainsPc(entry_point) && - CodeInfo::IsBaseline( - OatQuickMethodHeader::FromEntryPoint(entry_point)->GetOptimizedCodeInfoPtr())) { + if (method->GetCounter() < jit_compile_threshold) { methods.emplace_back(/*ProfileMethodInfo*/ MethodReference(dex_file, method->GetDexMethodIndex()), inline_caches); continue; |