Expose the optimization status of a dex file

Add a method which exposes the optimization status of a dex file based on
its expected runtime behaviour. The method returns the status in an array
[compilation filter, compilation reason].

The method will try to mimic the runtime effect of loading the dex file.
For example, if there is no usable oat file, the compiler filter will be
set to "run-from-apk".

This will enable more accurate performance monitoring of apks.

Test: oat_file_assistant_test
Bug: 73102540
Change-Id: Ida9abef502dcb3fd07e1b0988771fb60e9b2a423
diff --git a/runtime/dexopt_test.cc b/runtime/dexopt_test.cc
index 037d1fb..8ce7921 100644
--- a/runtime/dexopt_test.cc
+++ b/runtime/dexopt_test.cc
@@ -49,7 +49,8 @@
                                     CompilerFilter::Filter filter,
                                     bool relocate,
                                     bool pic,
-                                    bool with_alternate_image) {
+                                    bool with_alternate_image,
+                                    const char* compilation_reason) {
   std::string dalvik_cache = GetDalvikCache(GetInstructionSetString(kRuntimeISA));
   std::string dalvik_cache_tmp = dalvik_cache + ".redirected";
   std::string oat_location = oat_location_in;
@@ -89,6 +90,10 @@
     args.push_back("--boot-image=" + GetImageLocation2());
   }
 
+  if (compilation_reason != nullptr) {
+    args.push_back("--compilation-reason=" + std::string(compilation_reason));
+  }
+
   std::string error_msg;
   ASSERT_TRUE(OatFileAssistant::Dex2Oat(args, &error_msg)) << error_msg;
 
@@ -155,13 +160,15 @@
 
 void DexoptTest::GeneratePicOdexForTest(const std::string& dex_location,
                             const std::string& odex_location,
-                            CompilerFilter::Filter filter) {
+                            CompilerFilter::Filter filter,
+                            const char* compilation_reason) {
   GenerateOatForTest(dex_location,
                      odex_location,
                      filter,
                      /*relocate*/false,
                      /*pic*/true,
-                     /*with_alternate_image*/false);
+                     /*with_alternate_image*/false,
+                     compilation_reason);
 }
 
 void DexoptTest::GenerateOatForTest(const char* dex_location,