Modify trace timing of microJob and add macro to compile independently

Signed-off-by: yangxiaoshuai2022 <yangxiaoshuai@huawei.com>
This commit is contained in:
yangxiaoshuai2022 2024-04-24 11:48:49 +08:00
parent 11e22bd447
commit 226cbecfa9
3 changed files with 14 additions and 24 deletions

View File

@ -95,11 +95,7 @@
#include "ecmascript/ohos/enable_aot_list_helper.h"
#include "ecmascript/ohos/jit_tools.h"
#ifdef JIT_SWITCH_COMPILE_MODE
#include "base/startup/init/interfaces/innerkits/include/syspara/parameters.h"
#endif
#ifdef PANDA_TARGET_OHOS
#if defined(PANDA_TARGET_OHOS) && !defined(STANDALONE_MODE)
#include "parameters.h"
#endif
@ -138,7 +134,7 @@ EcmaVM *EcmaVM::Create(const JSRuntimeOptions &options)
SetThreadInfoCallback(CrashCallback);
}
#endif
#ifdef PANDA_TARGET_OHOS
#if defined(PANDA_TARGET_OHOS) && !defined(STANDALONE_MODE)
int arkProperties = OHOS::system::GetIntParameter<int>("persist.ark.properties", -1);
vm->GetJSOptions().SetArkProperties(arkProperties);
#endif
@ -201,7 +197,7 @@ void EcmaVM::PostFork()
heap_->NotifyPostFork();
heap_->NotifyFinishColdStartSoon();
#endif
#ifdef PANDA_TARGET_OHOS
#if defined(PANDA_TARGET_OHOS) && !defined(STANDALONE_MODE)
int arkProperties = OHOS::system::GetIntParameter<int>("persist.ark.properties", -1);
GetJSOptions().SetArkProperties(arkProperties);
#endif

View File

@ -48,14 +48,17 @@ void MicroJobQueue::EnqueueJob(JSThread *thread, JSHandle<MicroJobQueue> jobQueu
JSHandle<PendingJob> pendingJob(factory->NewPendingJob(job, argv));
ENQUEUE_JOB_HITRACE(pendingJob, queueType);
#if defined(ENABLE_BYTRACE)
[[maybe_unused]] uint64_t jobId = 0;
#if defined(ENABLE_HITRACE)
jobId = thread->GetJobId();
pendingJob->SetJobId(jobId);
#endif
std::string strTrace = "MicroJobQueue::EnqueueJob: jobId: " + std::to_string(jobId);
strTrace += ", threadId: " + std::to_string(thread->GetThreadId());
if (thread->GetEcmaVM()->GetJSOptions().EnableMicroJobTrace()) {
std::vector<JsFrameInfo> jsStackInfo = JsStackInfo::BuildJsStackInfo(thread, true);
if (!jsStackInfo.empty()) {
uint64_t jobId = thread->GetJobId();
pendingJob->SetJobId(jobId);
JsFrameInfo jsFrameInfo = jsStackInfo.front();
std::string fileName = jsFrameInfo.fileName;
int lineNumber;
int columnNumber;
@ -71,16 +74,10 @@ void MicroJobQueue::EnqueueJob(JSThread *thread, JSHandle<MicroJobQueue> jobQueu
} else {
fileName += ":" + jsFrameInfo.pos;
}
std::string strTrace = "MicroJobQueue::EnqueueJob: jobId: " + std::to_string(jobId);
strTrace += ", threadId: " + std::to_string(thread->GetThreadId());
strTrace += ", funcName: " + jsFrameInfo.functionName + ", url: " + fileName;
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, strTrace);
}
} else {
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, "MicroJobQueue::EnqueueJob");
}
#endif
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, strTrace);
if (queueType == QueueType::QUEUE_PROMISE) {
JSHandle<TaggedQueue> promiseQueue(thread, jobQueue->GetPromiseJobQueue());

View File

@ -42,14 +42,11 @@ public:
[[maybe_unused]] EcmaHandleScope handleScope(thread);
EXECUTE_JOB_HITRACE(pendingJob);
#if defined(ENABLE_BYTRACE)
[[maybe_unused]] uint64_t jobId = 0;
#if defined(ENABLE_HITRACE)
if (thread->GetEcmaVM()->GetJSOptions().EnableMicroJobTrace()) {
std::string strTrace = "PendingJob::ExecutePendingJob: jobId: " + std::to_string(pendingJob->GetJobId());
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, strTrace);
}
#endif
jobId = pendingJob->GetJobId();
#endif
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, "PendingJob::ExecutePendingJob: jobId: " + std::to_string(jobId));
JSHandle<JSTaggedValue> job(thread, pendingJob->GetJob());
ASSERT(job->IsCallable());