Handle the boot profile format when analyzing profiles
When analyzing profiles for dexopt, use the boot image profile format
if the system is configured to profile the boot image.
Test: atest installd_dexopt_test
Bug: 155423653
(cherry-picked from commit: c8a0442cad47728fcf433aed729a691268776f48)
Merged-In: I83ff959389bafcfce291485f78e1b05d6ca42625
Change-Id: I83ff959389bafcfce291485f78e1b05d6ca42625
diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp
index 3c04435..82be007 100644
--- a/cmds/installd/dexopt.cpp
+++ b/cmds/installd/dexopt.cpp
@@ -318,6 +318,16 @@
// Phenotype property name for enabling profiling the boot class path.
static const char* PROFILE_BOOT_CLASS_PATH = "profilebootclasspath";
+static bool IsBootClassPathProfilingEnable() {
+ std::string profile_boot_class_path = GetProperty("dalvik.vm.profilebootclasspath", "");
+ profile_boot_class_path =
+ server_configurable_flags::GetServerConfigurableFlag(
+ RUNTIME_NATIVE_BOOT_NAMESPACE,
+ PROFILE_BOOT_CLASS_PATH,
+ /*default_value=*/ profile_boot_class_path);
+ return profile_boot_class_path == "true";
+}
+
class RunDex2Oat : public ExecVHelper {
public:
RunDex2Oat(int zip_fd,
@@ -450,14 +460,7 @@
ENABLE_JITZYGOTE_IMAGE,
/*default_value=*/ "");
- std::string profile_boot_class_path = GetProperty("dalvik.vm.profilebootclasspath", "");
- profile_boot_class_path =
- server_configurable_flags::GetServerConfigurableFlag(
- RUNTIME_NATIVE_BOOT_NAMESPACE,
- PROFILE_BOOT_CLASS_PATH,
- /*default_value=*/ profile_boot_class_path);
-
- if (use_jitzygote_image == "true" || profile_boot_class_path == "true") {
+ if (use_jitzygote_image == "true" || IsBootClassPathProfilingEnable()) {
boot_image = StringPrintf("--boot-image=%s", kJitZygoteImage);
} else {
boot_image = MapPropertyToArg("dalvik.vm.boot-image", "--boot-image=%s");
@@ -896,7 +899,15 @@
}
RunProfman profman_merge;
- profman_merge.SetupMerge(profiles_fd, reference_profile_fd);
+ const std::vector<unique_fd>& apk_fds = std::vector<unique_fd>();
+ const std::vector<std::string>& dex_locations = std::vector<std::string>();
+ profman_merge.SetupMerge(
+ profiles_fd,
+ reference_profile_fd,
+ apk_fds,
+ dex_locations,
+ /* for_snapshot= */ false,
+ IsBootClassPathProfilingEnable());
pid_t pid = fork();
if (pid == 0) {
/* child -- drop privileges before continuing */
@@ -2810,7 +2821,13 @@
}
RunProfman args;
- args.SetupMerge(profiles_fd, snapshot_fd, apk_fds, dex_locations, /*for_snapshot=*/true);
+ // This is specifically a snapshot for an app, so don't use boot image profiles.
+ args.SetupMerge(profiles_fd,
+ snapshot_fd,
+ apk_fds,
+ dex_locations,
+ /* for_snapshot= */ true,
+ /* for_boot_image= */ false);
pid_t pid = fork();
if (pid == 0) {
/* child -- drop privileges before continuing */