Fix longstanding JIT bug in interaction with class initialization.
The entrypoint of a method of a class being initialized was
wrongly updated to pointing to compiled code when it should stay
the resolution stub.
Test: 694-clinit-jit
Bug: 119800099
Bug: 130337355
Change-Id: I1bd5769c950b62330d8ae5c34cc08111b2fb4c04
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index d3e4582..2052f14 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -1977,6 +1977,18 @@
return false;
}
+ ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
+ if (class_linker->IsQuickResolutionStub(method->GetEntryPointFromQuickCompiledCode())) {
+ // We currently don't save the JIT compiled code if we cannot update the entrypoint due
+ // to having the resolution stub.
+ VLOG(jit) << "Not compiling "
+ << method->PrettyMethod()
+ << " because it has the resolution stub";
+ // Give it a new chance to be hot.
+ ClearMethodCounter(method, /*was_warm=*/ false);
+ return false;
+ }
+
MutexLock mu(self, lock_);
if (osr && (osr_code_map_.find(method) != osr_code_map_.end())) {
return false;