diff options
Diffstat (limited to 'runtime/jit/jit_code_cache.cc')
-rw-r--r-- | runtime/jit/jit_code_cache.cc | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index 9d9a7d3bd4..e05ca111b2 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -615,12 +615,10 @@ static void ClearMethodCounter(ArtMethod* method, bool was_warm) if (was_warm) { method->SetPreviouslyWarm(); } - // We reset the counter to 1 so that the profile knows that the method was executed at least once. + method->ResetCounter(); + // We add one sample 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)); + method->UpdateCounter(/* new_samples= */ 1); } void JitCodeCache::WaitForPotentialCollectionToCompleteRunnable(Thread* self) { @@ -794,7 +792,7 @@ bool JitCodeCache::RemoveMethod(ArtMethod* method, bool release_memory) { return false; } - method->SetCounter(0); + ClearMethodCounter(method, /* was_warm= */ false); Runtime::Current()->GetInstrumentation()->UpdateMethodsCode( method, GetQuickToInterpreterBridge()); VLOG(jit) @@ -1168,14 +1166,13 @@ 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. - method->SetCounter(new_counter); + // Make sure a single invocation of the GenericJNI trampoline tries to recompile. + method->SetHotCounter(); method->SetEntryPointFromQuickCompiledCode(GetQuickGenericJniStub()); } } @@ -1300,6 +1297,7 @@ 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()); } } @@ -1489,7 +1487,6 @@ 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(); @@ -1501,10 +1498,13 @@ void JitCodeCache::GetProfiledMethods(const std::set<std::string>& dex_base_loca } std::vector<ProfileMethodInfo::ProfileInlineCache> inline_caches; - // If the method didn't reach the compilation threshold don't save the inline caches. + // If the method is still baseline compiled, 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. - if (method->GetCounter() < jit_compile_threshold) { + const void* entry_point = method->GetEntryPointFromQuickCompiledCode(); + if (ContainsPc(entry_point) && + CodeInfo::IsBaseline( + OatQuickMethodHeader::FromEntryPoint(entry_point)->GetOptimizedCodeInfoPtr())) { methods.emplace_back(/*ProfileMethodInfo*/ MethodReference(dex_file, method->GetDexMethodIndex()), inline_caches); continue; |