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/compiler/dex/quick_compiler_callbacks.cc b/compiler/dex/quick_compiler_callbacks.cc
index 540bd0c..baf97a8 100644
--- a/compiler/dex/quick_compiler_callbacks.cc
+++ b/compiler/dex/quick_compiler_callbacks.cc
@@ -17,6 +17,10 @@
 #include "quick_compiler_callbacks.h"
 
 #include "driver/compiler_driver.h"
+#include "mirror/class-inl.h"
+#include "mirror/object.h"
+#include "obj_ptr-inl.h"
+#include "thread-current-inl.h"
 #include "verification_results.h"
 #include "verifier/method_verifier-inl.h"
 
@@ -54,4 +58,15 @@
   }
 }
 
+bool QuickCompilerCallbacks::CanUseOatStatusForVerification(mirror::Class* klass) {
+  // No dex files: conservatively false.
+  if (dex_files_ == nullptr) {
+    return false;
+  }
+
+  // If the class isn't from one of the dex files, accept oat file data.
+  const DexFile* dex_file = &klass->GetDexFile();
+  return std::find(dex_files_->begin(), dex_files_->end(), dex_file) == dex_files_->end();
+}
+
 }  // namespace art