mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-27 12:10:47 +00:00
fix cpu profiler message and support option to control interpreter, runtime tag
Signed-off-by: linxiang8 <linxiang8@huawei.com> Change-Id: I5cedf2771ddc23c878bb64544d37d099242c781e
This commit is contained in:
parent
6dd7d9c0de
commit
7a9ae32aa7
48
ecmascript/builtins/builtins_method_index.h
Normal file
48
ecmascript/builtins/builtins_method_index.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ECMASCRIPT_BUILTINS_BUILTINS_METHOD_INDEX_H
|
||||
#define ECMASCRIPT_BUILTINS_BUILTINS_METHOD_INDEX_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace panda::ecmascript {
|
||||
enum class MethodIndex : uint8_t {
|
||||
BUILTINS_GLOBAL_CALL_JS_BOUND_FUNCTION = 0,
|
||||
BUILTINS_GLOBAL_CALL_JS_PROXY,
|
||||
BUILTINS_OBJECT_CREATE_DATA_PROPERTY_ON_OBJECT_FUNCTIONS,
|
||||
BUILTINS_COLLATOR_ANONYMOUS_COLLATOR,
|
||||
BUILTINS_DATE_TIME_FORMAT_ANONYMOUS_DATE_TIME_FORMAT,
|
||||
BUILTINS_NUMBER_FORMAT_NUMBER_FORMAT_INTERNAL_FORMAT_NUMBER,
|
||||
BUILTINS_PROXY_INVALIDATE_PROXY_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_ASYNC_AWAIT_FULFILLED,
|
||||
BUILTINS_PROMISE_HANDLER_ASYNC_AWAIT_REJECTED,
|
||||
BUILTINS_PROMISE_HANDLER_RESOLVE_ELEMENT_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_RESOLVE,
|
||||
BUILTINS_PROMISE_HANDLER_REJECT,
|
||||
BUILTINS_PROMISE_HANDLER_EXECUTOR,
|
||||
BUILTINS_PROMISE_HANDLER_ANY_REJECT_ELEMENT_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_ALL_SETTLED_RESOLVE_ELEMENT_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_ALL_SETTLED_REJECT_ELEMENT_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_THEN_FINALLY_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_CATCH_FINALLY_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_VALUE_THUNK_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_THROWER_FUNCTION,
|
||||
BUILTINS_ASYNC_GENERATOR_NEXT_FULFILLED_FUNCTION,
|
||||
BUILTINS_ASYNC_GENERATOR_NEXT_REJECTED_FUNCTION,
|
||||
METHOD_END
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
#endif // ECMASCRIPT_BUILTINS_BUILTINS_METHOD_INDEX_H
|
@ -33,6 +33,7 @@ CMap<pthread_t, const EcmaVM *> CpuProfiler::profilerMap_ = CMap<pthread_t, cons
|
||||
CpuProfiler::CpuProfiler(const EcmaVM *vm, const int interval) : vm_(vm), interval_(interval)
|
||||
{
|
||||
generator_ = new SamplesRecord();
|
||||
generator_->SetEnableVMTag(const_cast<EcmaVM *>(vm)->GetJSOptions().EnableCpuProfilerVMTag());
|
||||
if (generator_->SemInit(0, 0, 0) != 0) {
|
||||
LOG_ECMA(ERROR) << "sem_[0] init failed";
|
||||
}
|
||||
@ -467,32 +468,7 @@ void CpuProfiler::GetNativeStack(const FrameIterator &it, char *functionName, si
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (extraInfoValue.CheckIsJSNativePointer()) {
|
||||
stream << JSNativePointer::Cast(extraInfoValue.GetTaggedObject())->GetExternalPointer();
|
||||
CheckAndCopy(functionName, size, methodNameStr.c_str());
|
||||
const uint8_t methodNameStrLength = methodNameStr.size();
|
||||
CheckAndCopy(functionName + methodNameStrLength, size - methodNameStrLength, "(");
|
||||
const uint8_t arkuiBeginLength = 1; // 1:the length of "("
|
||||
CheckAndCopy(functionName + methodNameStrLength + arkuiBeginLength,
|
||||
size - methodNameStrLength - arkuiBeginLength, stream.str().c_str());
|
||||
uint8_t srcLength = stream.str().size();
|
||||
CheckAndCopy(functionName + methodNameStrLength + arkuiBeginLength + srcLength,
|
||||
size - methodNameStrLength - arkuiBeginLength - srcLength, ")");
|
||||
return;
|
||||
}
|
||||
// builtin method
|
||||
auto method = it.CheckAndGetMethod();
|
||||
auto addr = method->GetNativePointer();
|
||||
stream << addr;
|
||||
CheckAndCopy(functionName, size, methodNameStr.c_str());
|
||||
const uint8_t methodNameStrLength = methodNameStr.size();
|
||||
CheckAndCopy(functionName + methodNameStrLength, size - methodNameStrLength, "(");
|
||||
const uint8_t builtinBeginLength = 1; // 1:the length of "("
|
||||
CheckAndCopy(functionName + methodNameStrLength + builtinBeginLength,
|
||||
size - methodNameStrLength - builtinBeginLength, stream.str().c_str());
|
||||
uint8_t srcLength = stream.str().size();
|
||||
CheckAndCopy(functionName + builtinBeginLength + methodNameStrLength + srcLength,
|
||||
size - builtinBeginLength - methodNameStrLength - srcLength, ")");
|
||||
}
|
||||
|
||||
void CpuProfiler::GetStackBeforeCallNapi(JSThread *thread, const std::string &methodAddr)
|
||||
|
@ -385,11 +385,20 @@ std::string SamplesRecord::AddRunningStateToName(char *functionName, RunningStat
|
||||
case RunningState::GC:
|
||||
return temp.append("(GC)");
|
||||
case RunningState::CINT:
|
||||
return temp.append("(CINT)");
|
||||
if (enableVMTag_) {
|
||||
return temp.append("(CINT)");
|
||||
}
|
||||
return temp.append("");
|
||||
case RunningState::AINT:
|
||||
return temp.append("(AINT)");
|
||||
if (enableVMTag_) {
|
||||
return temp.append("(AINT)");
|
||||
}
|
||||
return temp.append("");
|
||||
case RunningState::AOT:
|
||||
return temp.append("(AOT)");
|
||||
if (enableVMTag_) {
|
||||
return temp.append("(AOT)");
|
||||
}
|
||||
return temp.append("");
|
||||
case RunningState::BUILTIN:
|
||||
return temp.append("(BUILTIN)");
|
||||
case RunningState::NAPI:
|
||||
@ -397,7 +406,10 @@ std::string SamplesRecord::AddRunningStateToName(char *functionName, RunningStat
|
||||
case RunningState::ARKUI_ENGINE:
|
||||
return temp.append("(ARKUI_ENGINE)");
|
||||
case RunningState::RUNTIME:
|
||||
return temp.append("(RUNTIME)");
|
||||
if (enableVMTag_) {
|
||||
return temp.append("(RUNTIME)");
|
||||
}
|
||||
return temp.append("");
|
||||
default:
|
||||
return temp.append("(OTHER)");
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ struct ProfileInfo {
|
||||
|
||||
struct FrameInfoTemp {
|
||||
char codeType[20] = {0}; // 20:the maximum size of the codeType
|
||||
char functionName[50] = {0}; // 50:the maximum size of the functionName
|
||||
char functionName[100] = {0}; // 50:the maximum size of the functionName
|
||||
int columnNumber = 0;
|
||||
int lineNumber = 0;
|
||||
int scriptId = 0;
|
||||
@ -165,6 +165,11 @@ public:
|
||||
void FinetuneTimeDeltas(size_t idx, uint64_t napiTime, uint64_t &sampleTime, bool isEndSample);
|
||||
std::ofstream fileHandle_;
|
||||
|
||||
void SetEnableVMTag(bool flag)
|
||||
{
|
||||
enableVMTag_ = flag;
|
||||
}
|
||||
|
||||
private:
|
||||
void StringifyStateTimeStatistic();
|
||||
void StringifyNodes();
|
||||
@ -202,6 +207,7 @@ private:
|
||||
CVector<FrameInfoTemp> napiFrameInfoTemps_;
|
||||
CVector<uint64_t> napiCallTimeVec_;
|
||||
CVector<std::string> napiCallAddrVec_;
|
||||
bool enableVMTag_ {false};
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
#endif // ECMASCRIPT_SAMPLES_RECORD_H
|
@ -17,6 +17,7 @@
|
||||
#define ECMASCRIPT_ECMA_VM_H
|
||||
|
||||
#include "ecmascript/base/config.h"
|
||||
#include "ecmascript/builtins/builtins_method_index.h"
|
||||
#include "ecmascript/js_handle.h"
|
||||
#include "ecmascript/js_runtime_options.h"
|
||||
#include "ecmascript/js_thread.h"
|
||||
@ -83,32 +84,6 @@ class QuickFixManager;
|
||||
class ConstantPool;
|
||||
class OptCodeProfiler;
|
||||
|
||||
enum class MethodIndex : uint8_t {
|
||||
BUILTINS_GLOBAL_CALL_JS_BOUND_FUNCTION = 0,
|
||||
BUILTINS_GLOBAL_CALL_JS_PROXY,
|
||||
BUILTINS_OBJECT_CREATE_DATA_PROPERTY_ON_OBJECT_FUNCTIONS,
|
||||
BUILTINS_COLLATOR_ANONYMOUS_COLLATOR,
|
||||
BUILTINS_DATE_TIME_FORMAT_ANONYMOUS_DATE_TIME_FORMAT,
|
||||
BUILTINS_NUMBER_FORMAT_NUMBER_FORMAT_INTERNAL_FORMAT_NUMBER,
|
||||
BUILTINS_PROXY_INVALIDATE_PROXY_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_ASYNC_AWAIT_FULFILLED,
|
||||
BUILTINS_PROMISE_HANDLER_ASYNC_AWAIT_REJECTED,
|
||||
BUILTINS_PROMISE_HANDLER_RESOLVE_ELEMENT_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_RESOLVE,
|
||||
BUILTINS_PROMISE_HANDLER_REJECT,
|
||||
BUILTINS_PROMISE_HANDLER_EXECUTOR,
|
||||
BUILTINS_PROMISE_HANDLER_ANY_REJECT_ELEMENT_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_ALL_SETTLED_RESOLVE_ELEMENT_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_ALL_SETTLED_REJECT_ELEMENT_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_THEN_FINALLY_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_CATCH_FINALLY_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_VALUE_THUNK_FUNCTION,
|
||||
BUILTINS_PROMISE_HANDLER_THROWER_FUNCTION,
|
||||
BUILTINS_ASYNC_GENERATOR_NEXT_FULFILLED_FUNCTION,
|
||||
BUILTINS_ASYNC_GENERATOR_NEXT_REJECTED_FUNCTION,
|
||||
METHOD_END
|
||||
};
|
||||
|
||||
enum class IcuFormatterType {
|
||||
SimpleDateFormatDefault,
|
||||
SimpleDateFormatDate,
|
||||
|
@ -43,6 +43,7 @@ enum ArkProperties {
|
||||
GLOBAL_PRIMITIVE_LEAK_CHECK = 1 << 11,
|
||||
ENABLE_IDLE_GC = 1 << 12, // default enable
|
||||
CPU_PROFILER = 1 << 13,
|
||||
ENABLE_CPU_PROFILER_VM_TAG = 1 << 14,
|
||||
};
|
||||
|
||||
// asm interpreter control parsed option
|
||||
@ -351,6 +352,11 @@ public:
|
||||
return (static_cast<uint32_t>(arkProperties_) & ArkProperties::CPU_PROFILER) != 0;
|
||||
}
|
||||
|
||||
bool EnableCpuProfilerVMTag() const
|
||||
{
|
||||
return (static_cast<uint32_t>(arkProperties_) & ArkProperties::ENABLE_CPU_PROFILER_VM_TAG) != 0;
|
||||
}
|
||||
|
||||
bool IsStartGlobalLeakCheck() const
|
||||
{
|
||||
return startGlobalLeakCheck_;
|
||||
|
Loading…
Reference in New Issue
Block a user