From 8e845ae19def2503850747a5996c5c011e2e4d99 Mon Sep 17 00:00:00 2001 From: harryhrp Date: Tue, 31 Dec 2024 14:18:59 +0800 Subject: [PATCH] Aot disk file path adjustment Aot disk file path adjustment Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IBEVFO Signed-off-by: harryhrp --- bundle.json | 1 + compiler_service/BUILD.gn | 9 +++++++++ compiler_service/ark_aot_compiler.cfg | 15 +++++++++++++++ .../aotcompilerimpl_unit.cpp | 8 ++++---- ecmascript/compiler/aot_compiler.cpp | 17 ----------------- ecmascript/ohos/ohos_pkg_verifier.h | 6 +++--- ecmascript/ohos/tests/ohos_test.cpp | 7 ++++--- ecmascript/platform/aot_crash_info.h | 1 + ecmascript/platform/unix/aot_crash_info.cpp | 4 +--- 9 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 compiler_service/ark_aot_compiler.cfg diff --git a/bundle.json b/bundle.json index c205261972..f6a6235b41 100644 --- a/bundle.json +++ b/bundle.json @@ -62,6 +62,7 @@ "//arkcompiler/ets_runtime:ark_js_packages", "//arkcompiler/ets_runtime:ark_js_host_linux_tools_packages", "//arkcompiler/ets_runtime/etc:arkcompiler.para.dac", + "//arkcompiler/ets_runtime/compiler_service:ark_aot_compiler.cfg", "//arkcompiler/ets_runtime/compiler_service:compiler_service" ], "inner_kits": [ diff --git a/compiler_service/BUILD.gn b/compiler_service/BUILD.gn index ede1a95506..e36aee4d1b 100644 --- a/compiler_service/BUILD.gn +++ b/compiler_service/BUILD.gn @@ -94,6 +94,15 @@ ohos_prebuilt_etc("compiler_service_cfg") { subsystem_name = "arkcompiler" } +ohos_prebuilt_etc("ark_aot_compiler.cfg") { + source = "ark_aot_compiler.cfg" + relative_install_dir = "init" + + # Set the subsystem name + part_name = "ets_runtime" + subsystem_name = "arkcompiler" +} + ohos_sa_profile("compiler_sa_profile") { sources = [ "sa_profile/5300.json" ] part_name = "ets_runtime" diff --git a/compiler_service/ark_aot_compiler.cfg b/compiler_service/ark_aot_compiler.cfg new file mode 100644 index 0000000000..8d0db7a2ab --- /dev/null +++ b/compiler_service/ark_aot_compiler.cfg @@ -0,0 +1,15 @@ +{ + "jobs" : [{ + "name" : "post-fs-data", + "cmds" : [ + "mkdir /data/app/el1/public/aot_compiler 0711 root root", + "mkdir /data/app/el1/public/aot_compiler/ark_cache 0711 root root", + "mkdir /data/app/el1/0/aot_compiler 0711 root root", + "mkdir /data/app/el1/0/aot_compiler/ark_profile 0711 root root", + "restorecon /data/app/el1/public/aot_compiler", + "restorecon /data/app/el1/public/aot_compiler/ark_cache" + ] + } + ], + "services" : [] +} diff --git a/compiler_service/test/unittest/aotcompilerimpl_unit/aotcompilerimpl_unit.cpp b/compiler_service/test/unittest/aotcompilerimpl_unit/aotcompilerimpl_unit.cpp index fd7b069b26..2ab2a38d61 100644 --- a/compiler_service/test/unittest/aotcompilerimpl_unit/aotcompilerimpl_unit.cpp +++ b/compiler_service/test/unittest/aotcompilerimpl_unit/aotcompilerimpl_unit.cpp @@ -50,13 +50,13 @@ const std::string compilerPkgInfoValue = "\"isEncryptedBundle\":\"0x0\"," "\"isScreenOff\":\"0x1\"," "\"moduleName\":\"entry\"," - "\"pgoDir\":\"/data/local/ark-profile/100/com.ohos.contacts\"," + "\"pgoDir\":\"/data/app/el1/100/aot_compiler/ark_profile/com.ohos.contacts\"," "\"pkgPath\":\"/system/app/Contacts/Contacts.hap\"," "\"processUid\":\"0xbf4\"}"; const std::unordered_map argsMapForTest { {"target-compiler-mode", "partial"}, - {"aot-file", "/data/local/ark-cache/com.ohos.contacts/arm64/entry"}, + {"aot-file", "/data/app/el1/public/aot_compiler/ark_cache/com.ohos.contacts/arm64/entry"}, {"compiler-pkg-info", compilerPkgInfoValue}, {"compiler-external-pkg-info", "[]"}, {"compiler-opt-bc-range", ""}, @@ -65,7 +65,7 @@ const std::unordered_map argsMapForTest { {"ABC-Path", "/system/app/Contacts/Contacts.hap/ets/modules.abc"}, {"BundleUid", "20020079"}, {"BundleGid", "20020079"}, - {"anFileName", "/data/local/ark-cache/com.ohos.contacts/arm64/entry.an"}, + {"anFileName", "/data/app/el1/public/aot_compiler/ark_cache/com.ohos.contacts/arm64/entry.an"}, {"appIdentifier", "5765880207853624761"} }; } // namespace ark_aot_compiler arguments @@ -581,7 +581,7 @@ HWTEST_F(AotCompilerImplTest, AotCompilerImplTest_022, TestSize.Level0) HWTEST_F(AotCompilerImplTest, AotCompilerImplTest_023, TestSize.Level0) { AotCompilerImplMock aotImplMock; - std::string fileName = "/data/local/ark-cache/com.ohos.contacts/arm64/entry.an"; + std::string fileName = "/data/app/el1/public/aot_compiler/ark_cache/com.ohos.contacts/arm64/entry.an"; std::string appSignature = "5765880207853624761"; std::vector sigData; int32_t ret = aotImplMock.PrepareArgsMock(argsMapForTest); diff --git a/ecmascript/compiler/aot_compiler.cpp b/ecmascript/compiler/aot_compiler.cpp index fd32a31713..44a5d3dbf5 100644 --- a/ecmascript/compiler/aot_compiler.cpp +++ b/ecmascript/compiler/aot_compiler.cpp @@ -71,13 +71,6 @@ bool CheckVersion(JSRuntimeOptions& runtimeOptions, AotCompilerStats& compilerSt return false; } -bool IsExistsPkgInfo(AotCompilerPreprocessor &cPreprocessor) -{ - if (cPreprocessor.GetMainPkgArgs()) { - return true; - } - return false; -} } // namespace int Main(const int argc, const char **argv) @@ -128,12 +121,6 @@ int Main(const int argc, const char **argv) return ERR_FAIL; } - if (IsExistsPkgInfo(cPreprocessor)) { - if (AotCrashInfo::IsAotEscaped(cPreprocessor.GetMainPkgArgs()->GetPgoDir())) { - LOG_COMPILER(ERROR) << "Stop compile AOT because there are multiple crashes"; - return ERR_FAIL; - } - } if (runtimeOptions.IsPartialCompilerMode() && cOptions.profilerIn_.empty()) { // no need to compile in partial mode without any ap files. return ERR_NO_AP; @@ -239,10 +226,6 @@ int Main(const int argc, const char **argv) if (runtimeOptions.IsTargetCompilerMode()) { compilerStats.PrintCompilerStatsLog(); } - if (IsExistsPkgInfo(cPreprocessor)) { - ohos::EnableAotJitListHelper::GetInstance()->AddEnableListCount( - ret, cPreprocessor.GetMainPkgArgs()->GetPgoDir()); - } } if (vm->GetJSOptions().IsEnableCompilerLogSnapshot()) { diff --git a/ecmascript/ohos/ohos_pkg_verifier.h b/ecmascript/ohos/ohos_pkg_verifier.h index 04e77b3c69..d4be203872 100644 --- a/ecmascript/ohos/ohos_pkg_verifier.h +++ b/ecmascript/ohos/ohos_pkg_verifier.h @@ -47,10 +47,10 @@ public: static bool CheckArkProfile(AotCompilerPreprocessor &cPreprocessor) { - std::string arkProfilePath = "/data/local/ark-profile/"; + std::regex pattern("/data/app/el1/\\d+/aot_compiler/ark_profile.*"); std::string pgoDir = cPreprocessor.GetMainPkgArgs()->GetPgoDir(); std::string bundleName = cPreprocessor.GetMainPkgArgs()->GetBundleName(); - if (pgoDir.substr(0, arkProfilePath.length()) != arkProfilePath || + if (!std::regex_search(pgoDir, pattern) || pgoDir.find(bundleName) == std::string::npos) { LOG_COMPILER(ERROR) << "verify ark-profile path wrong"; return false; @@ -60,7 +60,7 @@ public: static bool CheckAOTOutputFilePath(AotCompilerPreprocessor &cPreprocessor, CompilationOptions &cOptions) { - std::string arkCachePath = "/data/local/ark-cache/"; + std::string arkCachePath = "/data/app/el1/public/aot_compiler/ark_cache/"; if (cOptions.outputFileName_.substr(0, arkCachePath.length()) != arkCachePath) { LOG_COMPILER(ERROR) << "aot file name wrong"; return false; diff --git a/ecmascript/ohos/tests/ohos_test.cpp b/ecmascript/ohos/tests/ohos_test.cpp index 8a5b2e660e..e570973c38 100644 --- a/ecmascript/ohos/tests/ohos_test.cpp +++ b/ecmascript/ohos/tests/ohos_test.cpp @@ -49,8 +49,9 @@ public: { runtimeOptions_.SetPGOProfilerPath(""); runtimeOptions_.SetTargetCompilerMode("partial"); - runtimeOptions_.SetAOTOutputFile("/data/local/ark-cache/com.ohos.test/arm64/phone"); - runtimeOptions_.SetCompilerPkgJsonInfo(BuildOhosPkgJson("/data/local/ark-profile/100/com.ohos.test")); + runtimeOptions_.SetAOTOutputFile("/data/app/el1/public/aot_compiler/ark_cache/com.ohos.test/arm64/phone"); + runtimeOptions_.SetCompilerPkgJsonInfo( + BuildOhosPkgJson("/data/app/el1/100/aot_compiler/ark_profile/com.ohos.test")); runtimeOptions_.SetCompilerFrameworkAbcPath("/etc/abc/framework"); runtimeOptions_.SetCompilerEnableExternalPkg(true); runtimeOptions_.SetCompilerExternalPkgJsonInfo(BuildOhosExternalPkgJson()); @@ -169,7 +170,7 @@ HWTEST_F_L0(OhosTest, OhosPkgArgsParsePgoDir) AotCompilerPreprocessor preProcessor(vm_, runtimeOptions_, pkgArgsMap, decoder, pandaFileNames); OhosPkgArgs::ParseArgs(preProcessor, cOptions); - ASSERT_EQ(preProcessor.GetMainPkgArgs()->GetPgoDir(), "/data/local/ark-profile/100/com.ohos.test"); + ASSERT_EQ(preProcessor.GetMainPkgArgs()->GetPgoDir(), "/data/app/el1/100/aot_compiler/ark_profile/com.ohos.test"); } HWTEST_F_L0(OhosTest, UseBaselineApFromPgoDir) diff --git a/ecmascript/platform/aot_crash_info.h b/ecmascript/platform/aot_crash_info.h index cc1b987a48..88174b95c1 100644 --- a/ecmascript/platform/aot_crash_info.h +++ b/ecmascript/platform/aot_crash_info.h @@ -20,6 +20,7 @@ #include #include "ecmascript/compiler/aot_compiler_preprocessor.h" +#include "ecmascript/compiler/aot_file/an_file_data_manager.h" #include "ecmascript/dfx/stackinfo/js_stackinfo.h" #include "ecmascript/ohos/ohos_pkg_args.h" #include "ecmascript/ecma_vm.h" diff --git a/ecmascript/platform/unix/aot_crash_info.cpp b/ecmascript/platform/unix/aot_crash_info.cpp index 5a30f8f2c1..6b9b3e4e00 100644 --- a/ecmascript/platform/unix/aot_crash_info.cpp +++ b/ecmascript/platform/unix/aot_crash_info.cpp @@ -109,9 +109,7 @@ void AotCrashInfo::SetOptionPGOProfiler(JSRuntimeOptions *options, const std::st #ifdef AOT_ESCAPE_ENABLE if (ohos::EnableAotJitListHelper::GetInstance()->IsEnableAot(bundleName)) { options->SetEnablePGOProfiler(true); - if (options->GetAOTHasException() || - ohos::EnableAotJitListHelper::GetInstance()->IsAotCompileSuccessOnce() || - IsAotEscaped()) { + if (options->GetAOTHasException() || ecmascript::AnFileDataManager::GetInstance()->IsEnable()) { options->SetEnablePGOProfiler(false); LOG_ECMA(INFO) << "Aot has compile success once or escaped."; } -- Gitee