Add --compilation-reason option to dex2oat
The compilation reason is an optional metadata specifying the reason for
compiling the apk. If specified, the string will be embedded verbatim in
the key value store of the oat file.
This will allow a more precise performance monitoring based on the actual
reason for compilation (e.g. install time vs background dexopt time).
Test: dex2oat_test
Bug: 73102540
Change-Id: I73c7fcc73e37a695f1684d9e282c7cc5be3030f8
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 600449c..0852da5 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -1924,6 +1924,10 @@
return GetOatHeader().GetStoreValueByKey(OatHeader::kClassPathKey);
}
+const char* OatFile::GetCompilationReason() const {
+ return GetOatHeader().GetStoreValueByKey(OatHeader::kCompilationReasonKey);
+}
+
OatFile::OatClass OatFile::FindOatClass(const DexFile& dex_file,
uint16_t class_def_idx,
bool* found) {