mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-30 13:40:51 +00:00
微任务打点,包含入队及执行过程
Signed-off-by: yangxiaoshuai2022 <yangxiaoshuai@huawei.com> Signed-off-by: yangxiaoshuai2022 <yangxiaoshuai@huawei.com>
This commit is contained in:
parent
79997aa8be
commit
d7860cb5f3
@ -194,7 +194,7 @@ void BuildCrashInfo()
|
||||
file.close();
|
||||
}
|
||||
|
||||
std::vector<struct JsFrameInfo> JsStackInfo::BuildJsStackInfo(JSThread *thread)
|
||||
std::vector<struct JsFrameInfo> JsStackInfo::BuildJsStackInfo(JSThread *thread, bool currentStack)
|
||||
{
|
||||
std::vector<struct JsFrameInfo> jsFrame;
|
||||
uintptr_t *native = nullptr;
|
||||
@ -246,7 +246,10 @@ std::vector<struct JsFrameInfo> JsStackInfo::BuildJsStackInfo(JSThread *thread)
|
||||
!debugExtractor->MatchColumnWithOffset(callbackColumnFunc, methodId, offset)) {
|
||||
frameInfo.pos = "?";
|
||||
}
|
||||
jsFrame.push_back(frameInfo);
|
||||
jsFrame.push_back(std::move(frameInfo));
|
||||
if (currentStack) {
|
||||
return jsFrame;
|
||||
}
|
||||
} else {
|
||||
JSTaggedValue function = it.GetFunction();
|
||||
JSHandle<JSTaggedValue> extraInfoValue(
|
||||
|
@ -107,7 +107,7 @@ class JsStackInfo {
|
||||
public:
|
||||
static std::string BuildInlinedMethodTrace(const JSPandaFile *pf, std::map<uint32_t, uint32_t> &methodOffsets);
|
||||
static std::string BuildJsStackTrace(JSThread *thread, bool needNative);
|
||||
static std::vector<JsFrameInfo> BuildJsStackInfo(JSThread *thread);
|
||||
static std::vector<JsFrameInfo> BuildJsStackInfo(JSThread *thread, bool currentStack = false);
|
||||
static std::string BuildMethodTrace(Method *method, uint32_t pcOffset, bool enableStackSourceFile = true);
|
||||
static AOTFileManager *loader;
|
||||
};
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "ecmascript/js_thread.h"
|
||||
#include "ecmascript/object_factory.h"
|
||||
#include "ecmascript/tagged_queue.h"
|
||||
#include "ecmascript/dfx/stackinfo/js_stackinfo.h"
|
||||
|
||||
namespace panda::ecmascript::job {
|
||||
uint32_t MicroJobQueue::GetPromiseQueueSize(JSThread *thread, JSHandle<MicroJobQueue> jobQueue)
|
||||
@ -42,7 +43,20 @@ void MicroJobQueue::EnqueueJob(JSThread *thread, JSHandle<MicroJobQueue> jobQueu
|
||||
// 3. Assert: arguments is a List that has the same number of elements as the number of parameters required by job.
|
||||
// 4. Let callerContext be the running execution context.
|
||||
// 5. Let callerRealm be callerContext’s Realm.
|
||||
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, "MicroJobQueue::EnqueueJob");
|
||||
#if defined(ENABLE_BYTRACE)
|
||||
if (thread->GetEcmaVM()->GetJSOptions().EnableMicroJobTrace()) {
|
||||
std::vector<JsFrameInfo> jsStackInfo = JsStackInfo::BuildJsStackInfo(thread, true);
|
||||
if (!jsStackInfo.empty()) {
|
||||
JsFrameInfo jsFrameInfo = jsStackInfo.front();
|
||||
std::string strTrace = "MicroJobQueue::EnqueueJob: threadId: " + std::to_string(thread->GetThreadId());
|
||||
strTrace += ", funcName: " + jsFrameInfo.functionName;
|
||||
strTrace += ", url: " + jsFrameInfo.fileName + ":" + jsFrameInfo.pos;
|
||||
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, strTrace);
|
||||
}
|
||||
} else {
|
||||
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, "MicroJobQueue::EnqueueJob");
|
||||
}
|
||||
#endif
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
JSHandle<PendingJob> pendingJob(factory->NewPendingJob(job, argv));
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "ecmascript/tagged_array.h"
|
||||
#include "ecmascript/debugger/js_debugger_manager.h"
|
||||
#include "ecmascript/mem/c_containers.h"
|
||||
#include "ecmascript/dfx/stackinfo/js_stackinfo.h"
|
||||
|
||||
namespace panda::ecmascript::job {
|
||||
class PendingJob final : public Record {
|
||||
@ -38,6 +39,19 @@ public:
|
||||
|
||||
static JSTaggedValue ExecutePendingJob(const JSHandle<PendingJob> &pendingJob, JSThread *thread)
|
||||
{
|
||||
#if defined(ENABLE_BYTRACE)
|
||||
if (thread->GetEcmaVM()->GetJSOptions().EnableMicroJobTrace()) {
|
||||
std::vector<JsFrameInfo> jsStackInfo = JsStackInfo::BuildJsStackInfo(thread, true);
|
||||
if (!jsStackInfo.empty()) {
|
||||
JsFrameInfo jsFrameInfo = jsStackInfo.front();
|
||||
std::string strTrace = "PendingJob::ExecutePendingJob: ";
|
||||
strTrace += "threadId: " + std::to_string(thread->GetThreadId());
|
||||
strTrace += ", funcName: " + jsFrameInfo.functionName;
|
||||
strTrace += ", url: " + jsFrameInfo.fileName + ":" + jsFrameInfo.pos;
|
||||
ECMA_BYTRACE_NAME(HITRACE_TAG_ARK, strTrace);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
EXECUTE_JOB_HITRACE(pendingJob);
|
||||
|
||||
|
@ -48,7 +48,8 @@ enum ArkProperties {
|
||||
CPU_PROFILER_COLD_START_WORKER_THREAD = 1 << 16,
|
||||
CPU_PROFILER_ANY_TIME_MAIN_THREAD = 1 << 17,
|
||||
CPU_PROFILER_ANY_TIME_WORKER_THREAD = 1 << 18,
|
||||
ENABLE_HEAP_VERIFY = 1 << 19
|
||||
ENABLE_HEAP_VERIFY = 1 << 19,
|
||||
ENABLE_MICROJOB_TRACE = 1 << 20
|
||||
};
|
||||
|
||||
// asm interpreter control parsed option
|
||||
@ -540,6 +541,11 @@ public:
|
||||
return (static_cast<uint32_t>(arkProperties_) & ArkProperties::ENABLE_HEAP_VERIFY) != 0;
|
||||
}
|
||||
|
||||
bool EnableMicroJobTrace() const
|
||||
{
|
||||
return (static_cast<uint32_t>(arkProperties_) & ArkProperties::ENABLE_MICROJOB_TRACE) != 0;
|
||||
}
|
||||
|
||||
void DisableReportModuleResolvingFailure()
|
||||
{
|
||||
reportModuleResolvingFailure_ = false;
|
||||
|
Loading…
Reference in New Issue
Block a user