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/oat_file_assistant.h b/runtime/oat_file_assistant.h
index a614030..a184807 100644
--- a/runtime/oat_file_assistant.h
+++ b/runtime/oat_file_assistant.h
@@ -226,6 +226,20 @@
// dex file. The returned description is for debugging purposes only.
std::string GetStatusDump();
+ // Computes the optimization status of the given dex file. The result is
+ // returned via the two output parameters.
+ // - out_compilation_filter: the level of optimizations (compiler filter)
+ // - out_compilation_reason: the optimization reason. The reason might
+ // be "unknown" if the compiler artifacts were not annotated during optimizations.
+ //
+ // This 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".
+ static void GetOptimizationStatus(const std::string& filename,
+ InstructionSet isa,
+ std::string* out_compilation_filter,
+ std::string* out_compilation_reason);
+
// Open and returns an image space associated with the oat file.
static std::unique_ptr<gc::space::ImageSpace> OpenImageSpace(const OatFile* oat_file);