Loading cmds/installd/dexopt.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -1956,7 +1956,7 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins join_fds(context_input_fds), swap_fd.get(), instruction_set, compiler_filter, join_fds(context_input_fds), swap_fd.get(), instruction_set, compiler_filter, debuggable, boot_complete, for_restore, target_sdk_version, debuggable, boot_complete, for_restore, target_sdk_version, enable_hidden_api_checks, generate_compact_dex, use_jitzygote_image, enable_hidden_api_checks, generate_compact_dex, use_jitzygote_image, compilation_reason); background_job_compile, compilation_reason); bool cancelled = false; bool cancelled = false; pid_t pid = dexopt_status_->check_cancellation_and_fork(&cancelled); pid_t pid = dexopt_status_->check_cancellation_and_fork(&cancelled); Loading cmds/installd/run_dex2oat.cpp +17 −4 Original line number Original line Diff line number Diff line Loading @@ -81,6 +81,7 @@ void RunDex2Oat::Initialize(const UniqueFile& output_oat, bool enable_hidden_api_checks, bool enable_hidden_api_checks, bool generate_compact_dex, bool generate_compact_dex, bool use_jitzygote, bool use_jitzygote, bool background_job_compile, const char* compilation_reason) { const char* compilation_reason) { PrepareBootImageFlags(use_jitzygote); PrepareBootImageFlags(use_jitzygote); Loading @@ -92,7 +93,8 @@ void RunDex2Oat::Initialize(const UniqueFile& output_oat, debuggable, target_sdk_version, enable_hidden_api_checks, debuggable, target_sdk_version, enable_hidden_api_checks, generate_compact_dex, compilation_reason); generate_compact_dex, compilation_reason); PrepareCompilerRuntimeAndPerfConfigFlags(post_bootcomplete, for_restore); PrepareCompilerRuntimeAndPerfConfigFlags(post_bootcomplete, for_restore, background_job_compile); const std::string dex2oat_flags = GetProperty("dalvik.vm.dex2oat-flags", ""); const std::string dex2oat_flags = GetProperty("dalvik.vm.dex2oat-flags", ""); std::vector<std::string> dex2oat_flags_args = SplitBySpaces(dex2oat_flags); std::vector<std::string> dex2oat_flags_args = SplitBySpaces(dex2oat_flags); Loading Loading @@ -296,7 +298,8 @@ void RunDex2Oat::PrepareCompilerConfigFlags(const UniqueFile& input_vdex, } } void RunDex2Oat::PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete, void RunDex2Oat::PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete, bool for_restore) { bool for_restore, bool background_job_compile) { // CPU set // CPU set { { std::string cpu_set_format = "--cpu-set=%s"; std::string cpu_set_format = "--cpu-set=%s"; Loading @@ -306,7 +309,12 @@ void RunDex2Oat::PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete "dalvik.vm.restore-dex2oat-cpu-set", "dalvik.vm.restore-dex2oat-cpu-set", "dalvik.vm.dex2oat-cpu-set", "dalvik.vm.dex2oat-cpu-set", cpu_set_format) cpu_set_format) : MapPropertyToArg("dalvik.vm.dex2oat-cpu-set", cpu_set_format)) : (background_job_compile ? MapPropertyToArgWithBackup( "dalvik.vm.background-dex2oat-cpu-set", "dalvik.vm.dex2oat-cpu-set", cpu_set_format) : MapPropertyToArg("dalvik.vm.dex2oat-cpu-set", cpu_set_format))) : MapPropertyToArg("dalvik.vm.boot-dex2oat-cpu-set", cpu_set_format); : MapPropertyToArg("dalvik.vm.boot-dex2oat-cpu-set", cpu_set_format); AddArg(dex2oat_cpu_set_arg); AddArg(dex2oat_cpu_set_arg); } } Loading @@ -320,7 +328,12 @@ void RunDex2Oat::PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete "dalvik.vm.restore-dex2oat-threads", "dalvik.vm.restore-dex2oat-threads", "dalvik.vm.dex2oat-threads", "dalvik.vm.dex2oat-threads", threads_format) threads_format) : MapPropertyToArg("dalvik.vm.dex2oat-threads", threads_format)) : (background_job_compile ? MapPropertyToArgWithBackup( "dalvik.vm.background-dex2oat-threads", "dalvik.vm.dex2oat-threads", threads_format) : MapPropertyToArg("dalvik.vm.dex2oat-threads", threads_format))) : MapPropertyToArg("dalvik.vm.boot-dex2oat-threads", threads_format); : MapPropertyToArg("dalvik.vm.boot-dex2oat-threads", threads_format); AddArg(dex2oat_threads_arg); AddArg(dex2oat_threads_arg); } } Loading cmds/installd/run_dex2oat.h +4 −1 Original line number Original line Diff line number Diff line Loading @@ -51,6 +51,7 @@ class RunDex2Oat { bool enable_hidden_api_checks, bool enable_hidden_api_checks, bool generate_compact_dex, bool generate_compact_dex, bool use_jitzygote, bool use_jitzygote, bool background_job_compile, const char* compilation_reason); const char* compilation_reason); void Exec(int exit_code); void Exec(int exit_code); Loading @@ -76,7 +77,9 @@ class RunDex2Oat { bool enable_hidden_api_checks, bool enable_hidden_api_checks, bool generate_compact_dex, bool generate_compact_dex, const char* compilation_reason); const char* compilation_reason); void PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete, bool for_restore); void PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete, bool for_restore, bool background_job_compile); virtual std::string GetProperty(const std::string& key, const std::string& default_value); virtual std::string GetProperty(const std::string& key, const std::string& default_value); virtual bool GetBoolProperty(const std::string& key, bool default_value); virtual bool GetBoolProperty(const std::string& key, bool default_value); Loading cmds/installd/run_dex2oat_test.cpp +50 −0 Original line number Original line Diff line number Diff line Loading @@ -115,6 +115,7 @@ class RunDex2OatTest : public testing::Test { bool enable_hidden_api_checks = false; bool enable_hidden_api_checks = false; bool generate_compact_dex = true; bool generate_compact_dex = true; bool use_jitzygote = false; bool use_jitzygote = false; bool background_job_compile = false; const char* compilation_reason = nullptr; const char* compilation_reason = nullptr; }; }; Loading Loading @@ -259,6 +260,7 @@ class RunDex2OatTest : public testing::Test { args->enable_hidden_api_checks, args->enable_hidden_api_checks, args->generate_compact_dex, args->generate_compact_dex, args->use_jitzygote, args->use_jitzygote, args->background_job_compile, args->compilation_reason); args->compilation_reason); runner.Exec(/*exit_code=*/ 0); runner.Exec(/*exit_code=*/ 0); } } Loading Loading @@ -375,6 +377,30 @@ TEST_F(RunDex2OatTest, CpuSetPostBootCompleteNotForRestore) { VerifyExpectedFlags(); VerifyExpectedFlags(); } } TEST_F(RunDex2OatTest, CpuSetPostBootCompleteBackground) { setSystemProperty("dalvik.vm.background-dex2oat-cpu-set", "1,3"); setSystemProperty("dalvik.vm.dex2oat-cpu-set", "1,2"); auto args = RunDex2OatArgs::MakeDefaultTestArgs(); args->post_bootcomplete = true; args->background_job_compile = true; CallRunDex2Oat(std::move(args)); SetExpectedFlagUsed("--cpu-set", "=1,3"); VerifyExpectedFlags(); } TEST_F(RunDex2OatTest, CpuSetPostBootCompleteBackground_Backup) { setSystemProperty("dalvik.vm.background-dex2oat-cpu-set", ""); setSystemProperty("dalvik.vm.dex2oat-cpu-set", "1,2"); auto args = RunDex2OatArgs::MakeDefaultTestArgs(); args->post_bootcomplete = true; args->background_job_compile = true; CallRunDex2Oat(std::move(args)); SetExpectedFlagUsed("--cpu-set", "=1,2"); VerifyExpectedFlags(); } TEST_F(RunDex2OatTest, CpuSetPostBootCompleteForRestore) { TEST_F(RunDex2OatTest, CpuSetPostBootCompleteForRestore) { setSystemProperty("dalvik.vm.restore-dex2oat-cpu-set", "1,2"); setSystemProperty("dalvik.vm.restore-dex2oat-cpu-set", "1,2"); setSystemProperty("dalvik.vm.dex2oat-cpu-set", "2,3"); setSystemProperty("dalvik.vm.dex2oat-cpu-set", "2,3"); Loading Loading @@ -481,6 +507,30 @@ TEST_F(RunDex2OatTest, ThreadsPostBootCompleteNotForRestore) { VerifyExpectedFlags(); VerifyExpectedFlags(); } } TEST_F(RunDex2OatTest, ThreadsPostBootCompleteBackground) { setSystemProperty("dalvik.vm.background-dex2oat-threads", "2"); setSystemProperty("dalvik.vm.dex2oat-threads", "3"); auto args = RunDex2OatArgs::MakeDefaultTestArgs(); args->post_bootcomplete = true; args->background_job_compile = true; CallRunDex2Oat(std::move(args)); SetExpectedFlagUsed("-j", "2"); VerifyExpectedFlags(); } TEST_F(RunDex2OatTest, ThreadsPostBootCompleteBackground_Backup) { setSystemProperty("dalvik.vm.background-dex2oat-threads", ""); setSystemProperty("dalvik.vm.dex2oat-threads", "3"); auto args = RunDex2OatArgs::MakeDefaultTestArgs(); args->post_bootcomplete = true; args->background_job_compile = true; CallRunDex2Oat(std::move(args)); SetExpectedFlagUsed("-j", "3"); VerifyExpectedFlags(); } TEST_F(RunDex2OatTest, ThreadsPostBootCompleteForRestore) { TEST_F(RunDex2OatTest, ThreadsPostBootCompleteForRestore) { setSystemProperty("dalvik.vm.restore-dex2oat-threads", "4"); setSystemProperty("dalvik.vm.restore-dex2oat-threads", "4"); setSystemProperty("dalvik.vm.dex2oat-threads", "5"); setSystemProperty("dalvik.vm.dex2oat-threads", "5"); Loading Loading
cmds/installd/dexopt.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -1956,7 +1956,7 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins join_fds(context_input_fds), swap_fd.get(), instruction_set, compiler_filter, join_fds(context_input_fds), swap_fd.get(), instruction_set, compiler_filter, debuggable, boot_complete, for_restore, target_sdk_version, debuggable, boot_complete, for_restore, target_sdk_version, enable_hidden_api_checks, generate_compact_dex, use_jitzygote_image, enable_hidden_api_checks, generate_compact_dex, use_jitzygote_image, compilation_reason); background_job_compile, compilation_reason); bool cancelled = false; bool cancelled = false; pid_t pid = dexopt_status_->check_cancellation_and_fork(&cancelled); pid_t pid = dexopt_status_->check_cancellation_and_fork(&cancelled); Loading
cmds/installd/run_dex2oat.cpp +17 −4 Original line number Original line Diff line number Diff line Loading @@ -81,6 +81,7 @@ void RunDex2Oat::Initialize(const UniqueFile& output_oat, bool enable_hidden_api_checks, bool enable_hidden_api_checks, bool generate_compact_dex, bool generate_compact_dex, bool use_jitzygote, bool use_jitzygote, bool background_job_compile, const char* compilation_reason) { const char* compilation_reason) { PrepareBootImageFlags(use_jitzygote); PrepareBootImageFlags(use_jitzygote); Loading @@ -92,7 +93,8 @@ void RunDex2Oat::Initialize(const UniqueFile& output_oat, debuggable, target_sdk_version, enable_hidden_api_checks, debuggable, target_sdk_version, enable_hidden_api_checks, generate_compact_dex, compilation_reason); generate_compact_dex, compilation_reason); PrepareCompilerRuntimeAndPerfConfigFlags(post_bootcomplete, for_restore); PrepareCompilerRuntimeAndPerfConfigFlags(post_bootcomplete, for_restore, background_job_compile); const std::string dex2oat_flags = GetProperty("dalvik.vm.dex2oat-flags", ""); const std::string dex2oat_flags = GetProperty("dalvik.vm.dex2oat-flags", ""); std::vector<std::string> dex2oat_flags_args = SplitBySpaces(dex2oat_flags); std::vector<std::string> dex2oat_flags_args = SplitBySpaces(dex2oat_flags); Loading Loading @@ -296,7 +298,8 @@ void RunDex2Oat::PrepareCompilerConfigFlags(const UniqueFile& input_vdex, } } void RunDex2Oat::PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete, void RunDex2Oat::PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete, bool for_restore) { bool for_restore, bool background_job_compile) { // CPU set // CPU set { { std::string cpu_set_format = "--cpu-set=%s"; std::string cpu_set_format = "--cpu-set=%s"; Loading @@ -306,7 +309,12 @@ void RunDex2Oat::PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete "dalvik.vm.restore-dex2oat-cpu-set", "dalvik.vm.restore-dex2oat-cpu-set", "dalvik.vm.dex2oat-cpu-set", "dalvik.vm.dex2oat-cpu-set", cpu_set_format) cpu_set_format) : MapPropertyToArg("dalvik.vm.dex2oat-cpu-set", cpu_set_format)) : (background_job_compile ? MapPropertyToArgWithBackup( "dalvik.vm.background-dex2oat-cpu-set", "dalvik.vm.dex2oat-cpu-set", cpu_set_format) : MapPropertyToArg("dalvik.vm.dex2oat-cpu-set", cpu_set_format))) : MapPropertyToArg("dalvik.vm.boot-dex2oat-cpu-set", cpu_set_format); : MapPropertyToArg("dalvik.vm.boot-dex2oat-cpu-set", cpu_set_format); AddArg(dex2oat_cpu_set_arg); AddArg(dex2oat_cpu_set_arg); } } Loading @@ -320,7 +328,12 @@ void RunDex2Oat::PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete "dalvik.vm.restore-dex2oat-threads", "dalvik.vm.restore-dex2oat-threads", "dalvik.vm.dex2oat-threads", "dalvik.vm.dex2oat-threads", threads_format) threads_format) : MapPropertyToArg("dalvik.vm.dex2oat-threads", threads_format)) : (background_job_compile ? MapPropertyToArgWithBackup( "dalvik.vm.background-dex2oat-threads", "dalvik.vm.dex2oat-threads", threads_format) : MapPropertyToArg("dalvik.vm.dex2oat-threads", threads_format))) : MapPropertyToArg("dalvik.vm.boot-dex2oat-threads", threads_format); : MapPropertyToArg("dalvik.vm.boot-dex2oat-threads", threads_format); AddArg(dex2oat_threads_arg); AddArg(dex2oat_threads_arg); } } Loading
cmds/installd/run_dex2oat.h +4 −1 Original line number Original line Diff line number Diff line Loading @@ -51,6 +51,7 @@ class RunDex2Oat { bool enable_hidden_api_checks, bool enable_hidden_api_checks, bool generate_compact_dex, bool generate_compact_dex, bool use_jitzygote, bool use_jitzygote, bool background_job_compile, const char* compilation_reason); const char* compilation_reason); void Exec(int exit_code); void Exec(int exit_code); Loading @@ -76,7 +77,9 @@ class RunDex2Oat { bool enable_hidden_api_checks, bool enable_hidden_api_checks, bool generate_compact_dex, bool generate_compact_dex, const char* compilation_reason); const char* compilation_reason); void PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete, bool for_restore); void PrepareCompilerRuntimeAndPerfConfigFlags(bool post_bootcomplete, bool for_restore, bool background_job_compile); virtual std::string GetProperty(const std::string& key, const std::string& default_value); virtual std::string GetProperty(const std::string& key, const std::string& default_value); virtual bool GetBoolProperty(const std::string& key, bool default_value); virtual bool GetBoolProperty(const std::string& key, bool default_value); Loading
cmds/installd/run_dex2oat_test.cpp +50 −0 Original line number Original line Diff line number Diff line Loading @@ -115,6 +115,7 @@ class RunDex2OatTest : public testing::Test { bool enable_hidden_api_checks = false; bool enable_hidden_api_checks = false; bool generate_compact_dex = true; bool generate_compact_dex = true; bool use_jitzygote = false; bool use_jitzygote = false; bool background_job_compile = false; const char* compilation_reason = nullptr; const char* compilation_reason = nullptr; }; }; Loading Loading @@ -259,6 +260,7 @@ class RunDex2OatTest : public testing::Test { args->enable_hidden_api_checks, args->enable_hidden_api_checks, args->generate_compact_dex, args->generate_compact_dex, args->use_jitzygote, args->use_jitzygote, args->background_job_compile, args->compilation_reason); args->compilation_reason); runner.Exec(/*exit_code=*/ 0); runner.Exec(/*exit_code=*/ 0); } } Loading Loading @@ -375,6 +377,30 @@ TEST_F(RunDex2OatTest, CpuSetPostBootCompleteNotForRestore) { VerifyExpectedFlags(); VerifyExpectedFlags(); } } TEST_F(RunDex2OatTest, CpuSetPostBootCompleteBackground) { setSystemProperty("dalvik.vm.background-dex2oat-cpu-set", "1,3"); setSystemProperty("dalvik.vm.dex2oat-cpu-set", "1,2"); auto args = RunDex2OatArgs::MakeDefaultTestArgs(); args->post_bootcomplete = true; args->background_job_compile = true; CallRunDex2Oat(std::move(args)); SetExpectedFlagUsed("--cpu-set", "=1,3"); VerifyExpectedFlags(); } TEST_F(RunDex2OatTest, CpuSetPostBootCompleteBackground_Backup) { setSystemProperty("dalvik.vm.background-dex2oat-cpu-set", ""); setSystemProperty("dalvik.vm.dex2oat-cpu-set", "1,2"); auto args = RunDex2OatArgs::MakeDefaultTestArgs(); args->post_bootcomplete = true; args->background_job_compile = true; CallRunDex2Oat(std::move(args)); SetExpectedFlagUsed("--cpu-set", "=1,2"); VerifyExpectedFlags(); } TEST_F(RunDex2OatTest, CpuSetPostBootCompleteForRestore) { TEST_F(RunDex2OatTest, CpuSetPostBootCompleteForRestore) { setSystemProperty("dalvik.vm.restore-dex2oat-cpu-set", "1,2"); setSystemProperty("dalvik.vm.restore-dex2oat-cpu-set", "1,2"); setSystemProperty("dalvik.vm.dex2oat-cpu-set", "2,3"); setSystemProperty("dalvik.vm.dex2oat-cpu-set", "2,3"); Loading Loading @@ -481,6 +507,30 @@ TEST_F(RunDex2OatTest, ThreadsPostBootCompleteNotForRestore) { VerifyExpectedFlags(); VerifyExpectedFlags(); } } TEST_F(RunDex2OatTest, ThreadsPostBootCompleteBackground) { setSystemProperty("dalvik.vm.background-dex2oat-threads", "2"); setSystemProperty("dalvik.vm.dex2oat-threads", "3"); auto args = RunDex2OatArgs::MakeDefaultTestArgs(); args->post_bootcomplete = true; args->background_job_compile = true; CallRunDex2Oat(std::move(args)); SetExpectedFlagUsed("-j", "2"); VerifyExpectedFlags(); } TEST_F(RunDex2OatTest, ThreadsPostBootCompleteBackground_Backup) { setSystemProperty("dalvik.vm.background-dex2oat-threads", ""); setSystemProperty("dalvik.vm.dex2oat-threads", "3"); auto args = RunDex2OatArgs::MakeDefaultTestArgs(); args->post_bootcomplete = true; args->background_job_compile = true; CallRunDex2Oat(std::move(args)); SetExpectedFlagUsed("-j", "3"); VerifyExpectedFlags(); } TEST_F(RunDex2OatTest, ThreadsPostBootCompleteForRestore) { TEST_F(RunDex2OatTest, ThreadsPostBootCompleteForRestore) { setSystemProperty("dalvik.vm.restore-dex2oat-threads", "4"); setSystemProperty("dalvik.vm.restore-dex2oat-threads", "4"); setSystemProperty("dalvik.vm.dex2oat-threads", "5"); setSystemProperty("dalvik.vm.dex2oat-threads", "5"); Loading