diff options
author | 2020-04-20 04:08:26 +0000 | |
---|---|---|
committer | 2020-04-20 04:08:26 +0000 | |
commit | d656fe27e13f00ce7a6c395f03d0e60e842dac5a (patch) | |
tree | bde504ea86944fe3f65ee3a2ee9b819ecaa06e9f | |
parent | c7e949b743fc1bc50dbaa0be22d893d57c34bdf1 (diff) | |
parent | 6df89a6f20842cb37412e988f2753df01acb65b0 (diff) |
Merge "Control use of dex2oat64 by device property"
-rw-r--r-- | cmds/installd/dexopt.cpp | 11 | ||||
-rw-r--r-- | cmds/installd/dexopt.h | 6 | ||||
-rw-r--r-- | cmds/installd/tests/installd_dexopt_test.cpp | 30 |
3 files changed, 44 insertions, 3 deletions
diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp index 9566cf66f6..3c0443595e 100644 --- a/cmds/installd/dexopt.cpp +++ b/cmds/installd/dexopt.cpp @@ -429,8 +429,17 @@ class RunDex2Oat : public ExecVHelper { MapPropertyToArg("dalvik.vm.dex2oat-very-large", "--very-large-app-threshold=%s"); + + // Decide whether to use dex2oat64. + bool use_dex2oat64 = false; + // Check whether the device even supports 64-bit ABIs. + if (!GetProperty("ro.product.cpu.abilist64", "").empty()) { + use_dex2oat64 = GetBoolProperty("dalvik.vm.dex2oat64.enabled", false); + } const char* dex2oat_bin = select_execution_binary( - kDex2oatPath, kDex2oatDebugPath, background_job_compile); + (use_dex2oat64 ? kDex2oat64Path : kDex2oat32Path), + (use_dex2oat64 ? kDex2oatDebug64Path : kDex2oatDebug32Path), + background_job_compile); bool generate_minidebug_info = kEnableMinidebugInfo && GetBoolProperty(kMinidebugInfoSystemProperty, kMinidebugInfoSystemPropertyDefault); diff --git a/cmds/installd/dexopt.h b/cmds/installd/dexopt.h index 92b13c79c1..d35953c058 100644 --- a/cmds/installd/dexopt.h +++ b/cmds/installd/dexopt.h @@ -36,8 +36,10 @@ static constexpr int DEX2OAT_FOR_FILTER = 3; #define ANDROID_ART_APEX_BIN "/apex/com.android.art/bin" // Location of binaries in the Android Runtime APEX. -static constexpr const char* kDex2oatPath = ANDROID_ART_APEX_BIN "/dex2oat"; -static constexpr const char* kDex2oatDebugPath = ANDROID_ART_APEX_BIN "/dex2oatd"; +static constexpr const char* kDex2oat32Path = ANDROID_ART_APEX_BIN "/dex2oat32"; +static constexpr const char* kDex2oat64Path = ANDROID_ART_APEX_BIN "/dex2oat64"; +static constexpr const char* kDex2oatDebug32Path = ANDROID_ART_APEX_BIN "/dex2oatd32"; +static constexpr const char* kDex2oatDebug64Path = ANDROID_ART_APEX_BIN "/dex2oatd64"; static constexpr const char* kProfmanPath = ANDROID_ART_APEX_BIN "/profman"; static constexpr const char* kProfmanDebugPath = ANDROID_ART_APEX_BIN "/profmand"; static constexpr const char* kDexoptanalyzerPath = ANDROID_ART_APEX_BIN "/dexoptanalyzer"; diff --git a/cmds/installd/tests/installd_dexopt_test.cpp b/cmds/installd/tests/installd_dexopt_test.cpp index 9a1888cf70..96f5e44030 100644 --- a/cmds/installd/tests/installd_dexopt_test.cpp +++ b/cmds/installd/tests/installd_dexopt_test.cpp @@ -749,6 +749,36 @@ TEST_F(DexoptTest, ResolveStartupConstStrings) { EXPECT_TRUE(found_enable); } +TEST_F(DexoptTest, DexoptDex2oat64Enabled) { + LOG(INFO) << "DexoptDex2oat64Enabled"; + const std::string property = "dalvik.vm.dex2oat64.enabled"; + const std::string previous_value = android::base::GetProperty(property, ""); + auto restore_property = android::base::make_scope_guard([=]() { + android::base::SetProperty(property, previous_value); + }); + std::string odex = GetPrimaryDexArtifact(app_oat_dir_.c_str(), apk_path_, "odex"); + // Disable the property and use dex2oat32. + ASSERT_TRUE(android::base::SetProperty(property, "false")) << property; + CompilePrimaryDexOk("speed-profile", + DEXOPT_IDLE_BACKGROUND_JOB | DEXOPT_PROFILE_GUIDED | + DEXOPT_GENERATE_APP_IMAGE, + app_oat_dir_.c_str(), + kTestAppGid, + DEX2OAT_FROM_SCRATCH, + /*binder_result=*/nullptr, + empty_dm_file_.c_str()); + // Enable the property and use dex2oat64. + ASSERT_TRUE(android::base::SetProperty(property, "true")) << property; + CompilePrimaryDexOk("speed-profile", + DEXOPT_IDLE_BACKGROUND_JOB | DEXOPT_PROFILE_GUIDED | + DEXOPT_GENERATE_APP_IMAGE, + app_oat_dir_.c_str(), + kTestAppGid, + DEX2OAT_FROM_SCRATCH, + /*binder_result=*/nullptr, + empty_dm_file_.c_str()); +} + class PrimaryDexReCompilationTest : public DexoptTest { public: virtual void SetUp() { |