mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-27 12:10:47 +00:00
Add GetCurrentModuleName interface for library create worker
Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8MFLF?from=project-issue Signed-off-by: yaochaonan <yaochaonan@huawei.com> Change-Id: Ia4451b3a539be20e65e8bf32f63b3345318d3789
This commit is contained in:
parent
313a711d12
commit
5da3a2b806
@ -73,6 +73,7 @@
|
||||
#include "ecmascript/mem/visitor.h"
|
||||
#include "ecmascript/module/js_module_manager.h"
|
||||
#include "ecmascript/module/module_data_extractor.h"
|
||||
#include "ecmascript/module/module_path_helper.h"
|
||||
#include "ecmascript/object_factory.h"
|
||||
#include "ecmascript/patch/quick_fix_manager.h"
|
||||
#include "ecmascript/pgo_profiler/pgo_profiler_manager.h"
|
||||
@ -723,4 +724,17 @@ void EcmaVM::ResumeWorkerVm(uint32_t tid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This moduleName is a readOnly variable for napi, represent which abc is running in current vm.
|
||||
CString EcmaVM::GetCurrentModuleName()
|
||||
{
|
||||
CString recordName = ConvertToString(EcmaInterpreter::GetCurrentEntryPoint(thread_));
|
||||
LOG_FULL(INFO) << " Current recordName is " << recordName;
|
||||
CString moduleName = ModulePathHelper::GetModuleName(recordName);
|
||||
PathHelper::DeleteNamespace(moduleName);
|
||||
if (moduleName.empty()) {
|
||||
LOG_FULL(ERROR) << " GetCurrentModuleName Fail, recordName is " << recordName;
|
||||
}
|
||||
return moduleName;
|
||||
}
|
||||
} // namespace panda::ecmascript
|
||||
|
@ -422,6 +422,8 @@ public:
|
||||
return moduleName_;
|
||||
}
|
||||
|
||||
CString GetCurrentModuleName();
|
||||
|
||||
#if defined(ECMASCRIPT_SUPPORT_CPUPROFILER)
|
||||
CpuProfiler *GetProfiler() const
|
||||
{
|
||||
|
@ -169,6 +169,23 @@ public:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Before: bundleName/moduleName/ets/xxx/xxx
|
||||
* After: moduleName
|
||||
*/
|
||||
inline static CString GetModuleName(const CString recordName)
|
||||
{
|
||||
size_t pos1 = recordName.find(PathHelper::SLASH_TAG);
|
||||
if (pos1 != CString::npos) {
|
||||
pos1++;
|
||||
size_t pos2 = recordName.find(PathHelper::SLASH_TAG, pos1);
|
||||
if (pos2 != CString::npos) {
|
||||
return recordName.substr(pos1, pos2 - pos1);
|
||||
}
|
||||
}
|
||||
return CString();
|
||||
}
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
#endif // ECMASCRIPT_MODULE_MODULE_PATH_HELPER_H
|
@ -1273,6 +1273,7 @@ public:
|
||||
static std::string GetBundleName(EcmaVM *vm);
|
||||
static void SetModuleName(EcmaVM *vm, const std::string &moduleName);
|
||||
static std::string GetModuleName(EcmaVM *vm);
|
||||
static std::string GetCurrentModuleName(EcmaVM *vm);
|
||||
static void AllowCrossThreadExecution(EcmaVM *vm);
|
||||
static void SynchronizVMInfo(EcmaVM *vm, const EcmaVM *hostVM);
|
||||
static bool IsProfiling(EcmaVM *vm);
|
||||
|
@ -2590,6 +2590,11 @@ std::string JSNApi::GetModuleName(EcmaVM *vm)
|
||||
return vm->GetModuleName().c_str();
|
||||
}
|
||||
|
||||
std::string JSNApi::GetCurrentModuleName(EcmaVM *vm)
|
||||
{
|
||||
return vm->GetCurrentModuleName().c_str();
|
||||
}
|
||||
|
||||
// Enable cross thread execution.
|
||||
void JSNApi::AllowCrossThreadExecution(EcmaVM *vm)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user