Add esm Trace

Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I9RTYD?from=project-issue

Signed-off-by: yaochaonan <yaochaonan@huawei.com>
Change-Id: Ie696e83790b2375425a4f134f30e7192ccf48eb4
This commit is contained in:
yaochaonan 2024-05-28 16:57:13 +08:00
parent 619ee92cf1
commit 48213e5303
6 changed files with 21 additions and 5 deletions

View File

@ -156,7 +156,10 @@ JSTaggedValue BuiltinsPromiseJob::DynamicImportJob(EcmaRuntimeCallInfo *argv)
CString fileNameStr = ConvertToString(dirPath.GetTaggedValue());
CString requestPath = ConvertToString(specifierString.GetTaggedValue());
LOG_ECMA(DEBUG) << "Start importing dynamic module : " << requestPath;
if (thread->GetEcmaVM()->GetJSOptions().EnableESMTrace()) {
CString traceInfo = "DynamicImportJob: " + requestPath;
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, traceInfo.c_str());
}
std::shared_ptr<JSPandaFile> curJsPandaFile;
CString recordNameStr;
if (!recordName->IsUndefined()) {

View File

@ -46,10 +46,6 @@ public:
#if defined(ENABLE_HITRACE)
jobId = pendingJob->GetJobId();
#endif
std::string strTrace = "PendingJob::ExecutePendingJob: jobId: " + std::to_string(jobId);
strTrace += ", threadId: " + std::to_string(thread->GetThreadId());
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, strTrace);
JSHandle<JSTaggedValue> job(thread, pendingJob->GetJob());
ASSERT(job->IsCallable());
JSHandle<TaggedArray> argv(thread, pendingJob->GetArguments());

View File

@ -54,6 +54,7 @@ enum ArkProperties {
// Use DISABLE to adapt to the exsiting ArkProperties in testing scripts.
DISABLE_SHARED_CONCURRENT_MARK = 1 << 22,
ENABLE_NATIVE_MODULE_ERROR = 1 << 23,
ENABLE_ESM_TRACE = 1 << 24,
ENABLE_MODULE_LOG = 1 << 25
};
@ -568,6 +569,11 @@ public:
return (static_cast<uint32_t>(arkProperties_) & ArkProperties::ENABLE_MICROJOB_TRACE) != 0;
}
bool EnableESMTrace() const
{
return (static_cast<uint32_t>(arkProperties_) & ArkProperties::ENABLE_ESM_TRACE) != 0;
}
bool EnableInitOldSocketSession() const
{
return (static_cast<uint32_t>(arkProperties_) & ArkProperties::ENABLE_INIT_OLD_SOCKET_SESSION) != 0;

View File

@ -261,6 +261,10 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::Execute(JSThread *thread, con
std::string_view entryPoint, bool executeFromJob)
{
ThreadManagedScope managedScope(thread);
if (thread->GetEcmaVM()->GetJSOptions().EnableESMTrace()) {
CString traceInfo = "FileExecute: " + CString(entryPoint);
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, traceInfo.c_str());
}
// For Ark application startup
EcmaContext *context = thread->GetCurrentEcmaContext();

View File

@ -173,6 +173,9 @@ std::shared_ptr<JSPandaFile> JSPandaFileManager::LoadJSPandaFile(JSThread *threa
std::shared_ptr<JSPandaFile> JSPandaFileManager::LoadJSPandaFileSecure(JSThread *thread, const CString &filename,
std::string_view entryPoint, uint8_t *buffer, size_t size, bool needUpdate)
{
if (thread->GetEcmaVM()->GetJSOptions().EnableESMTrace()) {
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, "JSPandaFileManager::LoadJSPandaFileSecure");
}
if (buffer == nullptr || size == 0) {
LOG_FULL(ERROR) << "Input buffer is empty";
return nullptr;

View File

@ -408,6 +408,10 @@ bool SourceTextModule::LoadNativeModule(JSThread *thread, const JSHandle<SourceT
[[maybe_unused]] LocalScope scope(vm);
CString moduleRequestName = ConvertToString(EcmaString::Cast(requiredModule->GetEcmaModuleRecordName()));
if (thread->GetEcmaVM()->GetJSOptions().EnableESMTrace()) {
CString traceInfo = "LoadNativeModule: " + moduleRequestName;
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, traceInfo.c_str());
}
CString soName = PathHelper::GetStrippedModuleName(moduleRequestName);
CString fileName = ConvertToString(EcmaString::Cast(requiredModule->GetEcmaModuleFilename()));