diff --git a/compiler_service/include/aot_compiler_constants.h b/compiler_service/include/aot_compiler_constants.h index 98f3c21223d1676dd918b2b51d83f5896bb5e611..98b1953994d8e512938341a4ddb4d0357471dcc4 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 7b6a05d120262ed505861b488d5b3507ff382f9f..92e329cab1edb75e425c8f898156a8eeda025191 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 d79b7230c689edf6c880dc0d9c1e435335e81f41..cccd5c5ce622cb8d04468ba57e466a04d4bc2d5f 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) {