From 3af3efa6dbcc61d751ec2b7efc6e439fba159616 Mon Sep 17 00:00:00 2001 From: dingding Date: Thu, 29 Aug 2024 05:07:09 +0800 Subject: [PATCH] Update AOT/JIT Escape Threshold 1. Update AOT/JIT escape threshold as 1. 2. Add whitelist judgment in AOT enable flag. Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAO1JH Signed-off-by: dingding Change-Id: I7e8d9db339fa17972810215243eef7f62d32dafd --- ecmascript/napi/jsnapi_expo.cpp | 18 ++++++++++++------ ecmascript/platform/aot_crash_info.h | 3 ++- ecmascript/platform/unix/aot_crash_info.cpp | 19 +++++++++++-------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/ecmascript/napi/jsnapi_expo.cpp b/ecmascript/napi/jsnapi_expo.cpp index 6c5b86494e..e63585b209 100644 --- a/ecmascript/napi/jsnapi_expo.cpp +++ b/ecmascript/napi/jsnapi_expo.cpp @@ -5098,11 +5098,6 @@ void JSNApi::PreFork(EcmaVM *vm) void JSNApi::PostFork(EcmaVM *vm, const RuntimeOption &option) { JSRuntimeOptions &jsOption = vm->GetJSOptions(); - LOG_ECMA(INFO) << "asmint: " << jsOption.GetEnableAsmInterpreter() - << ", aot: " << jsOption.GetEnableAOT() - << ", jit: " << option.GetEnableJIT() - << ", baseline jit: " << option.GetEnableBaselineJIT() - << ", bundle name: " << option.GetBundleName(); jsOption.SetEnablePGOProfiler(option.GetEnableProfile()); jsOption.SetEnableJIT(option.GetEnableJIT()); jsOption.SetEnableBaselineJIT(option.GetEnableBaselineJIT()); @@ -5113,11 +5108,22 @@ void JSNApi::PostFork(EcmaVM *vm, const RuntimeOption &option) runtimeOptions.SetLogLevel(Log::LevelToString(Log::ConvertFromRuntime(option.GetLogLevel()))); Log::Initialize(runtimeOptions); - if (jsOption.GetEnableAOT() && option.GetAnDir().size()) { + // 1. system switch 2. an file dir exits 3. whitelist 4. escape mechanism + bool enableAOT = jsOption.GetEnableAOT() && + !option.GetAnDir().empty() && + EnableAotJitListHelper::GetInstance()->IsEnableAot(option.GetBundleName()) && + !ecmascript::AotCrashInfo::IsAotEscaped(); + if (enableAOT) { ecmascript::AnFileDataManager::GetInstance()->SetDir(option.GetAnDir()); ecmascript::AnFileDataManager::GetInstance()->SetEnable(true); } + LOG_ECMA(INFO) << "asmint: " << jsOption.GetEnableAsmInterpreter() + << ", aot: " << enableAOT + << ", jit: " << option.GetEnableJIT() + << ", baseline jit: " << option.GetEnableBaselineJIT() + << ", bundle name: " << option.GetBundleName(); + vm->PostFork(); } diff --git a/ecmascript/platform/aot_crash_info.h b/ecmascript/platform/aot_crash_info.h index fa68d1e5d5..cc1b987a48 100644 --- a/ecmascript/platform/aot_crash_info.h +++ b/ecmascript/platform/aot_crash_info.h @@ -39,6 +39,7 @@ constexpr static int AOT_CRASH_COUNT = 1; constexpr static int OTHERS_CRASH_COUNT = 3; constexpr static int JIT_CRASH_COUNT = 1; constexpr static int JS_CRASH_COUNT = 3; +constexpr static int OPT_CODE_CRASH_THRESHOLD = 1; public: explicit AotCrashInfo() = default; virtual ~AotCrashInfo() = default; @@ -62,4 +63,4 @@ public: static int GetOthersCrashCount(); }; } // namespace panda::ecmascript -#endif // ECMASCRIPT_PLATFORM_AOT_RUNTIME_INFO_H \ No newline at end of file +#endif // ECMASCRIPT_PLATFORM_AOT_RUNTIME_INFO_H diff --git a/ecmascript/platform/unix/aot_crash_info.cpp b/ecmascript/platform/unix/aot_crash_info.cpp index 67f066df4c..c378182180 100644 --- a/ecmascript/platform/unix/aot_crash_info.cpp +++ b/ecmascript/platform/unix/aot_crash_info.cpp @@ -128,18 +128,21 @@ bool AotCrashInfo::IsAotEscaped(const std::string &pgoRealPath) return false; } auto escapeMap = ohos::AotRuntimeInfo::GetInstance().CollectCrashSum(pgoRealPath); - return escapeMap[ohos::RuntimeInfoType::AOT_CRASH] >= AotCrashInfo::GetAotCrashCount() || - escapeMap[ohos::RuntimeInfoType::OTHERS] >= AotCrashInfo::GetOthersCrashCount() || - escapeMap[ohos::RuntimeInfoType::JS] >= AotCrashInfo::GetJsCrashCount(); + int totalCrashes = escapeMap[ohos::RuntimeInfoType::AOT_CRASH] + + escapeMap[ohos::RuntimeInfoType::JIT] + + escapeMap[ohos::RuntimeInfoType::OTHERS] + + escapeMap[ohos::RuntimeInfoType::JS]; + return totalCrashes >= OPT_CODE_CRASH_THRESHOLD; } bool AotCrashInfo::IsJitEscape() { auto escapeMap = ohos::AotRuntimeInfo::GetInstance().CollectCrashSum(); - return escapeMap[ohos::RuntimeInfoType::JIT] >= AotCrashInfo::GetJitCrashCount() || - escapeMap[ohos::RuntimeInfoType::AOT_CRASH] >= AotCrashInfo::GetAotCrashCount() || - escapeMap[ohos::RuntimeInfoType::OTHERS] >= AotCrashInfo::GetOthersCrashCount() || - escapeMap[ohos::RuntimeInfoType::JS] >= AotCrashInfo::GetJsCrashCount(); + int totalCrashes = escapeMap[ohos::RuntimeInfoType::AOT_CRASH] + + escapeMap[ohos::RuntimeInfoType::JIT] + + escapeMap[ohos::RuntimeInfoType::OTHERS] + + escapeMap[ohos::RuntimeInfoType::JS]; + return totalCrashes >= OPT_CODE_CRASH_THRESHOLD; } bool AotCrashInfo::GetAotEscapeDisable() @@ -175,4 +178,4 @@ int AotCrashInfo::GetOthersCrashCount() return OTHERS_CRASH_COUNT; } -} // namespace panda::ecmascript \ No newline at end of file +} // namespace panda::ecmascript -- Gitee