mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
Optimize AOT Compile Load
Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAF9NS Signed-off-by: wu_zhang_da <wuzhangda@huawei.com> Change-Id: Iba857b46ba82e32d051e653410936d1cf1bdac40
This commit is contained in:
parent
47e7002658
commit
bdff67d2eb
@ -29,6 +29,7 @@
|
||||
],
|
||||
"deps": {
|
||||
"components": [
|
||||
"ability_base",
|
||||
"faultloggerd",
|
||||
"init",
|
||||
"hitrace",
|
||||
@ -49,7 +50,6 @@
|
||||
"safwk",
|
||||
"samgr",
|
||||
"common_event_service",
|
||||
"power_manager",
|
||||
"ffrt",
|
||||
"cJSON"
|
||||
],
|
||||
|
@ -48,8 +48,10 @@ ohos_shared_library("libcompiler_service") {
|
||||
"src/aot_compiler_service.cpp",
|
||||
"src/power_disconnected_listener.cpp",
|
||||
"src/screen_status_listener.cpp",
|
||||
"src/thermal_mgr_listener.cpp",
|
||||
]
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libtokenid_sdk",
|
||||
"c_utils:utils",
|
||||
@ -61,7 +63,6 @@ ohos_shared_library("libcompiler_service") {
|
||||
"icu:shared_icui18n",
|
||||
"icu:shared_icuuc",
|
||||
"ipc:ipc_core",
|
||||
"power_manager:powermgr_client",
|
||||
"runtime_core:libarkfile_static",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
|
@ -61,6 +61,7 @@ std::unordered_set<std::string> AotArgsSet {
|
||||
"compiler-max-inline-bytecodes",
|
||||
"compiler-deopt-threshold",
|
||||
"compiler-device-state",
|
||||
"compiler-thermal-level",
|
||||
"compiler-stress-deopt",
|
||||
"compiler-opt-code-profiler",
|
||||
"compiler-opt-bc-range",
|
||||
|
@ -22,6 +22,7 @@
|
||||
namespace OHOS::ArkCompiler {
|
||||
enum {
|
||||
ERR_OK = 0,
|
||||
ERR_FAIL = -1,
|
||||
ERR_AOT_COMPILER_OFFSET = 10000,
|
||||
ERR_OK_NO_AOT_FILE = 10001,
|
||||
ERR_AOT_COMPILER_PARAM_FAILED = 10002,
|
||||
|
@ -25,6 +25,7 @@
|
||||
namespace OHOS::ArkCompiler {
|
||||
class AotCompilerImpl {
|
||||
public:
|
||||
static constexpr int32_t AOT_COMPILE_STOP_LEVEL = 2;
|
||||
static AotCompilerImpl &GetInstance();
|
||||
/**
|
||||
* @brief ecmascript aot_compiler
|
||||
@ -44,6 +45,8 @@ public:
|
||||
|
||||
void HandleScreenOn();
|
||||
|
||||
void HandleThermalLevelChanged(const int32_t level);
|
||||
|
||||
private:
|
||||
inline int32_t FindArgsIdxToInteger(const std::unordered_map<std::string, std::string> &argsMap,
|
||||
const std::string &keyName, int32_t &bundleID);
|
||||
@ -57,6 +60,7 @@ private:
|
||||
int32_t AOTLocalCodeSign(const std::string &fileName, const std::string &appSignature,
|
||||
std::vector<int16_t> &sigData);
|
||||
void InitState(const pid_t childPid);
|
||||
void AddExpandArgs(std::vector<std::string> &argVector);
|
||||
void ResetState();
|
||||
void PauseAotCompiler();
|
||||
void AllowAotCompiler();
|
||||
@ -83,6 +87,7 @@ private:
|
||||
pid_t childPid = -1;
|
||||
} state_;
|
||||
bool allowAotCompiler_ {true};
|
||||
int32_t thermalLevel_ {0};
|
||||
};
|
||||
} // namespace OHOS::ArkCompiler
|
||||
#endif // OHOS_ARKCOMPILER_AOTCOMPILER_IMPL_H
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include "power_disconnected_listener.h"
|
||||
#include "screen_status_listener.h"
|
||||
#include "thermal_mgr_listener.h"
|
||||
|
||||
namespace OHOS::ArkCompiler {
|
||||
enum class ServiceRunningState {
|
||||
@ -53,15 +54,19 @@ private:
|
||||
void DelayUnloadTask(const std::string &taskId, const int32_t delayTime);
|
||||
void RegisterPowerDisconnectedListener();
|
||||
void RegisterScreenStatusSubscriber();
|
||||
void RegisterThermalMgrListener();
|
||||
void UnRegisterPowerDisconnectedListener();
|
||||
void UnRegisterScreenStatusSubscriber();
|
||||
void UnRegisterThermalMgrListener();
|
||||
|
||||
std::shared_ptr<AppExecFwk::EventHandler> unLoadHandler_ { nullptr };
|
||||
ServiceRunningState state_;
|
||||
std::shared_ptr<PowerDisconnectedListener> powerDisconnectedListener_ { nullptr };
|
||||
std::shared_ptr<ScreenStatusSubscriber> screenStatusSubscriber_ { nullptr };
|
||||
std::shared_ptr<ThermalMgrListener> thermalMgrListener_ { nullptr };
|
||||
bool isPowerEventSubscribered_ { false };
|
||||
bool isScreenStatusSubscribered_ { false };
|
||||
bool isThermalLevelEventSubscribered_ { false };
|
||||
};
|
||||
} // namespace OHOS::ArkCompiler
|
||||
#endif // OHOS_ARKCOMPILER_AOTCOMPILER_SERVICE_H
|
31
compiler_service/include/thermal_mgr_listener.h
Normal file
31
compiler_service/include/thermal_mgr_listener.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ARKCOMPILER_THERMAL_MGR_LISTENER_H
|
||||
#define OHOS_ARKCOMPILER_THERMAL_MGR_LISTENER_H
|
||||
|
||||
#include "common_event_manager.h"
|
||||
#include "common_event_subscriber.h"
|
||||
#include "common_event_support.h"
|
||||
|
||||
namespace OHOS::ArkCompiler {
|
||||
class ThermalMgrListener : public EventFwk::CommonEventSubscriber {
|
||||
public:
|
||||
explicit ThermalMgrListener(const EventFwk::CommonEventSubscribeInfo &subscribeInfo);
|
||||
virtual ~ThermalMgrListener() = default;
|
||||
void OnReceiveEvent(const EventFwk::CommonEventData &data) override;
|
||||
};
|
||||
} // namespace OHOS::ArkCompiler
|
||||
#endif // OHOS_ARKCOMPILER_THERMAL_MGR_LISTENER_H
|
@ -6,6 +6,7 @@
|
||||
OHOS::ArkCompiler::AotCompilerClient::StopAotCompiler*;
|
||||
OHOS::ArkCompiler::PowerDisconnectedListener::PowerDisconnectedListener*;
|
||||
OHOS::ArkCompiler::ScreenStatusSubscriber::ScreenStatusSubscriber*;
|
||||
OHOS::ArkCompiler::ThermalMgrListener::ThermalMgrListener*;
|
||||
OHOS::ArkCompiler::AotCompilerClient::GetAOTVersion*;
|
||||
OHOS::ArkCompiler::AotCompilerClient::NeedReCompile*;
|
||||
};
|
||||
|
@ -85,6 +85,8 @@ int32_t AotCompilerImpl::PrepareArgs(const std::unordered_map<std::string, std::
|
||||
}
|
||||
hapArgs.argVector.clear();
|
||||
hapArgs.argVector.emplace_back(Cmds::ARK_AOT_COMPILER);
|
||||
// service process add aot compile args here
|
||||
AddExpandArgs(hapArgs.argVector);
|
||||
for (auto &argPair : argsMap) {
|
||||
if (AotArgsSet.find(argPair.first) != AotArgsSet.end()) {
|
||||
hapArgs.argVector.emplace_back(Symbols::PREFIX + argPair.first + Symbols::EQ + argPair.second);
|
||||
@ -143,6 +145,12 @@ void AotCompilerImpl::ExecuteInChildProcess(const std::vector<std::string> &aotV
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
void AotCompilerImpl::AddExpandArgs(std::vector<std::string> &argVector)
|
||||
{
|
||||
std::string thermalLevelArg = "--compiler-thermal-level=" + std::to_string(thermalLevel_);
|
||||
argVector.emplace_back(thermalLevelArg);
|
||||
}
|
||||
|
||||
int32_t AotCompilerImpl::PrintAOTCompilerResult(const int compilerStatus)
|
||||
{
|
||||
if (RetInfoOfCompiler.find(compilerStatus) == RetInfoOfCompiler.end()) {
|
||||
@ -279,6 +287,15 @@ int32_t AotCompilerImpl::StopAotCompiler()
|
||||
LOG_SA(INFO) << "begin to kill child process : " << state_.childPid;
|
||||
auto result = kill(state_.childPid, SIGKILL);
|
||||
int32_t ret = ERR_OK;
|
||||
if (access(hapArgs.fileName.c_str(), ERR_OK) != ERR_FAIL) {
|
||||
auto delRes = std::remove(hapArgs.fileName.c_str());
|
||||
if (delRes != ERR_OK) {
|
||||
LOG_SA(INFO) << "delete invalid aot file failed: " << delRes;
|
||||
ret = ERR_AOT_COMPILER_STOP_FAILED;
|
||||
} else {
|
||||
LOG_SA(INFO) << "delete invalid aot file success";
|
||||
}
|
||||
}
|
||||
if (result != 0) {
|
||||
LOG_SA(INFO) << "kill child process failed: " << result;
|
||||
ret = ERR_AOT_COMPILER_STOP_FAILED;
|
||||
@ -311,6 +328,18 @@ void AotCompilerImpl::HandleScreenOn()
|
||||
}).detach();
|
||||
}
|
||||
|
||||
void AotCompilerImpl::HandleThermalLevelChanged(const int32_t level)
|
||||
{
|
||||
LOG_SA(INFO) << "AotCompilerImpl::HandleThermalLevelChanged";
|
||||
thermalLevel_ = level;
|
||||
// thermal level >= 2, stop aot compile
|
||||
if (thermalLevel_ >= AOT_COMPILE_STOP_LEVEL) {
|
||||
PauseAotCompiler();
|
||||
} else {
|
||||
AllowAotCompiler();
|
||||
}
|
||||
}
|
||||
|
||||
void AotCompilerImpl::PauseAotCompiler()
|
||||
{
|
||||
LOG_SA(INFO) << "AotCompilerImpl::PauseAotCompiler";
|
||||
|
@ -70,6 +70,7 @@ void AotCompilerService::OnStart()
|
||||
state_ = ServiceRunningState::STATE_RUNNING;
|
||||
RegisterPowerDisconnectedListener();
|
||||
RegisterScreenStatusSubscriber();
|
||||
RegisterThermalMgrListener();
|
||||
}
|
||||
|
||||
bool AotCompilerService::Init()
|
||||
@ -118,6 +119,7 @@ void AotCompilerService::OnStop()
|
||||
state_ = ServiceRunningState::STATE_NOT_START;
|
||||
UnRegisterPowerDisconnectedListener();
|
||||
UnRegisterScreenStatusSubscriber();
|
||||
UnRegisterThermalMgrListener();
|
||||
}
|
||||
|
||||
int32_t AotCompilerService::AotCompiler(const std::unordered_map<std::string, std::string> &argsMap,
|
||||
@ -184,7 +186,7 @@ void AotCompilerService::RegisterScreenStatusSubscriber()
|
||||
EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
|
||||
screenStatusSubscriber_ = std::make_shared<ScreenStatusSubscriber>(subscribeInfo);
|
||||
if (!EventFwk::CommonEventManager::SubscribeCommonEvent(screenStatusSubscriber_)) {
|
||||
LOG_SA(INFO) << "AotCompilerService::RegisterScreenStatusSubscriber failed";
|
||||
LOG_SA(WARN) << "AotCompilerService::RegisterScreenStatusSubscriber failed";
|
||||
screenStatusSubscriber_ = nullptr;
|
||||
} else {
|
||||
LOG_SA(INFO) << "AotCompilerService::RegisterScreenStatusSubscriber success";
|
||||
@ -192,6 +194,22 @@ void AotCompilerService::RegisterScreenStatusSubscriber()
|
||||
}
|
||||
}
|
||||
|
||||
void AotCompilerService::RegisterThermalMgrListener()
|
||||
{
|
||||
LOG_SA(DEBUG) << "AotCompilerService::RegisterThermalMgrListener";
|
||||
EventFwk::MatchingSkills matchingSkills;
|
||||
matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_THERMAL_LEVEL_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
|
||||
thermalMgrListener_ = std::make_shared<ThermalMgrListener>(subscribeInfo);
|
||||
if (!EventFwk::CommonEventManager::SubscribeCommonEvent(thermalMgrListener_)) {
|
||||
LOG_SA(WARN) << "AotCompilerService::RegisterThermalMgrListener failed";
|
||||
thermalMgrListener_ = nullptr;
|
||||
} else {
|
||||
LOG_SA(INFO) << "AotCompilerService::RegisterThermalMgrListener success";
|
||||
isThermalLevelEventSubscribered_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void AotCompilerService::UnRegisterPowerDisconnectedListener()
|
||||
{
|
||||
LOG_SA(DEBUG) << "AotCompilerService::UnRegisterPowerDisconnectedListener";
|
||||
@ -213,10 +231,24 @@ void AotCompilerService::UnRegisterScreenStatusSubscriber()
|
||||
return;
|
||||
}
|
||||
if (!EventFwk::CommonEventManager::UnSubscribeCommonEvent(screenStatusSubscriber_)) {
|
||||
LOG_SA(INFO) << "AotCompilerService::UnRegisterScreenStatusSubscriber failed";
|
||||
LOG_SA(WARN) << "AotCompilerService::UnRegisterScreenStatusSubscriber failed";
|
||||
}
|
||||
screenStatusSubscriber_ = nullptr;
|
||||
isScreenStatusSubscribered_ = false;
|
||||
LOG_SA(INFO) << "AotCompilerService::UnRegisterScreenStatusSubscriber done";
|
||||
}
|
||||
|
||||
void AotCompilerService::UnRegisterThermalMgrListener()
|
||||
{
|
||||
LOG_SA(DEBUG) << "AotCompilerService::UnRegisterThermalMgrListener";
|
||||
if (!isThermalLevelEventSubscribered_) {
|
||||
return;
|
||||
}
|
||||
if (!EventFwk::CommonEventManager::UnSubscribeCommonEvent(thermalMgrListener_)) {
|
||||
LOG_SA(WARN) << "AotCompilerService::UnRegisterThermalMgrListener failed";
|
||||
}
|
||||
thermalMgrListener_ = nullptr;
|
||||
isThermalLevelEventSubscribered_ = false;
|
||||
LOG_SA(INFO) << "AotCompilerService::UnRegisterThermalMgrListener done";
|
||||
}
|
||||
} // namespace OHOS::ArkCompiler
|
35
compiler_service/src/thermal_mgr_listener.cpp
Normal file
35
compiler_service/src/thermal_mgr_listener.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "thermal_mgr_listener.h"
|
||||
|
||||
#include "aot_compiler_impl.h"
|
||||
#include "ecmascript/log_wrapper.h"
|
||||
|
||||
namespace OHOS::ArkCompiler {
|
||||
ThermalMgrListener::ThermalMgrListener(const EventFwk::CommonEventSubscribeInfo &subscribeInfo)
|
||||
: EventFwk::CommonEventSubscriber(subscribeInfo)
|
||||
{
|
||||
}
|
||||
|
||||
void ThermalMgrListener::OnReceiveEvent(const EventFwk::CommonEventData &data)
|
||||
{
|
||||
LOG_SA(INFO) << "ThermalMgrListener::OnReceiveEvent";
|
||||
std::string key = "0";
|
||||
int32_t invalidLevel = -1;
|
||||
int32_t level = data.GetWant().GetIntParam(key, invalidLevel);
|
||||
AotCompilerImpl::GetInstance().HandleThermalLevelChanged(level);
|
||||
}
|
||||
} // namespace OHOS::ArkCompiler
|
@ -33,5 +33,6 @@ aot_compiler_service_sources = [
|
||||
"${compiler_service_root}/src/aot_compiler_service.cpp",
|
||||
"${compiler_service_root}/src/power_disconnected_listener.cpp",
|
||||
"${compiler_service_root}/src/screen_status_listener.cpp",
|
||||
"${compiler_service_root}/src/thermal_mgr_listener.cpp",
|
||||
"${compiler_service_root}/test/mock/src/ecmascript/log_wrapper.cpp",
|
||||
]
|
||||
|
@ -38,7 +38,6 @@ ohos_fuzztest("AotCompilerArgsPrepareFuzzTest") {
|
||||
"icu:shared_icui18n",
|
||||
"icu:shared_icuuc",
|
||||
"ipc:ipc_core",
|
||||
"power_manager:powermgr_client",
|
||||
"runtime_core:libarkfile_static",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
|
@ -38,7 +38,6 @@ ohos_fuzztest("CompilerInterfaceStubFuzzTest") {
|
||||
"icu:shared_icui18n",
|
||||
"icu:shared_icuuc",
|
||||
"ipc:ipc_core",
|
||||
"power_manager:powermgr_client",
|
||||
"runtime_core:libarkfile_static",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
|
@ -41,7 +41,6 @@ ohos_unittest("AotCompilerClientUnitTest") {
|
||||
"icu:shared_icui18n",
|
||||
"icu:shared_icuuc",
|
||||
"ipc:ipc_core",
|
||||
"power_manager:powermgr_client",
|
||||
"runtime_core:libarkfile_static",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
|
@ -41,7 +41,6 @@ ohos_unittest("AotCompilerImplUnitTest") {
|
||||
"icu:shared_icui18n",
|
||||
"icu:shared_icuuc",
|
||||
"ipc:ipc_core",
|
||||
"power_manager:powermgr_client",
|
||||
"runtime_core:libarkfile_static",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
|
@ -206,4 +206,22 @@ HWTEST_F(AotCompilerImplTest, AotCompilerImplTest_008, TestSize.Level0)
|
||||
EXPECT_EQ(viewData2, 010101);
|
||||
EXPECT_STREQ(viewData3.c_str(), "010101");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AotCompilerImplTest_009
|
||||
* @tc.desc: AotCompilerImpl::HandleThermalLevelChanged()
|
||||
* @tc.type: Func
|
||||
* @tc.require: IR/AR/SR
|
||||
*/
|
||||
HWTEST_F(AotCompilerImplTest, AotCompilerImplTest_009, TestSize.Level0)
|
||||
{
|
||||
AotCompilerImpl &aotImpl = AotCompilerImpl::GetInstance();
|
||||
bool viewData1 = true;
|
||||
int32_t viewData2 = 010101;
|
||||
std::string viewData3 = "010101";
|
||||
aotImpl.HandleThermalLevelChanged(1);
|
||||
EXPECT_TRUE(viewData1);
|
||||
EXPECT_EQ(viewData2, 010101);
|
||||
EXPECT_STREQ(viewData3.c_str(), "010101");
|
||||
}
|
||||
} // namespace OHOS::ArkCompiler
|
@ -40,7 +40,6 @@ ohos_unittest("AotCompilerServiceUnitTest") {
|
||||
"icu:shared_icui18n",
|
||||
"icu:shared_icuuc",
|
||||
"ipc:ipc_core",
|
||||
"power_manager:powermgr_client",
|
||||
"runtime_core:libarkfile_static",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "ecmascript/platform/aot_crash_info.h"
|
||||
#include "ecmascript/platform/file.h"
|
||||
#include "ecmascript/platform/filesystem.h"
|
||||
#include "ecmascript/platform/os.h"
|
||||
|
||||
#include "ecmascript/compiler/aot_compiler_stats.h"
|
||||
|
||||
@ -94,13 +93,6 @@ int Main(const int argc, const char **argv)
|
||||
return ERR_HELP;
|
||||
}
|
||||
|
||||
if (runtimeOptions.WasSetDeviceState()) {
|
||||
bool deviceIsScreenOff = runtimeOptions.GetDeviceState();
|
||||
if (!deviceIsScreenOff) {
|
||||
BindSmallCpuCore();
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
// ark_aot_compiler running need disable asm interpreter to disable the loading of AOT files.
|
||||
runtimeOptions.SetEnableAsmInterpreter(false);
|
||||
|
@ -40,6 +40,7 @@ CompilationOptions::CompilationOptions(JSRuntimeOptions &runtimeOptions)
|
||||
logMethodsList_ = runtimeOptions.GetMethodsListForLog();
|
||||
compilerLogTime_ = runtimeOptions.IsEnableCompilerLogTime();
|
||||
deviceIsScreenOff_ = runtimeOptions.GetDeviceState();
|
||||
deviceThermalLevel_ = runtimeOptions.GetThermalLevel();
|
||||
maxAotMethodSize_ = runtimeOptions.GetMaxAotMethodSize();
|
||||
maxMethodsInModule_ = runtimeOptions.GetCompilerModuleMethods();
|
||||
hotnessThreshold_ = runtimeOptions.GetPGOHotnessThreshold();
|
||||
|
@ -65,6 +65,7 @@ struct CompilationOptions {
|
||||
size_t maxAotMethodSize_;
|
||||
size_t maxMethodsInModule_;
|
||||
uint32_t hotnessThreshold_;
|
||||
int32_t deviceThermalLevel_ {0};
|
||||
std::string profilerIn_;
|
||||
std::string optBCRange_;
|
||||
bool needMerge_ {false};
|
||||
|
@ -62,6 +62,7 @@ JitCompilationOptions::JitCompilationOptions(JSRuntimeOptions runtimeOptions)
|
||||
logMethodsList_ = runtimeOptions.GetMethodsListForLog();
|
||||
compilerLogTime_ = runtimeOptions.IsEnableCompilerLogTime();
|
||||
deviceIsScreenOff_ = runtimeOptions.GetDeviceState();
|
||||
deviceThermalLevel_ = runtimeOptions.GetThermalLevel();
|
||||
hotnessThreshold_ = runtimeOptions.GetPGOHotnessThreshold();
|
||||
profilerIn_ = std::string(runtimeOptions.GetPGOProfilerPath());
|
||||
isEnableArrayBoundsCheckElimination_ = runtimeOptions.IsEnableArrayBoundsCheckElimination();
|
||||
|
@ -47,6 +47,7 @@ struct JitCompilationOptions {
|
||||
bool compilerLogTime_;
|
||||
bool deviceIsScreenOff_;
|
||||
uint32_t hotnessThreshold_;
|
||||
int32_t deviceThermalLevel_;
|
||||
std::string profilerIn_;
|
||||
bool isEnableArrayBoundsCheckElimination_;
|
||||
bool isEnableTypeLowering_;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "ecmascript/compiler/aot_file/an_file_data_manager.h"
|
||||
#include "ecmascript/mem/mem_common.h"
|
||||
#include "ecmascript/compiler/ecma_opcode_des.h"
|
||||
#include "ecmascript/platform/os.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
const std::string PUBLIC_API COMMON_HELP_HEAD_MSG =
|
||||
@ -73,7 +74,6 @@ const std::string PUBLIC_API HELP_OPTION_MSG =
|
||||
"--compiler-trace-value-numbering: Enable tracing value numbering for aot runtime. Default: 'false'\n"
|
||||
"--compiler-max-inline-bytecodes Set max bytecodes count which aot function can be inlined. Default: '25'\n"
|
||||
"--compiler-deopt-threshold: Set max count which aot function can occur deoptimization. Default: '10'\n"
|
||||
"--compiler-device-state Compiler device state for aot. Check device screen state. Default: 'false'\n"
|
||||
"--compiler-stress-deopt: Enable stress deopt for aot compiler. Default: 'false'\n"
|
||||
"--compiler-opt-code-profiler: Enable opt code Bytecode Statistics for aot runtime. Default: 'false'\n"
|
||||
"--compiler-opt-bc-range: Range list for EcmaOpCode range Example '1:2,5:8'\n"
|
||||
@ -222,6 +222,7 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv)
|
||||
{"compiler-max-inline-bytecodes", required_argument, nullptr, OPTION_COMPILER_MAX_INLINE_BYTECODES},
|
||||
{"compiler-deopt-threshold", required_argument, nullptr, OPTION_COMPILER_DEOPT_THRESHOLD},
|
||||
{"compiler-device-state", required_argument, nullptr, OPTION_COMPILER_DEVICE_STATE},
|
||||
{"compiler-thermal-level", required_argument, nullptr, OPTION_COMPILER_THERMAL_LEVEL},
|
||||
{"compiler-stress-deopt", required_argument, nullptr, OPTION_COMPILER_STRESS_DEOPT},
|
||||
{"compiler-opt-code-profiler", required_argument, nullptr, OPTION_COMPILER_OPT_CODE_PROFILER},
|
||||
{"compiler-opt-bc-range", required_argument, nullptr, OPTION_COMPILER_OPT_BC_RANGE},
|
||||
@ -515,6 +516,14 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv)
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case OPTION_COMPILER_THERMAL_LEVEL:
|
||||
ret = ParseIntParam("compiler-thermal-level", &argInt);
|
||||
if (ret) {
|
||||
SetThermalLevel(argInt);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case OPTION_COMPILER_STRESS_DEOPT:
|
||||
ret = ParseBoolParam(&argBool);
|
||||
if (ret) {
|
||||
@ -1389,6 +1398,15 @@ void JSRuntimeOptions::ParseListArgParam(const std::string &option, arg_list_t *
|
||||
return;
|
||||
}
|
||||
|
||||
void JSRuntimeOptions::BindCPUCoreForTargetCompilation()
|
||||
{
|
||||
if (!deviceIsScreenOff_ || deviceThermalLevel_ > 0) {
|
||||
BindSmallCpuCore();
|
||||
} else {
|
||||
BindMidCpuCore();
|
||||
}
|
||||
}
|
||||
|
||||
void JSRuntimeOptions::SetOptionsForTargetCompilation()
|
||||
{
|
||||
if (IsTargetCompilerMode()) {
|
||||
@ -1406,6 +1424,7 @@ void JSRuntimeOptions::SetOptionsForTargetCompilation()
|
||||
SetEnableOptPGOType(false);
|
||||
SetPGOProfilerPath("");
|
||||
}
|
||||
BindCPUCoreForTargetCompilation();
|
||||
}
|
||||
if (IsCompilerPipelineHostAOT()) {
|
||||
SetTargetTriple("aarch64-unknown-linux-gnu");
|
||||
|
@ -126,7 +126,7 @@ enum CommandValues {
|
||||
OPTION_COMPILER_OPT_TYPE_LOWERING,
|
||||
OPTION_COMPILER_OPT_EARLY_ELIMINATION,
|
||||
OPTION_COMPILER_OPT_LATER_ELIMINATION,
|
||||
OPTION_COMPILER_OPT_STRING,
|
||||
OPTION_COMPILER_THERMAL_LEVEL,
|
||||
OPTION_COMPILER_OPT_VALUE_NUMBERING,
|
||||
OPTION_COMPILER_OPT_INLINING,
|
||||
OPTION_COMPILER_OPT_PGOTYPE,
|
||||
@ -205,6 +205,7 @@ enum CommandValues {
|
||||
OPTION_PGO_TRACE,
|
||||
OPTION_COMPILER_PGO_FORCE_DUMP,
|
||||
OPTION_COMPILER_ENABLE_CONCURRENT,
|
||||
OPTION_COMPILER_OPT_STRING,
|
||||
OPTION_OPEN_ARK_TOOLS,
|
||||
};
|
||||
static_assert(OPTION_SPLIT_ONE == 64); // add new option at the bottom, DO NOT modify this value
|
||||
@ -1404,6 +1405,21 @@ public:
|
||||
return WasOptionSet(OPTION_COMPILER_DEVICE_STATE);
|
||||
}
|
||||
|
||||
void SetThermalLevel(int32_t level)
|
||||
{
|
||||
deviceThermalLevel_ = level;
|
||||
}
|
||||
|
||||
int32_t GetThermalLevel() const
|
||||
{
|
||||
return deviceThermalLevel_;
|
||||
}
|
||||
|
||||
bool WasSetThermalLevel() const
|
||||
{
|
||||
return WasOptionSet(OPTION_COMPILER_THERMAL_LEVEL);
|
||||
}
|
||||
|
||||
void SetOptCodeProfiler(bool value)
|
||||
{
|
||||
optCodeProfiler_ = value;
|
||||
@ -1586,6 +1602,8 @@ public:
|
||||
|
||||
void SetOptionsForTargetCompilation();
|
||||
|
||||
void BindCPUCoreForTargetCompilation();
|
||||
|
||||
void SetCompilerPipelineHostAOT(bool value)
|
||||
{
|
||||
compilerPipelineHostAOT_ = value;
|
||||
@ -1942,6 +1960,7 @@ private:
|
||||
bool enableEdenGC_ {false};
|
||||
bool forceFullGc_ {true};
|
||||
uint32_t forceSharedGc_ {1};
|
||||
int32_t deviceThermalLevel_ {0};
|
||||
int arkProperties_ = GetDefaultProperties();
|
||||
std::string arkBundleName_ = {""};
|
||||
size_t heapSize_ = {0};
|
||||
|
@ -27,6 +27,7 @@ size_t PhysicalSize();
|
||||
int PrctlSetVMA(const void *p, const size_t size, const char *tag);
|
||||
long PtracePeektext(int pid, uintptr_t addr);
|
||||
PUBLIC_API void BindSmallCpuCore();
|
||||
PUBLIC_API void BindMidCpuCore();
|
||||
void PUBLIC_API *PageMapExecFortSpace(void *addr, size_t size, int prot);
|
||||
} // namespace panda::ecmascript
|
||||
#endif // ECMASCRIPT_PLATFORM_OS_H
|
||||
|
@ -76,6 +76,21 @@ void BindSmallCpuCore()
|
||||
}
|
||||
}
|
||||
|
||||
void BindMidCpuCore()
|
||||
{
|
||||
cpu_set_t cpuset;
|
||||
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(4, &cpuset); // 4: bind this process to cpu4
|
||||
CPU_SET(5, &cpuset); // 5: bind this process to cpu5
|
||||
CPU_SET(6, &cpuset); // 6: bind this process to cpu6
|
||||
CPU_SET(7, &cpuset); // 7: bind this process to cpu7
|
||||
|
||||
if (sched_setaffinity(0, sizeof(cpuset), &cpuset) == -1) {
|
||||
LOG_ECMA(ERROR) << "Set CPU affinity failed";
|
||||
}
|
||||
}
|
||||
|
||||
void *PageMapExecFortSpace(void *addr, size_t size, int prot)
|
||||
{
|
||||
void *res = mmap(addr, size, prot, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED | MAP_EXECUTABLE, -1, 0);
|
||||
|
@ -62,6 +62,11 @@ void BindSmallCpuCore()
|
||||
LOG_ECMA(INFO) << "Bind Small Core in macos not support";
|
||||
}
|
||||
|
||||
void BindMidCpuCore()
|
||||
{
|
||||
LOG_ECMA(INFO) << "Bind Mid Core in macos not support";
|
||||
}
|
||||
|
||||
void *PageMapExecFortSpace(void *addr, [[maybe_unused]] size_t size, [[maybe_unused]] int prot)
|
||||
{
|
||||
// basically no op
|
||||
|
@ -58,6 +58,11 @@ void BindSmallCpuCore()
|
||||
LOG_ECMA(INFO) << "Bind Small Core in windows not support";
|
||||
}
|
||||
|
||||
void BindMidCpuCore()
|
||||
{
|
||||
LOG_ECMA(INFO) << "Bind Mid Core in windows not support";
|
||||
}
|
||||
|
||||
void *PageMapExecFortSpace(void *addr, [[maybe_unused]] size_t size, [[maybe_unused]] int prot)
|
||||
{
|
||||
// basically no op
|
||||
|
@ -130,6 +130,7 @@
|
||||
panda::ecmascript::BigInt::DoubleToBigInt*;
|
||||
panda::ecmascript::BigInt::Int32ToBigInt*;
|
||||
panda::ecmascript::BindSmallCpuCore*;
|
||||
panda::ecmascript::BindMidCpuCore*;
|
||||
panda::ecmascript::ClassHelper::MatchFieldType*;
|
||||
panda::ecmascript::ConstantPool::GetMethodFromCache*;
|
||||
panda::ecmascript::ConstantPool::GetStringFromCacheForJit*;
|
||||
|
Loading…
Reference in New Issue
Block a user