Snap for 8417617 from 98ff3fb4dde267dc9c9f77f6c6c601e18011454b to mainline-tethering-release
Change-Id: I3bface91014d8ec2dc35ea8a8436f8b2e15a7ebc
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index c323879..f1ded6d 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -2343,7 +2343,11 @@
}
bool DoDexLayoutOptimizations() const {
- return DoProfileGuidedOptimizations() || DoGenerateCompactDex();
+ // Only run dexlayout when being asked to generate compact dex. We do this
+ // to avoid having multiple arguments being passed to dex2oat and the main
+ // user of dex2oat (installd) will have the same reasons for
+ // disabling/enabling compact dex and dex layout.
+ return DoGenerateCompactDex();
}
bool DoOatLayoutOptimizations() const {
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index cc29b0f..39cbe60 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -1206,7 +1206,8 @@
oat_filename,
CompilerFilter::Filter::kVerify,
&error_msg,
- {"--profile-file=" + profile_file.GetFilename()});
+ {"--profile-file=" + profile_file.GetFilename(),
+ "--compact-dex-level=fast"});
EXPECT_EQ(res, 0);
// Open our generated oat file.
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index af2db2d..d020b8a 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -485,11 +485,6 @@
relative_patcher_(nullptr),
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) {
@@ -3128,9 +3123,9 @@
if (extract_dex_files_into_vdex_) {
vdex_dex_files_offset_ = vdex_size_;
- // Perform dexlayout if requested.
- if (profile_compilation_info_ != nullptr ||
- compact_dex_level_ != CompactDexLevel::kCompactDexLevelNone) {
+ // Perform dexlayout if compact dex is enabled. Also see
+ // Dex2Oat::DoDexLayoutOptimizations.
+ if (compact_dex_level_ != CompactDexLevel::kCompactDexLevelNone) {
for (OatDexFile& oat_dex_file : oat_dex_files_) {
// update_input_vdex disables compact dex and layout.
CHECK(!update_input_vdex)