ART: Allow oatstatus verification for app dependencies
Allow taking verification state from the oat file durin compilation
if the class is a dependency (thus not being compiled itself). This
is necessary in case the dependency itself has been quickened and
stripped, as quickened bytecodes are not supported during compile-
time verification.
Expose this through the CompilerCallbacks.
Bug: 72237763
Test: m test-art-host
Change-Id: I9b7d3a353d81a6422c3b145fd5c5b71f36c6f257
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index b61fb4a..af45a69 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -4252,17 +4252,16 @@
ClassStatus& oat_file_class_status) {
// If we're compiling, we can only verify the class using the oat file if
// we are not compiling the image or if the class we're verifying is not part of
- // the app. In other words, we will only check for preverification of bootclasspath
- // classes.
+ // the compilation unit (app - dependencies). We will let the compiler callback
+ // tell us about the latter.
if (Runtime::Current()->IsAotCompiler()) {
+ CompilerCallbacks* callbacks = Runtime::Current()->GetCompilerCallbacks();
// Are we compiling the bootclasspath?
- if (Runtime::Current()->GetCompilerCallbacks()->IsBootImage()) {
+ if (callbacks->IsBootImage()) {
return false;
}
// We are compiling an app (not the image).
-
- // Is this an app class? (I.e. not a bootclasspath class)
- if (klass->GetClassLoader() != nullptr) {
+ if (!callbacks->CanUseOatStatusForVerification(klass.Ptr())) {
return false;
}
}
diff --git a/runtime/compiler_callbacks.h b/runtime/compiler_callbacks.h
index 4560bca..8395966 100644
--- a/runtime/compiler_callbacks.h
+++ b/runtime/compiler_callbacks.h
@@ -25,6 +25,12 @@
class CompilerDriver;
+namespace mirror {
+
+class Class;
+
+} // namespace mirror
+
namespace verifier {
class MethodVerifier;
@@ -68,6 +74,11 @@
virtual void UpdateClassState(ClassReference ref ATTRIBUTE_UNUSED,
ClassStatus state ATTRIBUTE_UNUSED) {}
+ virtual bool CanUseOatStatusForVerification(mirror::Class* klass ATTRIBUTE_UNUSED)
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ return false;
+ }
+
protected:
explicit CompilerCallbacks(CallbackMode mode) : mode_(mode) { }