merge aot and jit white list

Change-Id: Icf5ae4b14017d60e7864db59333e020489e584f9
Signed-off-by: l00799772 <liyufeng29@huawei.com>
This commit is contained in:
l00799772 2024-06-07 16:36:24 +08:00
parent be1681d7ee
commit 50b75d4c86
18 changed files with 61 additions and 154 deletions

View File

@ -1322,38 +1322,12 @@ ohos_shared_library("libark_jsruntime_test") {
subsystem_name = "test"
}
ohos_prebuilt_etc("app_aot_enable_list") {
ohos_prebuilt_etc("app_aot_jit_enable_list") {
relative_install_dir = "ark"
if (js_runtime_feature_enable_list) {
source = "$js_root/ecmascript/ohos/app_aot_enable_list.conf"
source = "$js_root/ecmascript/ohos/app_aot_jit_enable_list.conf"
} else {
source = "$js_root/ecmascript/ohos/app_aot_enable_list_default.conf"
}
# Set the subsystem name
part_name = "ets_runtime"
subsystem_name = "arkcompiler"
}
ohos_prebuilt_etc("app_aot_disable_list") {
relative_install_dir = "ark"
if (js_runtime_feature_enable_list) {
source = "$js_root/ecmascript/ohos/app_aot_disable_list.conf"
} else {
source = "$js_root/ecmascript/ohos/app_aot_disable_list_default.conf"
}
# Set the subsystem name
part_name = "ets_runtime"
subsystem_name = "arkcompiler"
}
ohos_prebuilt_etc("app_jit_enable_list") {
relative_install_dir = "ark"
if (js_runtime_feature_enable_list) {
source = "$js_root/ecmascript/ohos/app_jit_enable_list.conf"
} else {
source = "$js_root/ecmascript/ohos/app_jit_enable_list_default.conf"
source = "$js_root/ecmascript/ohos/app_aot_jit_enable_list_default.conf"
}
# Set the subsystem name

View File

@ -55,9 +55,7 @@
},
"build": {
"sub_component": [
"//arkcompiler/ets_runtime:app_aot_enable_list",
"//arkcompiler/ets_runtime:app_aot_disable_list",
"//arkcompiler/ets_runtime:app_jit_enable_list",
"//arkcompiler/ets_runtime:app_aot_jit_enable_list",
"//arkcompiler/ets_runtime:ark_js_packages",
"//arkcompiler/ets_runtime:ark_js_host_linux_tools_packages",
"//arkcompiler/ets_runtime/etc:arkcompiler.para.dac",

View File

@ -210,7 +210,7 @@ int Main(const int argc, const char **argv)
cOptions.optBCRange_);
bool isEnableLiteCG = runtimeOptions.IsCompilerEnableLiteCG();
if (ohos::EnableAotListHelper::GetInstance()->IsEnableList(bundleName)) {
if (ohos::EnableAotJitListHelper::GetInstance()->IsEnableAot(bundleName)) {
isEnableLiteCG = true;
}
vm->GetJSOptions().SetCompilerEnableLiteCG(isEnableLiteCG);
@ -227,7 +227,8 @@ int Main(const int argc, const char **argv)
compilerStats.PrintCompilerStatsLog();
}
if (IsExistsPkgInfo(cPreprocessor)) {
ohos::EnableAotListHelper::GetInstance()->AddEnableListCount(cPreprocessor.GetMainPkgArgs()->GetPgoDir());
ohos::EnableAotJitListHelper::GetInstance()->AddEnableListCount(
cPreprocessor.GetMainPkgArgs()->GetPgoDir());
}
}

View File

@ -220,10 +220,10 @@ void EcmaVM::PostFork()
DaemonThread::GetInstance()->StartRunning();
heap_->EnableParallelGC();
std::string bundleName = PGOProfilerManager::GetInstance()->GetBundleName();
if (ohos::EnableAotListHelper::GetInstance()->IsEnableList(bundleName)) {
if (ohos::EnableAotJitListHelper::GetInstance()->IsEnableAot(bundleName)) {
options_.SetEnablePGOProfiler(true);
}
if (ohos::EnableAotListHelper::GetInstance()->IsAotCompileSuccessOnce()) {
if (ohos::EnableAotJitListHelper::GetInstance()->IsAotCompileSuccessOnce()) {
options_.SetEnablePGOProfiler(false);
LOG_ECMA(INFO) << "Aot has compile success once.";
}
@ -237,7 +237,7 @@ void EcmaVM::PostFork()
processStartRealtime_ = InitializeStartRealTime();
bool jitEscapeDisable = ohos::JitTools::GetJitEscapeDisable();
if (jitEscapeDisable || !JSNApi::IsJitEscape()) {
if (ohos::EnableAotListHelper::GetJitInstance()->IsEnableJit(bundleName)) {
if (ohos::EnableAotJitListHelper::GetInstance()->IsEnableJit(bundleName)) {
bool isEnableFastJit = options_.IsEnableJIT() && options_.GetEnableAsmInterpreter();
bool isEnableBaselineJit = options_.IsEnableBaselineJIT() && options_.GetEnableAsmInterpreter();
options_.SetEnableAPPJIT(true);

View File

@ -203,7 +203,7 @@ using JsDebuggerManager = ecmascript::tooling::JsDebuggerManager;
using FrameIterator = ecmascript::FrameIterator;
using Concurrent = ecmascript::Concurrent;
using CrashInfo = ecmascript::ohos::AotCrashInfo;
using EnableAotListHelper = ecmascript::ohos::EnableAotListHelper;
using EnableAotJitListHelper = ecmascript::ohos::EnableAotJitListHelper;
using PGOProfilerManager = ecmascript::pgo::PGOProfilerManager;
namespace {
@ -4467,7 +4467,7 @@ void JSNApi::LoadAotFile(EcmaVM *vm, const std::string &moduleName)
return;
}
if (!vm->GetJSOptions().WasAOTOutputFileSet() &&
!EnableAotListHelper::GetInstance()->IsEnableList(PGOProfilerManager::GetInstance()->GetBundleName())) {
!EnableAotJitListHelper::GetInstance()->IsEnableAot(PGOProfilerManager::GetInstance()->GetBundleName())) {
LOG_ECMA(INFO) << "Stop load AOT because it's not in enable list";
return;
}

View File

@ -1,3 +0,0 @@
# Apps in this configuration file can be compiled by aot compiler, disable list can be written as below:
# {bundleName}:{moduleName}
# {bundleName}

View File

@ -1,2 +0,0 @@
# Apps in this configuration file can be compiled by aot compiler, disable list can be written as below:
# {bundleName}

View File

@ -1,3 +0,0 @@
# Apps in this configuration file can be compiled by aot compiler, enable list can be written as below:
# {bundleName}:{moduleName}
# {bundleName}

View File

@ -1,2 +0,0 @@
# Apps in this configuration file can be compiled by aot compiler, enable list can be written as below:
# {bundleName}

View File

@ -0,0 +1,4 @@
# Apps in this configuration file can be compiled by aot or jit compiler, enable list can be written as below, first is enable aot, second is enable jit, third is enable both aot and jit:
# {bundleName}:aot
# {bundleName}:jit
# {bundleName}

View File

@ -0,0 +1,4 @@
# Apps in this configuration file can be compiled by aot or jit compiler, enable list can be written as below, first is enable aot, second is enable jit, third is enable both aot and jit:
# {bundleName}:aot
# {bundleName}:jit
# {bundleName}

View File

@ -1,4 +0,0 @@
# Apps in this configuration file can be compiled by jit compiler, enable list can be written as below:
# {bundleName}:{moduleName}
# {bundleName}
# com.huawei.hmos.calculator

View File

@ -1,2 +0,0 @@
# Apps in this configuration file can be compiled by jit compiler, enable list can be written as below:
# {bundleName}

View File

@ -16,7 +16,5 @@
#include "ecmascript/ohos/enable_aot_list_helper.h"
namespace panda::ecmascript::ohos {
const std::string EnableAotListHelper::ENABLE_LIST_NAME = "/etc/ark/app_aot_enable_list.conf";
const std::string EnableAotListHelper::DISABLE_LIST_NAME = "/etc/ark/app_aot_disable_list.conf";
const std::string EnableAotListHelper::JIT_ENABLE_LIST_NAME = "/etc/ark/app_aot_enable_list.conf";
const std::string EnableAotJitListHelper::ENABLE_LIST_NAME = "/etc/ark/app_aot_jit_enable_list.conf";
} // namespace panda::ecmascript::ohos

View File

@ -33,59 +33,33 @@
#include "parameters.h"
#endif
namespace panda::ecmascript::ohos {
class EnableAotListHelper {
class EnableAotJitListHelper {
constexpr static const char *const AOT_BUILD_COUNT_DISABLE = "ark.aot.build.count.disable";
public:
static std::shared_ptr<EnableAotListHelper> GetInstance()
static std::shared_ptr<EnableAotJitListHelper> GetInstance()
{
static auto helper = std::make_shared<EnableAotListHelper>(ENABLE_LIST_NAME, DISABLE_LIST_NAME);
static auto helper = std::make_shared<EnableAotJitListHelper>(ENABLE_LIST_NAME);
return helper;
}
static std::shared_ptr<EnableAotListHelper> GetJitInstance()
explicit EnableAotJitListHelper(const std::string &enableListName)
{
static auto helper = std::make_shared<EnableAotListHelper>(JIT_ENABLE_LIST_NAME, "");
return helper;
ReadEnableList(enableListName);
}
explicit EnableAotListHelper(const std::string &enableListName, const std::string &disableListName)
{
ReadEnableAotList(enableListName);
ReadEnableAotList(disableListName);
}
EnableAotJitListHelper() = default;
~EnableAotJitListHelper() = default;
EnableAotListHelper() = default;
~EnableAotListHelper() = default;
bool IsEnableList(const std::string &candidate)
bool IsEnableAot(const std::string &candidate)
{
return enableList_.find(candidate) != enableList_.end();
}
bool IsEnableList(const std::string &bundleName, const std::string &moduleName)
{
if (IsEnableList(bundleName)) {
return true;
}
return IsEnableList(bundleName + ":" + moduleName);
return (enableList_.find(candidate) != enableList_.end()) ||
(enableList_.find(candidate + ":aot") != enableList_.end());
}
bool IsEnableJit(const std::string &candidate)
{
return jitEnableList_.find(candidate) != jitEnableList_.end();
}
bool IsDisableBlackList(const std::string &candidate)
{
return disableList_.find(candidate) != disableList_.end();
}
bool IsDisableBlackList(const std::string &bundleName, const std::string &moduleName)
{
if (IsDisableBlackList(bundleName)) {
return true;
}
return IsDisableBlackList(bundleName + ":" + moduleName);
return (enableList_.find(candidate) != enableList_.end()) ||
(enableList_.find(candidate + ":jit") != enableList_.end());
}
void AddEnableListEntry(const std::string &entry)
@ -93,21 +67,9 @@ public:
enableList_.insert(entry);
}
void AddDisableListEntry(const std::string &entry)
{
disableList_.insert(entry);
}
void AddJitEnableListEntry(const std::string &entry)
{
jitEnableList_.insert(entry);
}
void Clear()
{
disableList_.clear();
enableList_.clear();
jitEnableList_.clear();
}
static bool GetAotBuildCountDisable()
@ -139,8 +101,8 @@ public:
}
private:
NO_COPY_SEMANTIC(EnableAotListHelper);
NO_MOVE_SEMANTIC(EnableAotListHelper);
NO_COPY_SEMANTIC(EnableAotJitListHelper);
NO_MOVE_SEMANTIC(EnableAotJitListHelper);
static void Trim(std::string &data)
{
@ -151,17 +113,17 @@ private:
data.erase(data.find_last_not_of(' ') + 1);
}
void ReadEnableAotList(const std::string &aotListName)
void ReadEnableList(const std::string &aotJitListName)
{
if (!panda::ecmascript::FileExist(aotListName.c_str())) {
LOG_ECMA(DEBUG) << "bundle enable list not exist and will pass by all. file: " << aotListName;
if (!panda::ecmascript::FileExist(aotJitListName.c_str())) {
LOG_ECMA(DEBUG) << "bundle enable list not exist and will pass by all. file: " << aotJitListName;
return;
}
std::ifstream inputFile(aotListName);
std::ifstream inputFile(aotJitListName);
if (!inputFile.is_open()) {
LOG_ECMA(ERROR) << "bundle enable list open failed! file: " << aotListName << ", errno: " << errno;
LOG_ECMA(ERROR) << "bundle enable list open failed! file: " << aotJitListName << ", errno: " << errno;
return;
}
@ -177,24 +139,11 @@ private:
if (appName.at(0) == '#') {
continue;
}
if (aotListName == ENABLE_LIST_NAME) {
AddEnableListEntry(appName);
}
if (aotListName == DISABLE_LIST_NAME) {
AddDisableListEntry(appName);
}
if (aotListName == JIT_ENABLE_LIST_NAME) {
AddJitEnableListEntry(appName);
}
AddEnableListEntry(appName);
}
}
std::set<std::string> enableList_ {};
std::set<std::string> disableList_ {};
std::set<std::string> jitEnableList_ {};
PUBLIC_API static const std::string ENABLE_LIST_NAME;
PUBLIC_API static const std::string DISABLE_LIST_NAME;
PUBLIC_API static const std::string JIT_ENABLE_LIST_NAME;
};
} // namespace panda::ecmascript::ohos
#endif // ECMASCRIPT_OHOS_ENABLE_AOT_LIST_HELPER_H

View File

@ -61,7 +61,7 @@ public:
void TearDown() override
{
vm_->GetJSThread()->ManagedCodeEnd();
ohos::EnableAotListHelper::GetInstance()->Clear();
ohos::EnableAotJitListHelper::GetInstance()->Clear();
JSNApi::DestroyJSVM(vm_);
vm_ = nullptr;
}
@ -95,41 +95,36 @@ protected:
HWTEST_F_L0(OhosTest, AotWhiteListTest)
{
const char *whiteListTestDir = "ohos-whiteList/";
const char *enableListName = "ohos-whiteList/app_aot_enable_list.conf";
const char *disableListName = "ohos-whiteList/app_aot_disable_list.conf";
const char *enableListName = "ohos-whiteList/app_aot_jit_enable_list.conf";
std::string bundleScope = "com.bundle.scope.test";
std::string moduleScope = "com.module.scope.test";
std::string bundleScope1 = "com.bundle.scope.test1";
std::string bundleScope2 = "com.bundle.scope.test2";
mkdir(whiteListTestDir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
std::ofstream file(disableListName);
std::ofstream file(enableListName);
file << bundleScope << std::endl;
file << moduleScope << ":entry" << std::endl;
file << " # " <<moduleScope << ":entryComment" << std::endl;
file << bundleScope1 << ":aot" << std::endl;
file << bundleScope2 << ":jit" << std::endl;
file.close();
auto helper = std::make_unique<ohos::EnableAotListHelper>(enableListName, disableListName);
ASSERT_FALSE(helper->IsDisableBlackList(bundleScope));
ASSERT_FALSE(helper->IsDisableBlackList(bundleScope, "entry"));
ASSERT_FALSE(helper->IsDisableBlackList(moduleScope, "entry"));
ASSERT_FALSE(helper->IsDisableBlackList(moduleScope, "entry1"));
ASSERT_FALSE(helper->IsDisableBlackList(moduleScope, "entryComment"));
unlink(disableListName);
auto helper = std::make_unique<ohos::EnableAotJitListHelper>(enableListName);
ASSERT_TRUE(helper->IsEnableAot(bundleScope));
ASSERT_TRUE(helper->IsEnableJit(bundleScope));
ASSERT_TRUE(helper->IsEnableAot(bundleScope1));
ASSERT_FALSE(helper->IsEnableJit(bundleScope1));
ASSERT_FALSE(helper->IsEnableAot(bundleScope2));
ASSERT_TRUE(helper->IsEnableJit(bundleScope2));
unlink(enableListName);
rmdir(whiteListTestDir);
}
HWTEST_F_L0(OhosTest, AotWhiteListPassBy)
{
const char *enableListName = "ohos-AotWhiteListPassBy/app_aot_enable_list.conf";
const char *disableListName = "ohos-AotWhiteListPassBy/app_aot_disable_list.conf";
const char *enableListName = "ohos-AotWhiteListPassBy/app_aot_jit_enable_list.conf";
std::string bundleScope = "com.bundle.scope.test";
std::string moduleScope = "com.module.scope.test";
auto helper = std::make_unique<ohos::EnableAotListHelper>(enableListName, disableListName);
ASSERT_FALSE(helper->IsDisableBlackList(bundleScope));
ASSERT_FALSE(helper->IsDisableBlackList(bundleScope, "entry"));
ASSERT_FALSE(helper->IsDisableBlackList(moduleScope, "entry"));
ASSERT_FALSE(helper->IsDisableBlackList(moduleScope, "entry1"));
ASSERT_FALSE(helper->IsDisableBlackList(moduleScope, "entryCommentNotExist"));
auto helper = std::make_unique<ohos::EnableAotJitListHelper>(enableListName);
ASSERT_FALSE(helper->IsEnableAot(bundleScope));
ASSERT_FALSE(helper->IsEnableJit(bundleScope));
}
HWTEST_F_L0(OhosTest, OhosPkgArgsParse)

View File

@ -39,7 +39,7 @@ declare_args() {
TARGET = "x86_64"
HOST_ARCH = 64
# If true app_aot_disable_list, app_aot_disable_list, app_jit_enable_list will be placed in /etc/ark
# If true app_aot_jit_enable_list will be placed in /etc/ark
# Default false.
js_runtime_feature_enable_list = false
}

View File

@ -319,7 +319,7 @@
panda::ecmascript::ohos::DecrypRemoveKey*;
panda::ecmascript::ohos::DecryptAssociateKey*;
panda::ecmascript::ohos::DecryptSetKey*;
panda::ecmascript::ohos::EnableAotListHelper*;
panda::ecmascript::ohos::EnableAotJitListHelper*;
panda::ecmascript::pgo::ApNameUtils::GetMergedApName*;
panda::ecmascript::pgo::ApNameUtils::GetOhosPkgApName*;
panda::ecmascript::pgo::ApNameUtils::GetRuntimeApName*;