From 061aad01c14459fe508d87c6ae67cb2633d1cf20 Mon Sep 17 00:00:00 2001 From: herongpeng Date: Tue, 26 Aug 2025 16:17:51 +0800 Subject: [PATCH] Isolate the 1.2 code with a switch 0728 Isolate the 1.2 code with a switch 0728 Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICUVB0 Signed-off-by: herongpeng Change-Id: Ia772eed43aebda9b2ab8d4121f6e750daff2f939 --- .../include/aot_compiler_constants.h | 5 +++ compiler_service/include/aot_compiler_impl.h | 3 ++ compiler_service/src/aot_compiler_impl.cpp | 42 ++++++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/compiler_service/include/aot_compiler_constants.h b/compiler_service/include/aot_compiler_constants.h index 98f3c21223..98b1953994 100644 --- a/compiler_service/include/aot_compiler_constants.h +++ b/compiler_service/include/aot_compiler_constants.h @@ -40,6 +40,11 @@ const std::string IS_SYSTEM_COMPONENT = "isSysComp"; const std::string ARKTS_MODE = "moduleArkTSMode"; } // namespace ArgsIdx +#ifdef ENABLE_COMPILER_SERVICE_GET_PARAMETER +// Default closed, open on qiangji +const bool ARK_AOT_ENABLE_STATIC_COMPILER_DEFAULT_VALUE = true; +#endif + // UID and GID of system users constexpr uid_t OID_SYSTEM = 1000; diff --git a/compiler_service/include/aot_compiler_impl.h b/compiler_service/include/aot_compiler_impl.h index 7b6a05d120..92e329cab1 100644 --- a/compiler_service/include/aot_compiler_impl.h +++ b/compiler_service/include/aot_compiler_impl.h @@ -40,6 +40,9 @@ public: int32_t StopAotCompiler(); int32_t GetAOTVersion(std::string& sigData); int32_t NeedReCompile(const std::string& args, bool& sigData); + bool IsStaticCompiler(const std::unordered_map &argsMap); + bool IsEnableStaticCompiler(); + int32_t IsAllowAotCompiler(const std::unordered_map &argsMap); void HandlePowerDisconnected(); void HandleScreenOn(); void HandleThermalLevelChanged(const int32_t level); diff --git a/compiler_service/src/aot_compiler_impl.cpp b/compiler_service/src/aot_compiler_impl.cpp index d79b7230c6..cccd5c5ce6 100644 --- a/compiler_service/src/aot_compiler_impl.cpp +++ b/compiler_service/src/aot_compiler_impl.cpp @@ -155,8 +155,29 @@ bool AotCompilerImpl::VerifyCompilerModeAndPkgInfo(const std::unordered_map &argsMap, - std::vector &sigData) +bool AotCompilerImpl::IsStaticCompiler(const std::unordered_map &argsMap) +{ + if (argsMap.find(ArgsIdx::ARKTS_MODE) == argsMap.end()) { + return false; + } + std::string arktsMode = argsMap.at(ArgsIdx::ARKTS_MODE); + if (arktsMode == ARKTS_STATIC || arktsMode == ARKTS_HYBRID) { + return true; + } + return false; +} + +bool AotCompilerImpl::IsEnableStaticCompiler() +{ +#ifdef ENABLE_COMPILER_SERVICE_GET_PARAMETER + bool enable = OHOS::system::GetBoolParameter("ark.aot.enable_static_compiler", + ARK_AOT_ENABLE_STATIC_COMPILER_DEFAULT_VALUE); + return enable; +#endif + return false; +} + +int32_t AotCompilerImpl::IsAllowAotCompiler(const std::unordered_map &argsMap) { #ifdef CODE_SIGN_ENABLE if (!allowAotCompiler_) { @@ -167,6 +188,23 @@ int32_t AotCompilerImpl::EcmascriptAotCompiler(const std::unordered_map &argsMap, + std::vector &sigData) +{ +#ifdef CODE_SIGN_ENABLE + int32_t isAllowAotCompiler = IsAllowAotCompiler(argsMap); + if (isAllowAotCompiler != ERR_OK) { + return isAllowAotCompiler; + } argsHandler_ = std::make_unique(argsMap); if (argsHandler_->Handle(thermalLevel_) != ERR_OK) { -- Gitee