Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f85ddb9c authored by Calin Juravle's avatar Calin Juravle
Browse files

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: c8a0442c)

Merged-In: I83ff959389bafcfce291485f78e1b05d6ca42625
Change-Id: I83ff959389bafcfce291485f78e1b05d6ca42625
parent b5075fb2
Loading
Loading
Loading
Loading
+27 −10
Original line number Diff line number Diff line
@@ -318,6 +318,16 @@ static const char* kJitZygoteImage =
// 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 @@ class RunDex2Oat : public ExecVHelper {
                                                                 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 @@ static bool analyze_profiles(uid_t uid, const std::string& package_name,
    }

    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 @@ static bool create_app_profile_snapshot(int32_t app_id,
    }

    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 */