mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-24 02:30:03 +00:00
add aotfilemanger from vm to context
Signed-off-by: liu-qiang12 <liuqiang254@huawei.com> https: //gitee.com/openharmony/arkcompiler_ets_runtime/issues/I6UHGV Change-Id: Idfabd557b8ad5cb79c538f15224d22a8ac800e0f
This commit is contained in:
parent
4443a8a95d
commit
09ee91dec2
8
BUILD.gn
8
BUILD.gn
@ -205,11 +205,11 @@ group("ark_runtime_host_unittest") {
|
||||
# ts aot test and asm test
|
||||
if (!run_with_asan) {
|
||||
deps += [
|
||||
#"$js_root/test/aottest:ark_aot_test",
|
||||
"$js_root/test/aottest:ark_aot_test",
|
||||
#"$js_root/test/moduletest:ark_asm_single_step_test",
|
||||
#"$js_root/test/deopttest:ark_deopt_test",
|
||||
#"$js_root/test/moduletest:ark_asm_test",
|
||||
#"$js_root/test/typeinfer:ark_typeinfer_test",
|
||||
"$js_root/test/deopttest:ark_deopt_test",
|
||||
"$js_root/test/moduletest:ark_asm_test",
|
||||
"$js_root/test/typeinfer:ark_typeinfer_test",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ JSTaggedValue BuiltinsGlobal::StartRuntimeStat(EcmaRuntimeCallInfo *msg)
|
||||
BUILTINS_API_TRACE(thread, Global, StartRuntimeStat);
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
// start vm runtime stat statistic
|
||||
thread->GetEcmaVM()->SetRuntimeStatEnable(true);
|
||||
thread->GetCurrentEcmaContext()->SetRuntimeStatEnable(true);
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ JSTaggedValue BuiltinsGlobal::StopRuntimeStat(EcmaRuntimeCallInfo *msg)
|
||||
BUILTINS_API_TRACE(thread, Global, StopRuntimeStat);
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
// start vm runtime stat statistic
|
||||
thread->GetEcmaVM()->SetRuntimeStatEnable(false);
|
||||
thread->GetCurrentEcmaContext()->SetRuntimeStatEnable(false);
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
#endif
|
||||
|
@ -399,7 +399,7 @@ void CpuProfiler::GetStackSignalHandler(int signal, [[maybe_unused]] siginfo_t *
|
||||
// If the attempt fails, the callback will be terminated directly to avoid the reentrancy deadlock,
|
||||
// and a sampling will be abandoned. Failures are rare, so the impact on the overall sampling results
|
||||
// is very limited.
|
||||
if (!thread->GetEcmaVM()->GetAOTFileManager()->TryReadLock()) {
|
||||
if (!thread->GetCurrentEcmaContext()->GetAOTFileManager()->TryReadLock()) {
|
||||
if (profiler->generator_->SemPost(0) != 0) {
|
||||
LOG_ECMA(ERROR) << "sem_[0] post failed";
|
||||
}
|
||||
@ -502,7 +502,7 @@ uint64_t CpuProfiler::GetPcFromContext(void *context)
|
||||
|
||||
bool CpuProfiler::IsAddrAtStubOrAot(uint64_t pc) const
|
||||
{
|
||||
AOTFileManager *loader = vm_->GetAOTFileManager();
|
||||
AOTFileManager *loader = vm_->GetJSThread()->GetCurrentEcmaContext()->GetAOTFileManager();
|
||||
return loader->InsideStub(pc) || loader->InsideAOT(pc);
|
||||
}
|
||||
|
||||
|
@ -138,14 +138,14 @@ void EcmaRuntimeStat::PrintAllStats() const
|
||||
EcmaRuntimeStatScope::EcmaRuntimeStatScope(EcmaVM *vm) : vm_(vm)
|
||||
{
|
||||
if (vm_->GetJSOptions().IsEnableRuntimeStat()) {
|
||||
vm_->SetRuntimeStatEnable(true);
|
||||
vm_->GetJSThread()->GetCurrentEcmaContext()->SetRuntimeStatEnable(true);
|
||||
}
|
||||
}
|
||||
|
||||
EcmaRuntimeStatScope::~EcmaRuntimeStatScope()
|
||||
{
|
||||
if (vm_->GetJSOptions().IsEnableRuntimeStat()) {
|
||||
vm_->SetRuntimeStatEnable(false);
|
||||
vm_->GetJSThread()->GetCurrentEcmaContext()->SetRuntimeStatEnable(false);
|
||||
}
|
||||
vm_ = nullptr;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "ecmascript/jobs/micro_job_queue.h"
|
||||
#include "ecmascript/jspandafile/js_pandafile.h"
|
||||
#include "ecmascript/jspandafile/js_pandafile_manager.h"
|
||||
#include "ecmascript/compiler/aot_file/an_file_data_manager.h"
|
||||
#include "ecmascript/jspandafile/program_object.h"
|
||||
#include "ecmascript/js_thread.h"
|
||||
#include "ecmascript/object_factory.h"
|
||||
@ -106,12 +107,66 @@ bool EcmaContext::Initialize()
|
||||
moduleManager_ = new ModuleManager(vm_);
|
||||
tsManager_ = new TSManager(vm_);
|
||||
optCodeProfiler_ = new OptCodeProfiler();
|
||||
aotFileManager_ = new AOTFileManager(vm_);
|
||||
return true;
|
||||
}
|
||||
|
||||
void EcmaContext::InitializeEcmaScriptRunStat()
|
||||
{
|
||||
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
|
||||
static const char *runtimeCallerNames[] = {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define INTERPRETER_CALLER_NAME(name) "Interpreter::" #name,
|
||||
INTERPRETER_CALLER_LIST(INTERPRETER_CALLER_NAME) // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
|
||||
#undef INTERPRETER_CALLER_NAME
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define BUILTINS_API_NAME(class, name) "BuiltinsApi::" #class "_" #name,
|
||||
BUILTINS_API_LIST(BUILTINS_API_NAME)
|
||||
#undef BUILTINS_API_NAME
|
||||
#define ABSTRACT_OPERATION_NAME(class, name) "AbstractOperation::" #class "_" #name,
|
||||
ABSTRACT_OPERATION_LIST(ABSTRACT_OPERATION_NAME)
|
||||
#undef ABSTRACT_OPERATION_NAME
|
||||
#define MEM_ALLOCATE_AND_GC_NAME(name) "Memory::" #name,
|
||||
MEM_ALLOCATE_AND_GC_LIST(MEM_ALLOCATE_AND_GC_NAME)
|
||||
#undef MEM_ALLOCATE_AND_GC_NAME
|
||||
#define DEF_RUNTIME_ID(name) "Runtime::" #name,
|
||||
RUNTIME_STUB_WITH_GC_LIST(DEF_RUNTIME_ID)
|
||||
#undef DEF_RUNTIME_ID
|
||||
};
|
||||
static_assert(sizeof(runtimeCallerNames) == sizeof(const char *) * ecmascript::RUNTIME_CALLER_NUMBER,
|
||||
"Invalid runtime caller number");
|
||||
runtimeStat_ = chunk_.New<EcmaRuntimeStat>(runtimeCallerNames, ecmascript::RUNTIME_CALLER_NUMBER);
|
||||
if (UNLIKELY(runtimeStat_ == nullptr)) {
|
||||
LOG_FULL(FATAL) << "alloc runtimeStat_ failed";
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
void EcmaContext::SetRuntimeStatEnable(bool flag)
|
||||
{
|
||||
static uint64_t start = 0;
|
||||
if (flag) {
|
||||
start = PandaRuntimeTimer::Now();
|
||||
if (runtimeStat_ == nullptr) {
|
||||
InitializeEcmaScriptRunStat();
|
||||
}
|
||||
} else {
|
||||
LOG_ECMA(INFO) << "Runtime State duration:" << PandaRuntimeTimer::Now() - start << "(ns)";
|
||||
if (runtimeStat_ != nullptr && runtimeStat_->IsRuntimeStatEnabled()) {
|
||||
runtimeStat_->Print();
|
||||
runtimeStat_->ResetAllCount();
|
||||
}
|
||||
}
|
||||
if (runtimeStat_ != nullptr) {
|
||||
runtimeStat_->SetRuntimeStatEnabled(flag);
|
||||
}
|
||||
}
|
||||
|
||||
EcmaContext::~EcmaContext()
|
||||
{
|
||||
LOG_ECMA(INFO) << "~EcmaContext";
|
||||
if (runtimeStat_ != nullptr && runtimeStat_->IsRuntimeStatEnabled()) {
|
||||
runtimeStat_->Print();
|
||||
}
|
||||
ClearBufferData();
|
||||
// clear c_address: c++ pointer delete
|
||||
if (!vm_->IsBundlePack()) {
|
||||
@ -123,6 +178,10 @@ EcmaContext::~EcmaContext()
|
||||
// clear icu cache
|
||||
ClearIcuCache();
|
||||
|
||||
if (runtimeStat_ != nullptr) {
|
||||
vm_->GetChunk()->Delete(runtimeStat_);
|
||||
runtimeStat_ = nullptr;
|
||||
}
|
||||
if (optCodeProfiler_ != nullptr) {
|
||||
delete optCodeProfiler_;
|
||||
optCodeProfiler_ = nullptr;
|
||||
@ -142,9 +201,33 @@ EcmaContext::~EcmaContext()
|
||||
if (regExpParserCache_ != nullptr) {
|
||||
delete regExpParserCache_;
|
||||
regExpParserCache_ = nullptr;
|
||||
}
|
||||
if (aotFileManager_ != nullptr) {
|
||||
delete aotFileManager_;
|
||||
aotFileManager_ = nullptr;
|
||||
}
|
||||
}
|
||||
JSTaggedValue EcmaContext::InvokeEcmaAotEntrypoint(JSHandle<JSFunction> mainFunc, JSHandle<JSTaggedValue> &thisArg,
|
||||
const JSPandaFile *jsPandaFile, std::string_view entryPoint)
|
||||
{
|
||||
aotFileManager_->SetAOTMainFuncEntry(mainFunc, jsPandaFile, entryPoint);
|
||||
return JSFunction::InvokeOptimizedEntrypoint(thread_, mainFunc, thisArg, entryPoint);
|
||||
}
|
||||
|
||||
JSTaggedValue EcmaContext::ExecuteAot(size_t actualNumArgs, JSTaggedType *args, const JSTaggedType *prevFp,
|
||||
OptimizedEntryFrame::CallType callType)
|
||||
{
|
||||
INTERPRETER_TRACE(thread_, ExecuteAot);
|
||||
auto entry = thread_->GetRTInterface(kungfu::RuntimeStubCSigns::ID_JSFunctionEntry);
|
||||
// do not modify this log to INFO, this will call many times
|
||||
LOG_ECMA(DEBUG) << "start to execute aot entry: " << (void*)entry;
|
||||
auto res = reinterpret_cast<JSFunctionEntryType>(entry)(thread_->GetGlueAddr(),
|
||||
actualNumArgs,
|
||||
args,
|
||||
reinterpret_cast<uintptr_t>(prevFp),
|
||||
needPushUndefined);
|
||||
return res;
|
||||
}
|
||||
Expected<JSTaggedValue, bool> EcmaContext::InvokeEcmaEntrypoint(const JSPandaFile *jsPandaFile,
|
||||
std::string_view entryPoint, bool excuteFromJob)
|
||||
{
|
||||
@ -395,10 +478,39 @@ void EcmaContext::Iterate(const RootVisitor &v, [[maybe_unused]] const RootRange
|
||||
v(Root::ROOT_VM, ObjectSlot(reinterpret_cast<uintptr_t>(µJobQueue_)));
|
||||
moduleManager_->Iterate(v);
|
||||
tsManager_->Iterate(v);
|
||||
aotFileManager_->Iterate(v);
|
||||
}
|
||||
|
||||
void EcmaContext::SetupRegExpResultCache()
|
||||
{
|
||||
regexpCache_ = builtins::RegExpExecResultCache::CreateCacheTable(thread_);
|
||||
}
|
||||
void EcmaContext::LoadStubFile()
|
||||
{
|
||||
std::string stubFile = vm_->GetJSOptions().GetStubFile();
|
||||
aotFileManager_->LoadStubFile(stubFile);
|
||||
}
|
||||
|
||||
bool EcmaContext::LoadAOTFiles(const std::string& aotFileName)
|
||||
{
|
||||
std::string anFile = aotFileName + AOTFileManager::FILE_EXTENSION_AN;
|
||||
if (!aotFileManager_->LoadAnFile(anFile)) {
|
||||
LOG_ECMA(ERROR) << "Load " << anFile << " failed. Destroy aot data and rollback to interpreter";
|
||||
ecmascript::AnFileDataManager::GetInstance()->SafeDestroyAnData(anFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string aiFile = aotFileName + AOTFileManager::FILE_EXTENSION_AI;
|
||||
if (!aotFileManager_->LoadAiFile(aiFile)) {
|
||||
LOG_ECMA(ERROR) << "Load " << aiFile << " failed. Destroy aot data and rollback to interpreter";
|
||||
ecmascript::AnFileDataManager::GetInstance()->SafeDestroyAnData(anFile);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void EcmaContext::DumpAOTInfo() const
|
||||
{
|
||||
aotFileManager_->DumpAOTInfo();
|
||||
}
|
||||
} // namespace panda::ecmascript
|
||||
|
@ -20,8 +20,9 @@
|
||||
#include "ecmascript/base/config.h"
|
||||
#include "ecmascript/common.h"
|
||||
#include "ecmascript/frames.h"
|
||||
#include "ecmascript/js_tagged_value.h"
|
||||
#include "ecmascript/js_handle.h"
|
||||
// #include "ecmascript/compiler/aot_file/aot_file_manager.h"
|
||||
#include "ecmascript/js_tagged_value.h"
|
||||
#include "ecmascript/dfx/vmstat/opt_code_profiler.h"
|
||||
#include "ecmascript/mem/c_containers.h"
|
||||
#include "ecmascript/mem/visitor.h"
|
||||
@ -38,6 +39,7 @@ class File;
|
||||
namespace ecmascript {
|
||||
class GlobalEnv;
|
||||
class ObjectFactory;
|
||||
class EcmaRuntimeStat;
|
||||
class RegExpParserCache;
|
||||
class JSPandaFileManager;
|
||||
class JSPandaFile;
|
||||
@ -45,6 +47,7 @@ class EcmaStringTable;
|
||||
class ConstantPool;
|
||||
class JSPromise;
|
||||
class RegExpExecResultCache;
|
||||
class EcmaHandleScope;
|
||||
enum class PromiseRejectionEvent : uint8_t;
|
||||
|
||||
template<typename T>
|
||||
@ -209,7 +212,8 @@ public:
|
||||
void CreateAllConstpool(const JSPandaFile *jsPandaFile);
|
||||
|
||||
void HandleUncaughtException(JSTaggedValue exception);
|
||||
|
||||
void ProcessNativeDelete(const WeakRootVisitor &visitor);
|
||||
void ProcessReferences(const WeakRootVisitor &visitor);
|
||||
JSHandle<GlobalEnv> GetGlobalEnv() const;
|
||||
JSHandle<job::MicroJobQueue> GetMicroJobQueue() const;
|
||||
|
||||
@ -257,12 +261,104 @@ public:
|
||||
iter->second = EcmaContext::IcuFormatter{};
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
private:
|
||||
}
|
||||
AOTFileManager *GetAOTFileManager() const
|
||||
{
|
||||
return aotFileManager_;
|
||||
}
|
||||
EcmaRuntimeStat *GetRuntimeStat() const
|
||||
{
|
||||
return runtimeStat_;
|
||||
}
|
||||
void SetRuntimeStatEnable(bool flag);
|
||||
void InitializeEcmaScriptRunStat();
|
||||
void DumpAOTInfo() const DUMP_API_ATTR;
|
||||
|
||||
JSTaggedValue ExecuteAot(size_t actualNumArgs, JSTaggedType *args, const JSTaggedType *prevFp,
|
||||
OptimizedEntryFrame::CallType callType);
|
||||
void LoadStubFile();
|
||||
|
||||
JSTaggedType *GetHandleScopeStorageNext() const
|
||||
{
|
||||
return handleScopeStorageNext_;
|
||||
}
|
||||
|
||||
void SetHandleScopeStorageNext(JSTaggedType *value)
|
||||
{
|
||||
handleScopeStorageNext_ = value;
|
||||
}
|
||||
|
||||
JSTaggedType *GetHandleScopeStorageEnd() const
|
||||
{
|
||||
return handleScopeStorageEnd_;
|
||||
}
|
||||
|
||||
void SetHandleScopeStorageEnd(JSTaggedType *value)
|
||||
{
|
||||
handleScopeStorageEnd_ = value;
|
||||
}
|
||||
|
||||
int GetCurrentHandleStorageIndex() const
|
||||
{
|
||||
return currentHandleStorageIndex_;
|
||||
}
|
||||
|
||||
void HandleScopeCountAdd()
|
||||
{
|
||||
handleScopeCount_++;
|
||||
}
|
||||
|
||||
void HandleScopeCountDec()
|
||||
{
|
||||
handleScopeCount_--;
|
||||
}
|
||||
|
||||
void SetLastHandleScope(EcmaHandleScope *scope)
|
||||
{
|
||||
lastHandleScope_ = scope;
|
||||
}
|
||||
|
||||
EcmaHandleScope *GetLastHandleScope() const
|
||||
{
|
||||
return lastHandleScope_;
|
||||
}
|
||||
size_t IterateHandle(const RootRangeVisitor &rangeVisitor);
|
||||
uintptr_t *ExpandHandleStorage();
|
||||
void ShrinkHandleStorage(int prevIndex);
|
||||
JSTaggedType *GetCurrentFrame() const
|
||||
{
|
||||
return currentFrame_;
|
||||
}
|
||||
|
||||
JSTaggedType *GetLeaveFrame() const
|
||||
{
|
||||
return leaveFrame_;
|
||||
}
|
||||
|
||||
JSTaggedType *GetLastFp() const
|
||||
{
|
||||
return lastFp_;
|
||||
}
|
||||
|
||||
void SetFramePointers(JSTaggedType *currentFrame, JSTaggedType *leaveFrame, JSTaggedType *lastFp)
|
||||
{
|
||||
currentFrame_ = currentFrame;
|
||||
leaveFrame_ = leaveFrame;
|
||||
lastFp_ = lastFp;
|
||||
}
|
||||
|
||||
PropertiesCache *GetPropertiesCache() const
|
||||
{
|
||||
return propertiesCache_;
|
||||
}
|
||||
|
||||
void ClearBufferData();
|
||||
private:
|
||||
JSTaggedValue InvokeEcmaAotEntrypoint(JSHandle<JSFunction> mainFunc, JSHandle<JSTaggedValue> &thisArg,
|
||||
const JSPandaFile *jsPandaFile, std::string_view entryPoint);
|
||||
Expected<JSTaggedValue, bool> InvokeEcmaEntrypoint(const JSPandaFile *jsPandaFile, std::string_view entryPoint,
|
||||
bool excuteFromJob = false);
|
||||
|
||||
bool LoadAOTFiles(const std::string& aotFileName);
|
||||
NO_MOVE_SEMANTIC(EcmaContext);
|
||||
NO_COPY_SEMANTIC(EcmaContext);
|
||||
|
||||
@ -279,12 +375,13 @@ private:
|
||||
|
||||
JSTaggedValue microJobQueue_ {JSTaggedValue::Hole()};
|
||||
|
||||
EcmaRuntimeStat *runtimeStat_ {nullptr};
|
||||
// VM execution states.
|
||||
RegExpParserCache *regExpParserCache_ {nullptr};
|
||||
JSTaggedValue regexpCache_ {JSTaggedValue::Hole()};
|
||||
CMap<const JSPandaFile *, CMap<int32_t, JSTaggedValue>> cachedConstpools_ {};
|
||||
CString assetPath_;
|
||||
|
||||
AOTFileManager *aotFileManager_ {nullptr};
|
||||
// VM resources.
|
||||
TSManager *tsManager_ {nullptr};
|
||||
|
||||
@ -313,9 +410,25 @@ private:
|
||||
std::unordered_map<IcuFormatterType, IcuFormatter> icuObjCache_;
|
||||
void *loop_ {nullptr};
|
||||
|
||||
static const uint32_t NODE_BLOCK_SIZE_LOG2 = 10;
|
||||
static const uint32_t NODE_BLOCK_SIZE = 1U << NODE_BLOCK_SIZE_LOG2;
|
||||
static constexpr int32_t MIN_HANDLE_STORAGE_SIZE = 2;
|
||||
JSTaggedType *handleScopeStorageNext_ {nullptr};
|
||||
JSTaggedType *handleScopeStorageEnd_ {nullptr};
|
||||
std::vector<std::array<JSTaggedType, NODE_BLOCK_SIZE> *> handleStorageNodes_ {};
|
||||
int32_t currentHandleStorageIndex_ {-1};
|
||||
int32_t handleScopeCount_ {0};
|
||||
EcmaHandleScope *lastHandleScope_ {nullptr};
|
||||
JSTaggedType *currentFrame_ {nullptr};
|
||||
JSTaggedType *leaveFrame_ {nullptr};
|
||||
JSTaggedType *lastFp_ {nullptr};
|
||||
PropertiesCache *propertiesCache_ {nullptr};
|
||||
|
||||
friend class EcmaHandleScope;
|
||||
friend class JSPandaFileExecutor;
|
||||
friend class ObjectFactory;
|
||||
friend class panda::JSNApi;
|
||||
friend class AOTFileManager;
|
||||
};
|
||||
} // namespace ecmascript
|
||||
} // namespace panda
|
||||
|
@ -112,7 +112,7 @@ EcmaVM *EcmaVM::Create(const JSRuntimeOptions &options, EcmaParamConfiguration &
|
||||
auto jsThread = JSThread::Create(vm);
|
||||
vm->thread_ = jsThread;
|
||||
vm->Initialize();
|
||||
JsStackInfo::loader = vm->GetAOTFileManager();
|
||||
JsStackInfo::loader = vm->GetJSThread()->GetCurrentEcmaContext()->GetAOTFileManager();
|
||||
#if defined(__aarch64__) && !defined(PANDA_TARGET_MACOS) && !defined(PANDA_TARGET_IOS)
|
||||
if (SetThreadInfoCallback != nullptr) {
|
||||
SetThreadInfoCallback(CrashCallback);
|
||||
@ -215,9 +215,8 @@ bool EcmaVM::Initialize()
|
||||
if (!WIN_OR_MAC_OR_IOS_PLATFORM) {
|
||||
snapshotEnv_->Initialize();
|
||||
}
|
||||
aotFileManager_ = new AOTFileManager(this);
|
||||
if (options_.GetEnableAsmInterpreter()) {
|
||||
LoadStubFile();
|
||||
thread_->GetCurrentEcmaContext()->LoadStubFile();
|
||||
}
|
||||
|
||||
// optCodeProfiler_ = new OptCodeProfiler();
|
||||
@ -229,57 +228,6 @@ bool EcmaVM::Initialize()
|
||||
return true;
|
||||
}
|
||||
|
||||
void EcmaVM::InitializeEcmaScriptRunStat()
|
||||
{
|
||||
// NOLINTNEXTLINE(modernize-avoid-c-arrays)
|
||||
static const char *runtimeCallerNames[] = {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define INTERPRETER_CALLER_NAME(name) "Interpreter::" #name,
|
||||
INTERPRETER_CALLER_LIST(INTERPRETER_CALLER_NAME) // NOLINTNEXTLINE(bugprone-suspicious-missing-comma)
|
||||
#undef INTERPRETER_CALLER_NAME
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define BUILTINS_API_NAME(class, name) "BuiltinsApi::" #class "_" #name,
|
||||
BUILTINS_API_LIST(BUILTINS_API_NAME)
|
||||
#undef BUILTINS_API_NAME
|
||||
#define ABSTRACT_OPERATION_NAME(class, name) "AbstractOperation::" #class "_" #name,
|
||||
ABSTRACT_OPERATION_LIST(ABSTRACT_OPERATION_NAME)
|
||||
#undef ABSTRACT_OPERATION_NAME
|
||||
#define MEM_ALLOCATE_AND_GC_NAME(name) "Memory::" #name,
|
||||
MEM_ALLOCATE_AND_GC_LIST(MEM_ALLOCATE_AND_GC_NAME)
|
||||
#undef MEM_ALLOCATE_AND_GC_NAME
|
||||
#define DEF_RUNTIME_ID(name) "Runtime::" #name,
|
||||
RUNTIME_STUB_WITH_GC_LIST(DEF_RUNTIME_ID)
|
||||
#undef DEF_RUNTIME_ID
|
||||
};
|
||||
static_assert(sizeof(runtimeCallerNames) == sizeof(const char *) * ecmascript::RUNTIME_CALLER_NUMBER,
|
||||
"Invalid runtime caller number");
|
||||
runtimeStat_ = chunk_.New<EcmaRuntimeStat>(runtimeCallerNames, ecmascript::RUNTIME_CALLER_NUMBER);
|
||||
if (UNLIKELY(runtimeStat_ == nullptr)) {
|
||||
LOG_FULL(FATAL) << "alloc runtimeStat_ failed";
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
void EcmaVM::SetRuntimeStatEnable(bool flag)
|
||||
{
|
||||
static uint64_t start = 0;
|
||||
if (flag) {
|
||||
start = PandaRuntimeTimer::Now();
|
||||
if (runtimeStat_ == nullptr) {
|
||||
InitializeEcmaScriptRunStat();
|
||||
}
|
||||
} else {
|
||||
LOG_ECMA(INFO) << "Runtime State duration:" << PandaRuntimeTimer::Now() - start << "(ns)";
|
||||
if (runtimeStat_ != nullptr && runtimeStat_->IsRuntimeStatEnabled()) {
|
||||
runtimeStat_->Print();
|
||||
runtimeStat_->ResetAllCount();
|
||||
}
|
||||
}
|
||||
if (runtimeStat_ != nullptr) {
|
||||
runtimeStat_->SetRuntimeStatEnabled(flag);
|
||||
}
|
||||
}
|
||||
|
||||
EcmaVM::~EcmaVM()
|
||||
{
|
||||
initialized_ = false;
|
||||
@ -334,11 +282,6 @@ EcmaVM::~EcmaVM()
|
||||
factory_ = nullptr;
|
||||
}
|
||||
|
||||
if (runtimeStat_ != nullptr) {
|
||||
chunk_.Delete(runtimeStat_);
|
||||
runtimeStat_ = nullptr;
|
||||
}
|
||||
|
||||
if (quickFixManager_ != nullptr) {
|
||||
delete quickFixManager_;
|
||||
quickFixManager_ = nullptr;
|
||||
@ -349,11 +292,6 @@ EcmaVM::~EcmaVM()
|
||||
snapshotEnv_ = nullptr;
|
||||
}
|
||||
|
||||
if (aotFileManager_ != nullptr) {
|
||||
delete aotFileManager_;
|
||||
aotFileManager_ = nullptr;
|
||||
}
|
||||
|
||||
if (callTimer_ != nullptr) {
|
||||
delete callTimer_;
|
||||
callTimer_ = nullptr;
|
||||
@ -373,13 +311,6 @@ void EcmaVM::SetGlobalEnv(GlobalEnv *global)
|
||||
{
|
||||
thread_->GetCurrentEcmaContext()->SetGlobalEnv(global);
|
||||
}
|
||||
JSTaggedValue EcmaVM::InvokeEcmaAotEntrypoint(JSHandle<JSFunction> mainFunc, JSHandle<JSTaggedValue> &thisArg,
|
||||
const JSPandaFile *jsPandaFile, std::string_view entryPoint,
|
||||
CJSInfo* cjsInfo)
|
||||
{
|
||||
aotFileManager_->SetAOTMainFuncEntry(mainFunc, jsPandaFile, entryPoint);
|
||||
return JSFunction::InvokeOptimizedEntrypoint(thread_, mainFunc, thisArg, entryPoint, cjsInfo);
|
||||
}
|
||||
|
||||
JSTaggedValue EcmaVM::FastCallAot(size_t actualNumArgs, JSTaggedType *args, const JSTaggedType *prevFp)
|
||||
{
|
||||
@ -394,21 +325,6 @@ JSTaggedValue EcmaVM::FastCallAot(size_t actualNumArgs, JSTaggedType *args, cons
|
||||
return res;
|
||||
}
|
||||
|
||||
JSTaggedValue EcmaVM::ExecuteAot(size_t actualNumArgs, JSTaggedType *args,
|
||||
const JSTaggedType *prevFp, bool needPushUndefined)
|
||||
{
|
||||
INTERPRETER_TRACE(thread_, ExecuteAot);
|
||||
auto entry = thread_->GetRTInterface(kungfu::RuntimeStubCSigns::ID_JSFunctionEntry);
|
||||
// do not modify this log to INFO, this will call many times
|
||||
LOG_ECMA(DEBUG) << "start to execute aot entry: " << (void*)entry;
|
||||
auto res = reinterpret_cast<JSFunctionEntryType>(entry)(thread_->GetGlueAddr(),
|
||||
actualNumArgs,
|
||||
args,
|
||||
reinterpret_cast<uintptr_t>(prevFp),
|
||||
needPushUndefined);
|
||||
return res;
|
||||
}
|
||||
|
||||
void EcmaVM::CheckStartCpuProfiler()
|
||||
{
|
||||
#if defined(ECMASCRIPT_SUPPORT_CPUPROFILER)
|
||||
@ -734,7 +650,6 @@ void EcmaVM::Iterate(const RootVisitor &v, const RootRangeVisitor &rv)
|
||||
{
|
||||
rv(Root::ROOT_VM, ObjectSlot(ToUintPtr(&internalNativeMethods_.front())),
|
||||
ObjectSlot(ToUintPtr(&internalNativeMethods_.back()) + JSTaggedValue::TaggedTypeSize()));
|
||||
aotFileManager_->Iterate(v);
|
||||
if (!WIN_OR_MAC_OR_IOS_PLATFORM) {
|
||||
snapshotEnv_->Iterate(v);
|
||||
}
|
||||
@ -747,35 +662,6 @@ void EcmaVM::Iterate(const RootVisitor &v, const RootRangeVisitor &rv)
|
||||
}
|
||||
}
|
||||
|
||||
void EcmaVM::LoadStubFile()
|
||||
{
|
||||
std::string stubFile = options_.GetStubFile();
|
||||
aotFileManager_->LoadStubFile(stubFile);
|
||||
}
|
||||
|
||||
bool EcmaVM::LoadAOTFiles(const std::string& aotFileName)
|
||||
{
|
||||
std::string anFile = aotFileName + AOTFileManager::FILE_EXTENSION_AN;
|
||||
if (!aotFileManager_->LoadAnFile(anFile)) {
|
||||
LOG_ECMA(ERROR) << "Load " << anFile << " failed. Destroy aot data and rollback to interpreter";
|
||||
ecmascript::AnFileDataManager::GetInstance()->SafeDestroyAnData(anFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string aiFile = aotFileName + AOTFileManager::FILE_EXTENSION_AI;
|
||||
if (!aotFileManager_->LoadAiFile(aiFile)) {
|
||||
LOG_ECMA(ERROR) << "Load " << aiFile << " failed. Destroy aot data and rollback to interpreter";
|
||||
ecmascript::AnFileDataManager::GetInstance()->SafeDestroyAnData(anFile);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void EcmaVM::DumpAOTInfo() const
|
||||
{
|
||||
aotFileManager_->DumpAOTInfo();
|
||||
}
|
||||
|
||||
#if defined(ECMASCRIPT_SUPPORT_HEAPPROFILER)
|
||||
void EcmaVM::DeleteHeapProfile()
|
||||
{
|
||||
|
@ -86,19 +86,10 @@ class QuickFixManager;
|
||||
class ConstantPool;
|
||||
class FunctionCallTimer;
|
||||
|
||||
// enum class IcuFormatterType {
|
||||
// SIMPLE_DATE_FORMAT_DEFAULT,
|
||||
// SIMPLE_DATE_FORMAT_DATE,
|
||||
// SIMPLE_DATE_FORMAT_TIME,
|
||||
// NUMBER_FORMATTER,
|
||||
// COLLATOR
|
||||
// };
|
||||
|
||||
using NativePtrGetter = void* (*)(void* info);
|
||||
|
||||
using ResolvePathCallback = std::function<std::string(std::string dirPath, std::string requestPath)>;
|
||||
using ResolveBufferCallback = std::function<std::vector<uint8_t>(std::string dirPath)>;
|
||||
// using IcuDeleteEntry = void(*)(void *pointer, void *data);
|
||||
|
||||
class EcmaVM {
|
||||
public:
|
||||
@ -187,16 +178,8 @@ public:
|
||||
void RemoveFromNativePointerList(JSNativePointer *array);
|
||||
|
||||
JSHandle<ecmascript::JSTaggedValue> GetAndClearEcmaUncaughtException() const;
|
||||
JSHandle<ecmascript::JSTaggedValue> GetEcmaUncaughtException() const;
|
||||
JSHandle<ecmascript::JSTaggedValue> GetEcmaUncaughtException() const;
|
||||
void EnableUserUncaughtErrorHandler();
|
||||
|
||||
EcmaRuntimeStat *GetRuntimeStat() const
|
||||
{
|
||||
return runtimeStat_;
|
||||
}
|
||||
|
||||
void SetRuntimeStatEnable(bool flag);
|
||||
|
||||
bool IsOptionalLogEnabled() const
|
||||
{
|
||||
return optionalLogEnabled_;
|
||||
@ -231,11 +214,6 @@ public:
|
||||
void ProcessNativeDelete(const WeakRootVisitor &visitor);
|
||||
void ProcessReferences(const WeakRootVisitor &visitor);
|
||||
|
||||
AOTFileManager *GetAOTFileManager() const
|
||||
{
|
||||
return aotFileManager_;
|
||||
}
|
||||
|
||||
SnapshotEnv *GetSnapshotEnv() const
|
||||
{
|
||||
return snapshotEnv_;
|
||||
@ -426,9 +404,6 @@ public:
|
||||
return quickFixManager_;
|
||||
}
|
||||
|
||||
JSTaggedValue ExecuteAot(size_t actualNumArgs, JSTaggedType *args,
|
||||
const JSTaggedType *prevFp, bool needPushUndefined);
|
||||
|
||||
JSTaggedValue FastCallAot(size_t actualNumArgs, JSTaggedType *args, const JSTaggedType *prevFp);
|
||||
|
||||
void HandleUncaughtException(JSTaggedValue exception);
|
||||
@ -442,32 +417,21 @@ public:
|
||||
|
||||
|
||||
void SetGlobalEnv(GlobalEnv *global);
|
||||
void CJSExecution(JSHandle<JSFunction> &func, JSHandle<JSTaggedValue> &thisArg,
|
||||
const JSPandaFile *jsPandaFile);
|
||||
protected:
|
||||
|
||||
void PrintJSErrorInfo(const JSHandle<JSTaggedValue> &exceptionInfo) const;
|
||||
|
||||
private:
|
||||
JSTaggedValue InvokeEcmaAotEntrypoint(JSHandle<JSFunction> mainFunc, JSHandle<JSTaggedValue> &thisArg,
|
||||
const JSPandaFile *jsPandaFile, std::string_view entryPoint,
|
||||
CJSInfo* cjsInfo = nullptr);
|
||||
|
||||
void CJSExecution(JSHandle<JSFunction> &func, JSHandle<JSTaggedValue> &thisArg,
|
||||
const JSPandaFile *jsPandaFile, std::string_view entryPoint);
|
||||
|
||||
void InitializeEcmaScriptRunStat();
|
||||
|
||||
void ClearBufferData();
|
||||
|
||||
bool LoadAOTFiles(const std::string& aotFileName);
|
||||
void LoadStubFile();
|
||||
void CheckStartCpuProfiler();
|
||||
|
||||
// For Internal Native MethodLiteral.
|
||||
void GenerateInternalNativeMethods();
|
||||
|
||||
NO_MOVE_SEMANTIC(EcmaVM);
|
||||
NO_MOVE_SEMANTIC(EcmaVM);
|
||||
NO_COPY_SEMANTIC(EcmaVM);
|
||||
|
||||
// VM startup states.
|
||||
@ -484,14 +448,12 @@ private:
|
||||
CList<JSNativePointer *> nativePointerList_;
|
||||
// VM execution states.
|
||||
JSThread *thread_ {nullptr};
|
||||
EcmaRuntimeStat *runtimeStat_ {nullptr};
|
||||
|
||||
CMap<const JSPandaFile *, CMap<int32_t, JSTaggedValue>> cachedConstpools_ {};
|
||||
|
||||
// VM resources.
|
||||
SnapshotEnv *snapshotEnv_ {nullptr};
|
||||
bool optionalLogEnabled_ {false};
|
||||
AOTFileManager *aotFileManager_ {nullptr};
|
||||
|
||||
// Debugger
|
||||
tooling::JsDebuggerManager *debuggerManager_ {nullptr};
|
||||
|
@ -27,7 +27,7 @@ namespace panda::ecmascript {
|
||||
FrameIterator::FrameIterator(JSTaggedType *sp, const JSThread *thread) : current_(sp), thread_(thread)
|
||||
{
|
||||
if (thread != nullptr) {
|
||||
arkStackMapParser_ = thread->GetEcmaVM()->GetAOTFileManager()->GetStackMapParser();
|
||||
arkStackMapParser_ = const_cast<JSThread*>(thread)->GetCurrentEcmaContext()->GetAOTFileManager()->GetStackMapParser();
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ JSTaggedValue FrameIterator::GetFunction() const
|
||||
|
||||
AOTFileInfo::CallSiteInfo FrameIterator::CalCallSiteInfo(uintptr_t retAddr) const
|
||||
{
|
||||
auto loader = thread_->GetEcmaVM()->GetAOTFileManager();
|
||||
auto loader = const_cast<JSThread*>(thread_)->GetCurrentEcmaContext()->GetAOTFileManager();
|
||||
return loader->CalCallSiteInfo(retAddr);
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ void FrameHandler::Iterate(const RootVisitor &visitor, const RootRangeVisitor &r
|
||||
}
|
||||
// lazy assignment: only Iterate need arkStackMapParser_ in order to high improve performance
|
||||
if (arkStackMapParser_ == nullptr) {
|
||||
arkStackMapParser_ = thread_->GetEcmaVM()->GetAOTFileManager()->GetStackMapParser();
|
||||
arkStackMapParser_ = const_cast<JSThread*>(thread_)->GetCurrentEcmaContext()->GetAOTFileManager()->GetStackMapParser();
|
||||
}
|
||||
IterateFrameChain(current, visitor, rangeVisitor, derivedVisitor);
|
||||
}
|
||||
|
@ -820,7 +820,7 @@ JSTaggedValue EcmaInterpreter::GeneratorReEnterAot(JSThread *thread, JSHandle<Ge
|
||||
#if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
|
||||
RuntimeStubs::StartCallTimer(thread->GetGlueAddr(), func.GetTaggedType(), true);
|
||||
#endif
|
||||
auto res = thread->GetEcmaVM()->ExecuteAot(method->GetNumArgs(), args.data(), prevFp, false);
|
||||
auto res = thread->GetCurrentEcmaContext()->ExecuteAot(method->GetNumArgs(), args.data(), prevFp, false);
|
||||
#if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
|
||||
RuntimeStubs::EndCallTimer(thread->GetGlueAddr(), func.GetTaggedType());
|
||||
#endif
|
||||
|
@ -343,7 +343,7 @@ JSTaggedValue JSFunction::InvokeOptimizedEntrypoint(JSThread *thread, JSHandle<J
|
||||
args = JSFunction::GetArgsData(false, thisArg, mainFunc, cjsInfo);
|
||||
// do not modify this log to INFO, this will call many times
|
||||
LOG_ECMA(DEBUG) << "start to execute aot entry: " << entryPoint;
|
||||
res = thread->GetEcmaVM()->ExecuteAot(actualNumArgs, args.data(), prevFp, false);
|
||||
res = thread->GetCurrentEcmaContext()->ExecuteAot(actualNumArgs, args.data(), prevFp, false);
|
||||
}
|
||||
#if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
|
||||
RuntimeStubs::EndCallTimer(thread->GetGlueAddr(), mainFunc.GetTaggedType());
|
||||
@ -404,8 +404,8 @@ JSTaggedValue JSFunction::InvokeOptimizedEntrypoint(JSThread *thread, JSHandle<J
|
||||
stackArgs[1] = stackArgs[0];
|
||||
resultValue = thread->GetEcmaVM()->FastCallAot(info->GetArgsNumber(), stackArgs + 1, prevFp);
|
||||
} else {
|
||||
resultValue = thread->GetEcmaVM()->ExecuteAot(info->GetArgsNumber(),
|
||||
info->GetArgs(), prevFp, needPushUndefined);
|
||||
resultValue = thread->GetCurrentEcmaContext()->ExecuteAot(info->GetArgsNumber(),
|
||||
info->GetArgs(), prevFp, needPushUndefined);
|
||||
}
|
||||
#if ECMASCRIPT_ENABLE_FUNCTION_CALL_TIMER
|
||||
RuntimeStubs::EndCallTimer(thread->GetGlueAddr(), func.GetTaggedType());
|
||||
|
@ -219,11 +219,11 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::Execute(JSThread *thread, con
|
||||
void JSPandaFileExecutor::LoadAOTFilesForFile(EcmaVM *vm, JSPandaFile *jsPandaFile)
|
||||
{
|
||||
if (vm->GetJSOptions().GetEnableAsmInterpreter()) {
|
||||
auto aotFM = vm->GetAOTFileManager();
|
||||
auto aotFM = vm->GetJSThread()->GetCurrentEcmaContext()->GetAOTFileManager();
|
||||
if (vm->GetJSOptions().WasAOTOutputFileSet()) {
|
||||
AnFileDataManager::GetInstance()->SetEnable(true);
|
||||
std::string aotFilename = vm->GetJSOptions().GetAOTOutputFile();
|
||||
vm->LoadAOTFiles(aotFilename);
|
||||
vm->GetJSThread()->GetCurrentEcmaContext()->LoadAOTFiles(aotFilename);
|
||||
}
|
||||
if (aotFM->IsLoad(jsPandaFile)) {
|
||||
uint32_t index = aotFM->GetAnFileIndex(jsPandaFile);
|
||||
|
@ -202,7 +202,7 @@ JSHandle<Program> JSPandaFileManager::GenerateProgram(EcmaVM *vm, const JSPandaF
|
||||
{
|
||||
ASSERT(GetJSPandaFile(jsPandaFile->GetPandaFile()) != nullptr);
|
||||
if (AnFileDataManager::GetInstance()->IsEnable()) {
|
||||
vm->GetAOTFileManager()->LoadAiFile(jsPandaFile);
|
||||
vm->GetJSThread()->GetCurrentEcmaContext()->GetAOTFileManager()->LoadAiFile(jsPandaFile);
|
||||
}
|
||||
|
||||
return PandaFileTranslator::GenerateProgram(vm, jsPandaFile, entryPoint);
|
||||
|
@ -19,6 +19,6 @@ namespace panda::ecmascript {
|
||||
JSHandle<ConstantPool> ConstantPool::GetDeserializedConstantPool(EcmaVM *vm, const JSPandaFile *jsPandaFile,
|
||||
int32_t cpID)
|
||||
{
|
||||
return JSHandle<ConstantPool>(vm->GetAOTFileManager()->GetDeserializedConstantPool(jsPandaFile, cpID));
|
||||
return JSHandle<ConstantPool>(vm->GetJSThread()->GetCurrentEcmaContext()->GetAOTFileManager()->GetDeserializedConstantPool(jsPandaFile, cpID));
|
||||
}
|
||||
}
|
@ -200,7 +200,6 @@ public:
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
ASSERT(jsPandaFile->IsNewVersion());
|
||||
JSHandle<ConstantPool> constpoolHandle(thread, constpool);
|
||||
EcmaVM *vm = thread->GetEcmaVM();
|
||||
|
||||
EntityId id = constpoolHandle->GetEntityId(index);
|
||||
MethodLiteral *methodLiteral = jsPandaFile->FindMethodLiteral(id.GetOffset());
|
||||
@ -237,6 +236,13 @@ public:
|
||||
thread, jsPandaFile, literalId, constpool, entry, needSetAotFlag, entryIndexes);
|
||||
JSHandle<ClassLiteral> classLiteral = factory->NewClassLiteral();
|
||||
classLiteral->SetArray(thread, literalArray);
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
if (isLoadedAOT && !entryIndexes.GetTaggedValue().IsUndefined()) {
|
||||
thread->GetCurrentEcmaContext()->GetAOTFileManager()->SetAOTFuncEntryForLiteral(jsPandaFile, *literalArray, *entryIndexes);
|
||||
}
|
||||
|
||||
>>>>>>> 2f570c226 (add aotfilemanger from vm to context)
|
||||
val = classLiteral.GetTaggedValue();
|
||||
constpool->SetObjectToCache(thread, literal, val);
|
||||
}
|
||||
@ -286,6 +292,12 @@ public:
|
||||
valueHandle.Update(elements->Get(i + 1));
|
||||
JSObject::DefinePropertyByLiteral(thread, obj, key, valueHandle);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
if (isLoadedAOT && !entryIndexes.GetTaggedValue().IsUndefined()) {
|
||||
thread->GetCurrentEcmaContext()->GetAOTFileManager()->SetAOTFuncEntryForLiteral(jsPandaFile, *properties, *entryIndexes);
|
||||
}
|
||||
>>>>>>> 2f570c226 (add aotfilemanger from vm to context)
|
||||
val = obj.GetTaggedValue();
|
||||
break;
|
||||
}
|
||||
@ -295,6 +307,12 @@ public:
|
||||
uint32_t length = literal->GetLength();
|
||||
JSHandle<JSArray> arr(JSArray::ArrayCreate(thread, JSTaggedNumber(length)));
|
||||
arr->SetElements(thread, literal);
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
if (isLoadedAOT && !entryIndexes.GetTaggedValue().IsUndefined()) {
|
||||
thread->GetCurrentEcmaContext()->GetAOTFileManager()->SetAOTFuncEntryForLiteral(jsPandaFile, *literal, *entryIndexes);
|
||||
}
|
||||
>>>>>>> 2f570c226 (add aotfilemanger from vm to context)
|
||||
val = arr.GetTaggedValue();
|
||||
break;
|
||||
}
|
||||
|
@ -203,12 +203,12 @@ void DFXJSNApi::PrintStatisticResult(const EcmaVM *vm)
|
||||
|
||||
void DFXJSNApi::StartRuntimeStat(EcmaVM *vm)
|
||||
{
|
||||
vm->SetRuntimeStatEnable(true);
|
||||
vm->GetJSThread()->GetCurrentEcmaContext()->SetRuntimeStatEnable(true);
|
||||
}
|
||||
|
||||
void DFXJSNApi::StopRuntimeStat(EcmaVM *vm)
|
||||
{
|
||||
vm->SetRuntimeStatEnable(false);
|
||||
vm->GetJSThread()->GetCurrentEcmaContext()->SetRuntimeStatEnable(false);
|
||||
}
|
||||
|
||||
size_t DFXJSNApi::GetArrayBufferSize(const EcmaVM *vm)
|
||||
|
@ -514,7 +514,7 @@ void JSNApi::LoadAotFile(EcmaVM *vm, const std::string &moduleName)
|
||||
std::string aotFileName = ecmascript::AnFileDataManager::GetInstance()->GetDir();
|
||||
aotFileName += moduleName;
|
||||
LOG_ECMA(INFO) << "start to load aot file: " << aotFileName;
|
||||
vm->LoadAOTFiles(aotFileName);
|
||||
vm->GetJSThread()->GetCurrentEcmaContext()->LoadAOTFiles(aotFileName);
|
||||
}
|
||||
|
||||
bool JSNApi::ExecuteInContext(EcmaVM *vm, const std::string &fileName, const std::string &entry, bool needUpdate)
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
void SetUp() override
|
||||
{
|
||||
TestHelper::CreateEcmaVMWithScope(vm_, thread_, scope_);
|
||||
vm_->SetRuntimeStatEnable(true);
|
||||
vm_->GetJSThread()->GetCurrentEcmaContext()->SetRuntimeStatEnable(true);
|
||||
vm_->SetEnableForceGC(false);
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ HWTEST_F_L0(DFXJSNApiTests, Start_Stop_HeapTracking_002)
|
||||
|
||||
HWTEST_F_L0(DFXJSNApiTests, Start_Stop_RuntimeStat)
|
||||
{
|
||||
EcmaRuntimeStat *ecmaRuntimeStat = vm_->GetRuntimeStat();
|
||||
EcmaRuntimeStat *ecmaRuntimeStat = vm_->GetJSThread()->GetCurrentEcmaContext()->GetRuntimeStat();
|
||||
EXPECT_TRUE(ecmaRuntimeStat != nullptr);
|
||||
|
||||
ecmaRuntimeStat->SetRuntimeStatEnabled(false);
|
||||
|
@ -1088,21 +1088,21 @@ enum EcmaRuntimeCallerId {
|
||||
|
||||
#if ECMASCRIPT_ENABLE_INTERPRETER_RUNTIME_STAT
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define INTERPRETER_TRACE(thread, name) \
|
||||
[[maybe_unused]] JSThread *_js_thread_ = thread; \
|
||||
[[maybe_unused]] EcmaRuntimeStat *_run_stat_ = _js_thread_->GetEcmaVM()->GetRuntimeStat(); \
|
||||
#define INTERPRETER_TRACE(thread, name) \
|
||||
[[maybe_unused]] JSThread *_js_thread_ = thread; \
|
||||
[[maybe_unused]] EcmaRuntimeStat *_run_stat_ = _js_thread_->GetCurrentEcmaContext()->GetRuntimeStat(); \
|
||||
RuntimeTimerScope interpret_##name##_scope_(INTERPRETER_CALLER_ID(name) _run_stat_)
|
||||
#if defined(ECMASCRIPT_SUPPORT_CPUPROFILER)
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define RUNTIME_TRACE(thread, name) \
|
||||
[[maybe_unused]] JSThread *_js_thread_ = thread; \
|
||||
[[maybe_unused]] EcmaRuntimeStat *_run_stat_ = _js_thread_->GetEcmaVM()->GetRuntimeStat(); \
|
||||
RuntimeTimerScope interpret_##name##_scope_(RUNTIME_CALLER_ID(name) _run_stat_); \
|
||||
#define RUNTIME_TRACE(thread, name) \
|
||||
[[maybe_unused]] JSThread *_js_thread_ = thread; \
|
||||
[[maybe_unused]] EcmaRuntimeStat *_run_stat_ = _js_thread_->GetCurrentEcmaContext()->GetRuntimeStat(); \
|
||||
RuntimeTimerScope interpret_##name##_scope_(RUNTIME_CALLER_ID(name) _run_stat_); \
|
||||
[[maybe_unused]] RuntimeStateScope _runtime_state_##name##_scope_(_js_thread_)
|
||||
#else
|
||||
#define RUNTIME_TRACE(thread, name) \
|
||||
[[maybe_unused]] JSThread *_js_thread_ = thread; \
|
||||
[[maybe_unused]] EcmaRuntimeStat *_run_stat_ = _js_thread_->GetEcmaVM()->GetRuntimeStat(); \
|
||||
#define RUNTIME_TRACE(thread, name) \
|
||||
[[maybe_unused]] JSThread *_js_thread_ = thread; \
|
||||
[[maybe_unused]] EcmaRuntimeStat *_run_stat_ = _js_thread_->GetCurrentEcmaContext()->GetRuntimeStat(); \
|
||||
RuntimeTimerScope interpret_##name##_scope_(RUNTIME_CALLER_ID(name) _run_stat_);
|
||||
#endif
|
||||
#else
|
||||
@ -1119,15 +1119,15 @@ enum EcmaRuntimeCallerId {
|
||||
|
||||
#if ECMASCRIPT_ENABLE_BUILTINS_RUNTIME_STAT
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define BUILTINS_API_TRACE(thread, class, name) \
|
||||
[[maybe_unused]] JSThread *_js_thread_ = thread; \
|
||||
[[maybe_unused]] EcmaRuntimeStat *_run_stat_ = _js_thread_->GetEcmaVM()->GetRuntimeStat(); \
|
||||
#define BUILTINS_API_TRACE(thread, class, name) \
|
||||
[[maybe_unused]] JSThread *_js_thread_ = thread; \
|
||||
[[maybe_unused]] EcmaRuntimeStat *_run_stat_ = _js_thread_->GetCurrentEcmaContext()->GetRuntimeStat(); \
|
||||
RuntimeTimerScope builtins_##class##name##_scope_(BUILTINS_API_ID(class, name) _run_stat_)
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
|
||||
#define ABSTRACT_OPERATION_TRACE(thread, class, name) \
|
||||
[[maybe_unused]] JSThread *_js_thread_ = thread; \
|
||||
[[maybe_unused]] EcmaRuntimeStat *_run_stat_ = _js_thread_->GetEcmaVM()->GetRuntimeStat(); \
|
||||
#define ABSTRACT_OPERATION_TRACE(thread, class, name) \
|
||||
[[maybe_unused]] JSThread *_js_thread_ = thread; \
|
||||
[[maybe_unused]] EcmaRuntimeStat *_run_stat_ = _js_thread_->GetCurrentEcmaContext()->GetRuntimeStat(); \
|
||||
RuntimeTimerScope abstract_##class##name##_scope_(ABSTRACT_OPERATION_ID(class, name) _run_stat_)
|
||||
#else
|
||||
#define BUILTINS_API_TRACE(thread, class, name) static_cast<void>(0) // NOLINT(cppcoreguidelines-macro-usage)
|
||||
@ -1135,9 +1135,9 @@ enum EcmaRuntimeCallerId {
|
||||
#endif // ECMASCRIPT_ENABLE_BUILTINS_RUNTIME_STAT
|
||||
|
||||
#if ECMASCRIPT_ENABLE_ALLOCATE_AND_GC_RUNTIME_STAT
|
||||
#define MEM_ALLOCATE_AND_GC_TRACE(vm, name) \
|
||||
CHECK_JS_THREAD(vm); \
|
||||
EcmaRuntimeStat *_run_stat_ = vm->GetRuntimeStat(); \
|
||||
#define MEM_ALLOCATE_AND_GC_TRACE(vm, name) \
|
||||
CHECK_JS_THREAD(vm); \
|
||||
EcmaRuntimeStat *_run_stat_ = vm->GetJSThread()->GetCurrentEcmaContext()->GetRuntimeStat(); \
|
||||
RuntimeTimerScope mem_##name##_scope_(MEM_ALLOCATE_AND_GC_ID(name) _run_stat_)
|
||||
#else
|
||||
#define MEM_ALLOCATE_AND_GC_TRACE(vm, name) static_cast<void>(0) // NOLINT(cppcoreguidelines-macro-usage)
|
||||
|
@ -1406,7 +1406,7 @@ void SnapshotProcessor::HandleRootObject(SnapshotType type, uintptr_t rootObject
|
||||
case SnapshotType::AI: {
|
||||
JSTaggedValue item = JSTaggedValue(static_cast<JSTaggedType>(rootObjectAddr));
|
||||
if (!isRootObjRelocate_ && item.IsTaggedArray()) {
|
||||
vm_->GetAOTFileManager()->AddConstantPool(fileName_, item);
|
||||
vm_->GetJSThread()->GetCurrentEcmaContext()->GetAOTFileManager()->AddConstantPool(fileName_, item);
|
||||
isRootObjRelocate_ = true;
|
||||
}
|
||||
break;
|
||||
|
@ -2463,7 +2463,7 @@ JSTaggedValue RuntimeStubs::RuntimeOptConstructGeneric(JSThread *thread, JSHandl
|
||||
}
|
||||
resultValue = thread->GetEcmaVM()->FastCallAot(size, values.data(), prevFp);
|
||||
} else {
|
||||
resultValue = thread->GetEcmaVM()->ExecuteAot(size, values.data(), prevFp, needPushUndefined);
|
||||
resultValue = thread->GetCurrentEcmaContext()->ExecuteAot(size, values.data(), prevFp, needPushUndefined);
|
||||
}
|
||||
} else {
|
||||
ctor->GetCallTarget()->SetAotCodeBit(false); // if Construct is not ClassConstructor, don't run aot
|
||||
|
Loading…
Reference in New Issue
Block a user