Always do cdex conversion for OatWriter dexlayout
Don't use DexLayout without CompactDex conversion in the case where
a profile is passed in.
Bug: 77498934
Test: test-art-host
Change-Id: I6c0498db71f1324402b8dfe2ab3ef9bbd121b4cc
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 88dc6d4..220f568 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -454,7 +454,9 @@
UsageError(" The image writer will group them together.");
UsageError("");
UsageError(" --compact-dex-level=none|fast: None avoids generating compact dex, fast");
- UsageError(" generates compact dex with low compile time.");
+ UsageError(" generates compact dex with low compile time. If speed-profile is specified as");
+ UsageError(" the compiler filter and the profile is not empty, the default compact dex");
+ UsageError(" level is always used.");
UsageError("");
UsageError(" --deduplicate-code=true|false: enable|disable code deduplication. Deduplicated");
UsageError(" code will have an arbitrary symbol tagged with [DEDUPED].");
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index 65a4c5b..bcc5909 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -445,6 +445,11 @@
absolute_patch_locations_(),
profile_compilation_info_(info),
compact_dex_level_(compact_dex_level) {
+ // If we have a profile, always use at least the default compact dex level. The reason behind
+ // this is that CompactDex conversion is not more expensive than normal dexlayout.
+ if (info != nullptr && compact_dex_level_ == CompactDexLevel::kCompactDexLevelNone) {
+ compact_dex_level_ = kDefaultCompactDexLevel;
+ }
}
static bool ValidateDexFileHeader(const uint8_t* raw_header, const char* location) {