Add access flag for previously warm methods
We want to know if the method was warm instead of just having a non
zero counter. This is required if we want to not compile all of the
startup methods, but still compile warm methods.
Test: test-art-host ART_TEST_JIT=true
Bug: 62200509
Change-Id: I6e04866f39f970b04b47342b7af5ed474e1f4172
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 42d7653..fdac24e 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -526,6 +526,15 @@
}
}
+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 @@
// 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 @@
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 @@
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 @@
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);