summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Stjernholm <mast@google.com>2023-11-28 16:15:50 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-11-28 16:32:01 +0000
commit90f7e8dc1f33d6d45d26b3c57062da23dd1b50e2 (patch)
treea54524bccd2e3ab03e3310c388d0b37e41313d10
parent4dcb986d17ac0a2323a283caa75fc55c7b180904 (diff)
downloadart-90f7e8dc1f33d6d45d26b3c57062da23dd1b50e2.tar.gz
Revert "Disable cdex at build time."
This reverts commit de428d4a39a76ee1256eb47a935c705f0d8d1918. Reason for revert: App startup (b/313417445) and LMK (b/313417502) regressions Bug: 313417445 Bug: 313417502 Bug: 256664509 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:13b6705ba57cb38772d7659e7ebe115889d8d8d9) Merged-In: Ie8fee165bae8ee57b7b2dcb3fb756f33867862e5 Change-Id: Ie8fee165bae8ee57b7b2dcb3fb756f33867862e5
-rw-r--r--build/art.go3
-rw-r--r--dex2oat/dex2oat.cc16
-rw-r--r--dex2oat/dex2oat_options.cc4
-rw-r--r--dex2oat/dex2oat_test.cc22
-rw-r--r--dexlayout/dexlayout_test.cc15
-rw-r--r--libdexfile/dex/compact_dex_level.h8
6 files changed, 35 insertions, 33 deletions
diff --git a/build/art.go b/build/art.go
index f03a528f5d..dd2106ea88 100644
--- a/build/art.go
+++ b/build/art.go
@@ -84,6 +84,9 @@ func globalFlags(ctx android.LoadHookContext) ([]string, []string) {
cflags = append(cflags, "-DART_USE_TLAB=1")
}
+ cdexLevel := ctx.Config().GetenvWithDefault("ART_DEFAULT_COMPACT_DEX_LEVEL", "fast")
+ cflags = append(cflags, "-DART_DEFAULT_COMPACT_DEX_LEVEL="+cdexLevel)
+
// We need larger stack overflow guards for ASAN, as the compiled code will have
// larger frame sizes. For simplicity, just use global not-target-specific cflags.
// Note: We increase this for both debug and non-debug, as the overflow gap will
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 98acff62a4..f4c3e2a094 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1116,9 +1116,17 @@ class Dex2Oat final {
AssignIfExists(args, M::PublicSdk, &public_sdk_);
AssignIfExists(args, M::ApexVersions, &apex_versions_argument_);
+ // Check for phenotype flag to override compact_dex_level_, if it isn't "none" already.
+ // TODO(b/256664509): Clean this up.
if (compact_dex_level_ != CompactDexLevel::kCompactDexLevelNone) {
- LOG(WARNING) << "Obsolete flag --compact-dex-level ignored";
- compact_dex_level_ = CompactDexLevel::kCompactDexLevelNone;
+ std::string ph_disable_compact_dex =
+ android::base::GetProperty(kPhDisableCompactDex, "false");
+ if (ph_disable_compact_dex == "true") {
+ LOG(WARNING)
+ << "Overriding --compact-dex-level due to "
+ "persist.device_config.runtime_native_boot.disable_compact_dex set to `true`";
+ compact_dex_level_ = CompactDexLevel::kCompactDexLevelNone;
+ }
}
AssignIfExists(args, M::Backend, &compiler_kind_);
@@ -2973,9 +2981,7 @@ class Dex2Oat final {
std::string android_root_;
std::string no_inline_from_string_;
bool force_allow_oj_inlines_ = false;
-
- // TODO(b/256664509): Clean this up.
- CompactDexLevel compact_dex_level_ = CompactDexLevel::kCompactDexLevelNone;
+ CompactDexLevel compact_dex_level_ = kDefaultCompactDexLevel;
std::vector<std::unique_ptr<linker::ElfWriter>> elf_writers_;
std::vector<std::unique_ptr<linker::OatWriter>> oat_writers_;
diff --git a/dex2oat/dex2oat_options.cc b/dex2oat/dex2oat_options.cc
index 1c46d1373f..4da219897b 100644
--- a/dex2oat/dex2oat_options.cc
+++ b/dex2oat/dex2oat_options.cc
@@ -427,7 +427,9 @@ Parser CreateDex2oatArgumentParser() {
.WithType<CompactDexLevel>()
.WithValueMap({{"none", CompactDexLevel::kCompactDexLevelNone},
{"fast", CompactDexLevel::kCompactDexLevelFast}})
- .WithHelp("This flag is obsolete and does nothing.")
+ .WithHelp("None avoids generating compact dex, fast generates compact dex with low\n"
+ "compile time. If speed-profile is specified as the compiler filter and the\n"
+ "profile is not empty, the default compact dex level is always used.")
.IntoKey(M::CompactDexLevel)
.Define("--runtime-arg _")
.WithType<std::vector<std::string>>().AppendValues()
diff --git a/dex2oat/dex2oat_test.cc b/dex2oat/dex2oat_test.cc
index 511fdfaab8..ca76254fc1 100644
--- a/dex2oat/dex2oat_test.cc
+++ b/dex2oat/dex2oat_test.cc
@@ -1242,9 +1242,6 @@ TEST_F(Dex2oatDeterminism, UnloadCompile) {
// Test that dexlayout section info is correctly written to the oat file for profile based
// compilation.
TEST_F(Dex2oatTest, LayoutSections) {
- // TODO(b/256664509): Clean this up.
- GTEST_SKIP() << "Compact dex is disabled";
-#if 0
using Hotness = ProfileCompilationInfo::MethodHotness;
std::unique_ptr<const DexFile> dex(OpenTestDexFile("ManyMethods"));
ScratchFile profile_file;
@@ -1395,14 +1392,10 @@ TEST_F(Dex2oatTest, LayoutSections) {
EXPECT_GT(startup_count, 0u);
EXPECT_GT(unused_count, 0u);
}
-#endif // 0
}
// Test that generating compact dex works.
TEST_F(Dex2oatTest, GenerateCompactDex) {
- // TODO(b/256664509): Clean this up.
- GTEST_SKIP() << "Compact dex is disabled";
-#if 0
// Generate a compact dex based odex.
const std::string dir = GetScratchDir();
const std::string oat_filename = dir + "/base.oat";
@@ -1458,7 +1451,6 @@ TEST_F(Dex2oatTest, GenerateCompactDex) {
}
}
}
-#endif // 0
}
class Dex2oatVerifierAbort : public Dex2oatTest {};
@@ -1697,7 +1689,8 @@ TEST_F(Dex2oatTest, CompactDexGenerationFailureMultiDex) {
}
const std::string& dex_location = apk_file.GetFilename();
const std::string odex_location = GetOdexDir() + "/output.odex";
- ASSERT_TRUE(GenerateOdexForTest(dex_location, odex_location, CompilerFilter::kVerify, {}, true));
+ ASSERT_TRUE(GenerateOdexForTest(
+ dex_location, odex_location, CompilerFilter::kVerify, {"--compact-dex-level=fast"}, true));
}
TEST_F(Dex2oatTest, StderrLoggerOutput) {
@@ -1876,8 +1869,11 @@ TEST_F(Dex2oatTest, CompactDexInvalidSource) {
const std::string& dex_location = invalid_dex.GetFilename();
const std::string odex_location = GetOdexDir() + "/output.odex";
std::string error_msg;
- int status = GenerateOdexForTestWithStatus(
- {dex_location}, odex_location, CompilerFilter::kVerify, &error_msg, {});
+ int status = GenerateOdexForTestWithStatus({dex_location},
+ odex_location,
+ CompilerFilter::kVerify,
+ &error_msg,
+ {"--compact-dex-level=fast"});
ASSERT_TRUE(WIFEXITED(status) && WEXITSTATUS(status) != 0) << status << " " << output_;
}
@@ -1915,14 +1911,14 @@ TEST_F(Dex2oatTest, CompactDexInZip) {
GetOdexDir() + "/output_apk.odex",
CompilerFilter::kVerify,
&error_msg,
- {});
+ {"--compact-dex-level=fast"});
ASSERT_TRUE(WIFEXITED(status) && WEXITSTATUS(status) != 0) << status << " " << output_;
status = GenerateOdexForTestWithStatus({invalid_dex.GetFilename()},
GetOdexDir() + "/output.odex",
CompilerFilter::kVerify,
&error_msg,
- {});
+ {"--compact-dex-level=fast"});
ASSERT_TRUE(WIFEXITED(status) && WEXITSTATUS(status) != 0) << status << " " << output_;
}
diff --git a/dexlayout/dexlayout_test.cc b/dexlayout/dexlayout_test.cc
index 4e4811ffa5..03df258f04 100644
--- a/dexlayout/dexlayout_test.cc
+++ b/dexlayout/dexlayout_test.cc
@@ -225,8 +225,11 @@ static const char kDuplicateCodeItemInputDex[] =
"AHAAAAACAAAAAwAAAIwAAAADAAAAAQAAAJgAAAAFAAAABAAAAKQAAAAGAAAAAQAAAMQAAAABIAAA"
"AwAAAOQAAAACIAAABwAAACQBAAADIAAAAwAAAFYBAAAAIAAAAQAAAGUBAAAAEAAAAQAAAHgBAAA=";
-// Returns the default compact dex option for dexlayout.
-static std::vector<std::string> DefaultCompactDexOption() { return {"-x", "none"}; }
+// Returns the default compact dex option for dexlayout based on kDefaultCompactDexLevel.
+static std::vector<std::string> DefaultCompactDexOption() {
+ return (kDefaultCompactDexLevel == CompactDexLevel::kCompactDexLevelFast) ?
+ std::vector<std::string>{"-x", "fast"} : std::vector<std::string>{"-x", "none"};
+}
static void WriteBase64ToFile(const char* base64, File* file) {
// Decode base64.
@@ -546,25 +549,17 @@ class DexLayoutTest : public CommonArtTest {
TEST_F(DexLayoutTest, FullPlainOutput) {
- // TODO(b/256664509): Clean this up.
- GTEST_SKIP() << "Compact dex is disabled";
-#if 0
// Disable test on target.
TEST_DISABLED_FOR_TARGET();
std::string error_msg;
ASSERT_TRUE(FullPlainOutputExec(&error_msg)) << error_msg;
-#endif
}
TEST_F(DexLayoutTest, DexFileOutput) {
- // TODO(b/256664509): Clean this up.
- GTEST_SKIP() << "Compact dex is disabled";
-#if 0
// Disable test on target.
TEST_DISABLED_FOR_TARGET();
std::string error_msg;
ASSERT_TRUE(DexFileOutputExec(&error_msg)) << error_msg;
-#endif
}
TEST_F(DexLayoutTest, DexFileLayout) {
diff --git a/libdexfile/dex/compact_dex_level.h b/libdexfile/dex/compact_dex_level.h
index 2f06688e8e..599ec4db19 100644
--- a/libdexfile/dex/compact_dex_level.h
+++ b/libdexfile/dex/compact_dex_level.h
@@ -24,7 +24,6 @@
namespace art {
// Optimization level for compact dex generation.
-// TODO(b/256664509): Clean this up.
enum class CompactDexLevel {
// Level none means not generated.
kCompactDexLevelNone,
@@ -32,7 +31,9 @@ enum class CompactDexLevel {
kCompactDexLevelFast,
};
-#ifdef ART_DEFAULT_COMPACT_DEX_LEVEL
+#ifndef ART_DEFAULT_COMPACT_DEX_LEVEL
+#error ART_DEFAULT_COMPACT_DEX_LEVEL not specified.
+#else
#define ART_DEFAULT_COMPACT_DEX_LEVEL_VALUE_fast CompactDexLevel::kCompactDexLevelFast
#define ART_DEFAULT_COMPACT_DEX_LEVEL_VALUE_none CompactDexLevel::kCompactDexLevelNone
@@ -40,8 +41,7 @@ enum class CompactDexLevel {
ART_DEFAULT_COMPACT_DEX_LEVEL_VALUE_, \
ART_DEFAULT_COMPACT_DEX_LEVEL)
-static_assert(ART_DEFAULT_COMPACT_DEX_LEVEL_DEFAULT == CompactDexLevel::kCompactDexLevelNone,
- "ART_DEFAULT_COMPACT_DEX_LEVEL_DEFAULT != none is no longer supported");
+static constexpr CompactDexLevel kDefaultCompactDexLevel = ART_DEFAULT_COMPACT_DEX_LEVEL_DEFAULT;
#endif
} // namespace art