diff options
| author | 2022-01-04 11:54:46 +0000 | |
|---|---|---|
| committer | 2022-01-04 11:54:46 +0000 | |
| commit | fcf748dbd42225242196e5680d654c04875b874c (patch) | |
| tree | 554cf9a5ab6b42c847ba8b2467420c050fdb6e1f | |
| parent | ecc1f7d135ba90bc42d12b54876bec019c60637b (diff) | |
| parent | 2556fc0a6de81bfc0377616a8562de704644f759 (diff) | |
Merge "Update JIT Zygote image option for installd and otapreopt." am: 9a869c9c1f am: 1f6dbdcf37 am: 2556fc0a6d
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1931837
Change-Id: Ic494e2efdbd496f73ef8e21cd92cd9ae91486b63
| -rw-r--r-- | cmds/installd/otapreopt.cpp | 17 | ||||
| -rw-r--r-- | cmds/installd/run_dex2oat.cpp | 20 | ||||
| -rw-r--r-- | cmds/installd/run_dex2oat.h | 4 | ||||
| -rw-r--r-- | cmds/installd/run_dex2oat_test.cpp | 23 |
4 files changed, 35 insertions, 29 deletions
diff --git a/cmds/installd/otapreopt.cpp b/cmds/installd/otapreopt.cpp index 6aa32b8d8e..e978e79d86 100644 --- a/cmds/installd/otapreopt.cpp +++ b/cmds/installd/otapreopt.cpp @@ -140,8 +140,8 @@ class OTAPreoptService { PrepareEnvironmentVariables(); - if (!EnsureBootImageAndDalvikCache()) { - LOG(ERROR) << "Bad boot image."; + if (!EnsureDalvikCache()) { + LOG(ERROR) << "Bad dalvik cache."; return 5; } @@ -349,8 +349,8 @@ private: } } - // Ensure that we have the right boot image and cache file structures. - bool EnsureBootImageAndDalvikCache() const { + // Ensure that we have the right cache file structures. + bool EnsureDalvikCache() const { if (parameters_.instruction_set == nullptr) { LOG(ERROR) << "Instruction set missing."; return false; @@ -376,15 +376,6 @@ private: } } - // Check whether we have a boot image. - // TODO: check that the files are correct wrt/ jars. - std::string preopted_boot_art_path = - StringPrintf("/apex/com.android.art/javalib/%s/boot.art", isa); - if (access(preopted_boot_art_path.c_str(), F_OK) != 0) { - PLOG(ERROR) << "Bad access() to " << preopted_boot_art_path; - return false; - } - return true; } diff --git a/cmds/installd/run_dex2oat.cpp b/cmds/installd/run_dex2oat.cpp index b6616841f0..51c4589440 100644 --- a/cmds/installd/run_dex2oat.cpp +++ b/cmds/installd/run_dex2oat.cpp @@ -50,10 +50,6 @@ static constexpr bool kMinidebugInfoSystemPropertyDefault = false; static constexpr const char* kMinidebugDex2oatFlag = "--generate-mini-debug-info"; static constexpr const char* kDisableCompactDexFlag = "--compact-dex-level=none"; -// Location of the JIT Zygote image. -static const char* kJitZygoteImage = - "boot.art:/nonx/boot-framework.art!/system/etc/boot-image.prof"; - std::vector<std::string> SplitBySpaces(const std::string& str) { if (str.empty()) { return {}; @@ -84,9 +80,9 @@ void RunDex2Oat::Initialize(const UniqueFile& output_oat, int target_sdk_version, bool enable_hidden_api_checks, bool generate_compact_dex, - bool use_jitzygote_image, + bool use_jitzygote, const char* compilation_reason) { - PrepareBootImageFlags(use_jitzygote_image); + PrepareBootImageFlags(use_jitzygote); PrepareInputFileFlags(output_oat, output_vdex, output_image, input_dex, input_vdex, dex_metadata, profile, swap_fd, class_loader_context, @@ -112,14 +108,14 @@ void RunDex2Oat::Initialize(const UniqueFile& output_oat, RunDex2Oat::~RunDex2Oat() {} -void RunDex2Oat::PrepareBootImageFlags(bool use_jitzygote_image) { - std::string boot_image; - if (use_jitzygote_image) { - boot_image = StringPrintf("--boot-image=%s", kJitZygoteImage); +void RunDex2Oat::PrepareBootImageFlags(bool use_jitzygote) { + if (use_jitzygote) { + // Don't pass a boot image because JIT Zygote should decide which image to use. Typically, + // it does not use any boot image on disk. + AddArg("--force-jit-zygote"); } else { - boot_image = MapPropertyToArg("dalvik.vm.boot-image", "--boot-image=%s"); + AddArg(MapPropertyToArg("dalvik.vm.boot-image", "--boot-image=%s")); } - AddArg(boot_image); } void RunDex2Oat::PrepareInputFileFlags(const UniqueFile& output_oat, diff --git a/cmds/installd/run_dex2oat.h b/cmds/installd/run_dex2oat.h index 475e12413d..559244f2b7 100644 --- a/cmds/installd/run_dex2oat.h +++ b/cmds/installd/run_dex2oat.h @@ -50,13 +50,13 @@ class RunDex2Oat { int target_sdk_version, bool enable_hidden_api_checks, bool generate_compact_dex, - bool use_jitzygote_image, + bool use_jitzygote, const char* compilation_reason); void Exec(int exit_code); protected: - void PrepareBootImageFlags(bool use_jitzygote_image); + void PrepareBootImageFlags(bool use_jitzygote); void PrepareInputFileFlags(const UniqueFile& output_oat, const UniqueFile& output_vdex, const UniqueFile& output_image, diff --git a/cmds/installd/run_dex2oat_test.cpp b/cmds/installd/run_dex2oat_test.cpp index 0a638cd51b..2a8135a037 100644 --- a/cmds/installd/run_dex2oat_test.cpp +++ b/cmds/installd/run_dex2oat_test.cpp @@ -114,7 +114,7 @@ class RunDex2OatTest : public testing::Test { int target_sdk_version = 0; bool enable_hidden_api_checks = false; bool generate_compact_dex = true; - bool use_jitzygote_image = false; + bool use_jitzygote = false; const char* compilation_reason = nullptr; }; @@ -175,6 +175,7 @@ class RunDex2OatTest : public testing::Test { default_expected_flags_["--swap-fd"] = FLAG_UNUSED; default_expected_flags_["--class-loader-context"] = FLAG_UNUSED; default_expected_flags_["--class-loader-context-fds"] = FLAG_UNUSED; + default_expected_flags_["--boot-image"] = FLAG_UNUSED; // Arch default_expected_flags_["--instruction-set"] = "=arm64"; @@ -190,6 +191,7 @@ class RunDex2OatTest : public testing::Test { default_expected_flags_["--max-image-block-size"] = FLAG_UNUSED; default_expected_flags_["--very-large-app-threshold"] = FLAG_UNUSED; default_expected_flags_["--resolve-startup-const-strings"] = FLAG_UNUSED; + default_expected_flags_["--force-jit-zygote"] = FLAG_UNUSED; // Debug default_expected_flags_["--debuggable"] = FLAG_UNUSED; @@ -256,7 +258,7 @@ class RunDex2OatTest : public testing::Test { args->target_sdk_version, args->enable_hidden_api_checks, args->generate_compact_dex, - args->use_jitzygote_image, + args->use_jitzygote, args->compilation_reason); runner.Exec(/*exit_code=*/ 0); } @@ -557,5 +559,22 @@ TEST_F(RunDex2OatTest, ExtraFlags) { VerifyExpectedFlags(); } +TEST_F(RunDex2OatTest, UseJitZygoteImage) { + auto args = RunDex2OatArgs::MakeDefaultTestArgs(); + args->use_jitzygote = true; + CallRunDex2Oat(std::move(args)); + + SetExpectedFlagUsed("--force-jit-zygote", ""); + VerifyExpectedFlags(); +} + +TEST_F(RunDex2OatTest, BootImage) { + setSystemProperty("dalvik.vm.boot-image", "foo.art:bar.art"); + CallRunDex2Oat(RunDex2OatArgs::MakeDefaultTestArgs()); + + SetExpectedFlagUsed("--boot-image", "=foo.art:bar.art"); + VerifyExpectedFlags(); +} + } // namespace installd } // namespace android |