diff options
Diffstat (limited to 'runtime/jit/jit_code_cache.cc')
-rw-r--r-- | runtime/jit/jit_code_cache.cc | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index 42d7653b9b..fdac24e5a0 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -526,6 +526,15 @@ void JitCodeCache::CopyInlineCacheInto(const InlineCache& ic, } } +static void ClearMethodCounter(ArtMethod* method, bool was_warm) { + if (was_warm) { + method->AddAccessFlags(kAccPreviouslyWarm); + } + // 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. + method->SetCounter(1); +} + uint8_t* JitCodeCache::CommitCodeInternal(Thread* self, ArtMethod* method, uint8_t* stack_map, @@ -600,7 +609,7 @@ uint8_t* JitCodeCache::CommitCodeInternal(Thread* self, // Simply discard the compiled code. Clear the counter so that it may be recompiled later. // Hopefully the class hierarchy will be more stable when compilation is retried. single_impl_still_valid = false; - method->SetCounter(1); + ClearMethodCounter(method, /*was_warm*/ false); break; } } @@ -1068,9 +1077,8 @@ void JitCodeCache::DoCollection(Thread* self, bool collect_profiling_info) { if (info->GetSavedEntryPoint() != nullptr) { info->SetSavedEntryPoint(nullptr); // We are going to move this method back to interpreter. Clear the counter now to - // give it a chance to be hot again, but set it to 1 so that this method can still be - // considered a startup method in case it's not executed again. - info->GetMethod()->SetCounter(1); + // give it a chance to be hot again. + ClearMethodCounter(info->GetMethod(), /*was_warm*/ true); } } } else if (kIsDebugBuild) { @@ -1379,7 +1387,7 @@ bool JitCodeCache::NotifyCompilationOf(ArtMethod* method, Thread* self, bool osr VLOG(jit) << method->PrettyMethod() << " needs a ProfilingInfo to be compiled"; // Because the counter is not atomic, there are some rare cases where we may not hit the // threshold for creating the ProfilingInfo. Reset the counter now to "correct" this. - method->SetCounter(1); + ClearMethodCounter(method, /*was_warm*/ false); return false; } @@ -1432,11 +1440,10 @@ void JitCodeCache::InvalidateCompiledCodeFor(ArtMethod* method, if (method->GetEntryPointFromQuickCompiledCode() == header->GetEntryPoint()) { // The entrypoint is the one to invalidate, so we just update it to the interpreter entry point - // and clear the counter to get the method Jitted again. We reset the counter to 1 to preserve - // it as a potential startup method. + // and clear the counter to get the method Jitted again. Runtime::Current()->GetInstrumentation()->UpdateMethodsCode( method, GetQuickToInterpreterBridge()); - method->SetCounter(1); + ClearMethodCounter(method, /*was_warm*/ profiling_info != nullptr); } else { MutexLock mu(Thread::Current(), lock_); auto it = osr_code_map_.find(method); |