mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-27 12:10:47 +00:00
Support skip aot function where too many deopts occur
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I662CB Signed-off-by: xujie <xujie101@huawei.com> Change-Id: Ie7195f725ee4cd4b917e436046e9faafcbf8e84b
This commit is contained in:
parent
b0343f5d9d
commit
b6d01825e0
@ -646,6 +646,7 @@ void AOTFileManager::SetAOTMainFuncEntry(JSHandle<JSFunction> mainFunc, const JS
|
||||
mainMethod->SetAotCodeBit(true);
|
||||
mainMethod->SetNativeBit(false);
|
||||
Method *method = mainFunc->GetCallTarget();
|
||||
method->SetDeoptThreshold(vm_->GetJSOptions().GetDeoptThreshold());
|
||||
method->SetCodeEntryAndMarkAOT(reinterpret_cast<uintptr_t>(mainEntry));
|
||||
#ifndef NDEBUG
|
||||
PrintAOTEntry(jsPandaFile, method, mainEntry);
|
||||
@ -664,6 +665,7 @@ void AOTFileManager::SetAOTFuncEntry(const JSPandaFile *jsPandaFile, Method *met
|
||||
if (!codeEntry) {
|
||||
return;
|
||||
}
|
||||
method->SetDeoptThreshold(vm_->GetJSOptions().GetDeoptThreshold());
|
||||
method->SetCodeEntryAndMarkAOT(codeEntry);
|
||||
}
|
||||
|
||||
|
@ -244,6 +244,13 @@ JSTaggedType Deoptimizier::ConstructAsmInterpretFrame()
|
||||
auto method = GetMethod(callTarget);
|
||||
Dump(method);
|
||||
ASSERT(thread_ != nullptr);
|
||||
uint16_t deoptThreshold = method->GetDeoptThreshold();
|
||||
if (deoptThreshold > 0) {
|
||||
method->SetDeoptThreshold(--deoptThreshold);
|
||||
} else {
|
||||
method->SetAotCodeBit(false);
|
||||
method->SetCodeEntryOrLiteral(reinterpret_cast<uintptr_t>(nullptr));
|
||||
}
|
||||
|
||||
FrameWriter frameWriter(this);
|
||||
// Push asm interpreter frame
|
||||
|
@ -58,6 +58,7 @@ const std::string PUBLIC_API HELP_OPTION_MSG =
|
||||
"--enable-ark-tools: Enable ark tools to debug. Default: false\n"
|
||||
"--trace-bc: enable tracing bytecode for aot runtime. Default: false\n"
|
||||
"--trace-deopt: enable tracing deopt for aot runtime. Default: false\n"
|
||||
"--deopt-threshold: set max count which aot function can occur deoptimization. Default: 10\n"
|
||||
"--enable-cpuprofiler: Enable cpuprofiler to sample call stack and output to json file. Default: false\n"
|
||||
"--enable-force-gc: enable force gc when allocating object. Default: true\n"
|
||||
"--enable-ic: switch of inline cache. Default: true\n"
|
||||
@ -126,6 +127,7 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv)
|
||||
{"enable-ark-tools", required_argument, nullptr, OPTION_ENABLE_ARK_TOOLS},
|
||||
{"trace-bc", required_argument, nullptr, OPTION_TRACE_BC},
|
||||
{"trace-deopt", required_argument, nullptr, OPTION_TRACE_DEOPT},
|
||||
{"deopt-threshold", required_argument, nullptr, OPTION_DEOPT_THRESHOLD},
|
||||
{"enable-cpuprofiler", required_argument, nullptr, OPTION_ENABLE_CPUPROFILER},
|
||||
{"enable-force-gc", required_argument, nullptr, OPTION_ENABLE_FORCE_GC},
|
||||
{"enable-ic", required_argument, nullptr, OPTION_ENABLE_IC},
|
||||
|
@ -88,6 +88,7 @@ enum CommandValues {
|
||||
OPTION_BUILTINS_DTS,
|
||||
OPTION_TRACE_BC,
|
||||
OPTION_TRACE_DEOPT,
|
||||
OPTION_DEOPT_THRESHOLD,
|
||||
OPTION_LOG_LEVEL,
|
||||
OPTION_LOG_DEBUG,
|
||||
OPTION_LOG_INFO,
|
||||
@ -821,6 +822,16 @@ public:
|
||||
{
|
||||
return traceDeopt_;
|
||||
}
|
||||
|
||||
void SetDeoptThreshold(uint16_t value)
|
||||
{
|
||||
deoptThreshold_ = value;
|
||||
}
|
||||
|
||||
uint32_t GetDeoptThreshold() const
|
||||
{
|
||||
return deoptThreshold_;
|
||||
}
|
||||
private:
|
||||
static bool StartsWith(const std::string &haystack, const std::string &needle)
|
||||
{
|
||||
@ -889,6 +900,7 @@ private:
|
||||
uint32_t pgoHotnessThreshold_ {2};
|
||||
std::string pgoProfilerPath_ {""};
|
||||
bool traceDeopt_{false};
|
||||
uint32_t deoptThreshold_ {10};
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
|
||||
|
@ -213,8 +213,10 @@ public:
|
||||
|
||||
static constexpr size_t BUILTINID_NUM_BITS = 8;
|
||||
static constexpr size_t FUNCTION_KIND_NUM_BITS = 4;
|
||||
static constexpr size_t DEOPT_THRESHOLD_BITS = 16;
|
||||
using BuiltinIdBits = BitField<uint8_t, 0, BUILTINID_NUM_BITS>; // offset 0-7
|
||||
using FunctionKindBits = BuiltinIdBits::NextField<FunctionKind, FUNCTION_KIND_NUM_BITS>; // offset 8-11
|
||||
using DeoptCountBits = FunctionKindBits::NextField<uint16_t, DEOPT_THRESHOLD_BITS>; // offset 12-28
|
||||
|
||||
inline NO_THREAD_SANITIZE void SetHotnessCounter(int16_t counter)
|
||||
{
|
||||
@ -308,6 +310,16 @@ public:
|
||||
return BuiltinIdBits::Update(literalInfo, id);
|
||||
}
|
||||
|
||||
static uint64_t SetDeoptThreshold(uint64_t literalInfo, uint16_t count)
|
||||
{
|
||||
return DeoptCountBits::Update(literalInfo, count);
|
||||
}
|
||||
|
||||
static uint16_t GetDeoptThreshold(uint64_t literalInfo)
|
||||
{
|
||||
return DeoptCountBits::Decode(literalInfo);
|
||||
}
|
||||
|
||||
static uint32_t PUBLIC_API GetNumVregs(const JSPandaFile *jsPandaFile, const MethodLiteral *methodLiteral);
|
||||
static const char * PUBLIC_API GetMethodName(const JSPandaFile *jsPandaFile, EntityId methodId);
|
||||
static std::string PUBLIC_API ParseFunctionName(const JSPandaFile *jsPandaFile, EntityId methodId);
|
||||
|
@ -200,6 +200,19 @@ public:
|
||||
SetExtraLiteralInfo(newValue);
|
||||
}
|
||||
|
||||
void SetDeoptThreshold(uint16_t count)
|
||||
{
|
||||
uint64_t extraLiteralInfo = GetExtraLiteralInfo();
|
||||
uint64_t newValue = MethodLiteral::SetDeoptThreshold(extraLiteralInfo, count);
|
||||
SetExtraLiteralInfo(newValue);
|
||||
}
|
||||
|
||||
uint16_t GetDeoptThreshold() const
|
||||
{
|
||||
uint64_t extraLiteralInfo = GetExtraLiteralInfo();
|
||||
return MethodLiteral::GetDeoptThreshold(extraLiteralInfo);
|
||||
}
|
||||
|
||||
const void* GetNativePointer() const
|
||||
{
|
||||
return GetNativePointerOrBytecodeArray();
|
||||
|
Loading…
Reference in New Issue
Block a user