mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
e68673a13f
add baseline builtins Change-Id: Ib8d7c392c62e21eab19b17e45c0fafb499cbbed9 support running baseline compiler by option --compiler-force-baseline-compile-main=true Change-Id: I7c7337faf9fad39ccffb2de28d46403e2f6cb22b baseline jit part3 Change-Id: I36e8dd6a6fa6fffb738029a8620bbcd01df1e017 baseline part4 Change-Id: Ib45bcf7255a85aa48f864a6021adf819927e6a13 baseline part5 move baseline into compiler folder Change-Id: Ia8781c95ae00c4f300e7267a6da0078b5d04e4c8 !185 support BaselinePrologue * support BaselinePrologue part3 * support BaselinePrologue part2 * support BaselinePrologue !187 [BaselineJit] support load baseline builtins * [BaselineJit]support load baseline builtins !186[BaselineJIT] workaround for baselinejit support install code * install code part3 * install code part2 * baseline jit support intall code !188 [BaselineJit] support CallBuiltin * [BaselineJit] baseline support CallBuiltin !189 [BaselineJIT]implement StackOffset class * [BaselineJIT]implement StackOffset class !190 [BaselineJIT]refactor BaselineAssembler and MacroAssembler * [BaselineJIT]refactor BaselineAssembler and MacroAssembler !191 [BaselineJIT] refactor class BaselineCompiler * [BaselineJIT] refactor class BaselineCompiler !192 [BaselineJIT] callbuiltin support new parameter type new parameter type: int32_t,SpecialParameter,VirtualRegister !193 [BaselineJIT]modify BaselineLoadObjByName function * [BaselineJIT]modify BaselineLoadObjByName function !194 [BaselineJIT] support new builtins * [BaselineJIT] add BaselineTryLdGLobalByNameImm8ID16, BaselineStToGlobalRecordImm16ID16, BaselineLdaStrID16 !196 [BaselineJIT]bugfix for BaselinePrologue, align the rsp * [BaselineJIT]bugfix for BaselinePrologue, align the rsp !197 [BaselineJIT]bugfix for StackOffsetDescriptor * [BaselineJIT]bugfix for StackOffsetDescriptor !198 [BaselineJIT]workaround for helloworld testcase, helloworld can run successfully * workaround for helloworld testcase, helloworld can run successfully !200 [BaselineJIT]adapt profile collection * [BaselineJIT]adapt profile collection !201 [BaselineJIT]refactor baseline jit * [BaselineJIT]refactor baseline jit !203 [BaselineJIT]support trigger BaselineJITCompile and call baselinecode async * [BaselineJIT]support trigger BaselineJITCompile and call baselinecode async !202 [BaselineJIT]enable update hotness * [BaselineJIT]enable update hotness !205 [BaselineJIT]adapt JSCallDispatch interface * [BaselineJIT]adapt JSCallDispatch interface Change-Id: I4efce4346f985c7e074d7fc4bbfe3b081272e950 !195 [Baseline JIT] bytecode to builtin funs * !206 enable bytecode builtins and call CHECK_PENDING_EXCEPTION * [Baseline JIT] builtins:StobjbynameImm9Id16V8,StobjbynameImm16Id16V8,S… * [Baseline JIT] builtins:CopyrestargsImm8,LdlexvarImm4Imm4,StlexvarImm4… * [Baseline JIT] builtins: LdsuperbyvalueImm8V8,LdsuperbyvalueImm16V8,St… * [Baseline JIT] builtins: DelobjpropV8,AsyncfunctionawaituncaughtV8,Cop… * !204 enable bytecode builtins * [Baseline JIT] builtins: DefineclasswithbufferImm8Id16Id16Imm16V8,Defi… * [Baseline JIT] builtins: LdthisbynameImm8Id16,Definegettersetterbyval… * [Baseline JIT] builtins: Callarg0Imm8,SupercallspreadImm8V8,ApplyImm8V… * !199 enable bytecode builtin func * [Baseline JIT] builtins: StrictnoteqImm8V8,StricteqImm8V8,Istrue,Isfal… * [Baseline JIT] builtins: NegImm8,NotImm8,IncImm8,DecImm8,IsinImm8V8,In… * [Baseline JIT] builtins: And2Imm8V8,Or2Imm8V8,Xor2Imm8V8,ExpImm8V8,Typ… * [Baseline JIT] builtins:LessImm8V8,LesseqImm8V8,GreaterImm8V8,Greatere… * [Baseline JIT] builtins:Add2Imm8V8,SUB2_IMM8_V8,MUL2_IMM8_V8,DIV2_IMM8… * [Baseline JIT] builtins:CreateobjectwithbufferImm8Id16,Createobjectwit… * [Baseline JIT]builtins:Createemptyobject,CreateemptyarrayImm8,Createem… * [Baseline JIT] builtins:GetiteratorImm16,Asyncfunctionenter,Createasyn… * [Baseline JIT] builtins:ldsymbol,ldglobal,Poplexenv,Getunmappedargs,Ge… * [BaselineJIT] builtins: add base class !209 handle opcode in baseline compiler * handle opcode in baseline compiler !210 [baseline jit]: add baseline stub call signature target kind info * [baseline jit]: add baseline stub call signature target kind info !212 [BaselineJIT]baseline builtin bugfix * [BaselineJIT]baseline builtin bugfix !207 [BaselineJIT]support BaselineBuiltinFrame * [BaselineJIT]support BaselineBuiltinFrame !214 [BaselineJIT]baseline builtin bugfix of using JSCallDispatch * [BaselineJIT]baseline builtin bugfix JSCallDispatch Change-Id: Id67b991df5dee753a38c284234d15b02f0d8a091 !215 [BaselineJIT]bugfix for StackOffsetDescriptor * [BaselineJIT]bugfix for StackOffsetDescriptor !216 [baseline jit]update bytecode builtins * [baseline jit]update bytecode builtins !213 [BaselineJIT]support BaselineReturn and BaselineReturnundefined * [BaselineJIT]support BaselineReturn and BaselineReturnundefined !218 [BaselineJIT]baseline builtin * [BaselineJIT]baseline builtin:ldfunction,ldthis,asyncgeneratorresolvev… !217 parse baseline-jit bytecode v1.0 * parse bytecode in baseline-jit !220 [BaselineJIT]baseline refactor ParameterIndex * [BaselineJIT]baseline refactor ParameterIndex !223 [BaselineJIT]get function and method from stack, avoiding method is used after call * [BaselineJIT]get function and method from stack, avoiding method is us… !224 [BaselineJIT]bugfix for compiling x64.release * [BaselineJIT]bugfix for compiling x64.release !226 [BaselineJIT] adapt gc for BASELINE_BUILTIN_FRAME type * [BaselineJIT]adapt gc for BASELINE_BUILTIN_FRAME type !222 [BaselineJIT] parse baseline builtin args * [BaselineJIT] parse baseline builtin args:part 2 * [BaselineJIT] parse baseline builtin args !229 parse baseline-jit bytecode v2.0 * [BaselineJIT] parse bytecode v2.0 !230 [BaselineJIT] remove including undefined_function file * [BaselineJIT] remove including undefined_function file !228 handle byte opcode of jmp v2 * [baseline jit]handle opcode of jmp V2 [BaselineJIT]rebase bugfix Change-Id: I078298849139317dfa89fb139979c1b7d938b344 !231 [BaselineJIT] fix bugs about reading bytecode * [BaselineJIT] fix bugs about read bytecode !232 [BaselineJIT] fix bug about processing arguments in stub * [BaselineJIT] fix bug about processing argument in baseline-stubs !233 handle int64_t type in CallBuiltin * [baseline jit]handle int64_t type in CallBuiltin !234 [BaselineJIT] fix bug for StToGlobalRecordImm16ID16 * [BaselineJIT] fix bug for StToGlobalRecordImm16ID16 !235 [BaselineJIT] fix bugs about args type * [BaselineJIT] fix type of args that passing to builtins !236 [BaselineJIT] do not pass constpool to builtins * [BaselineJIT] do not passing constpool to builtin Change-Id: I8c46d70527a3fedd841d28ac1908a02d4a66edeb !237 [baselineJit]Bugfix for sp used in JSCallDispatch and incorretc type * [baselineJit]Bugfix for sp used in JSCallDispatch and incorretc type Change-Id: I3f42ecd06266a20b2b145cfe98bcbd97a2848bab [BaselineJIT] dump_test bugfix Change-Id: I97d21960ca98cd1a6fc9b1e81b647ff9d8d5d0c2 [BaselineJIT]codecheck fix Change-Id: I93eb02e45b70f4a5bfee84fec0c8e2cdc765d348 code check bugfix part2 Change-Id: I8680dd2c098193705709691fa78e8e6f3ad8cd6c bugfix for review Change-Id: I49b28e109530b9f8b403ba22ba39948e02834021 [BaselineJIT]change file folder Change-Id: I1f46110a804f17270badcff7cdeb2058ca164161 [BaselineJIT]bugfix for review part2 Change-Id: I190406652697f9b17ac6c84dd706262046dbb5f7 !238 [BaselineJIT] fix more than 6 args builtins * [BaselineJIT] fix more than 6 args builtins !239 [BaselineJIT] fix bug in parsing CALLTHISRANGE_IMM8_IMM8_V8 * [BaselineJIT] fix bug in parsing CALLTHISRANGE_IMM8_IMM8_V8 !240 [BaselineJIT] fix bug and add NewobjrangeImm8Imm8V8,NewobjrangeImm16Imm8V8 * [BaselineJIT] fix bug and add NewobjrangeImm8Imm8V8,NewobjrangeImm16Imm8V8 !241 [BaselineJIT] fix bug of ldnan, ldinfinity * [BaselineJIT] fix bug of ldnan, ldinfinity !242 [BaselineJIT] return JSCallDispatch result * [BaselineJIT] return result of JSCallDispatch for baselinecode !245 [BaselineJIT] fix builtins return value * [BaselineJIT] fix builtins return value !244 [BaselineJIT] save result to acc * [BaselineJIT] save result to acc !243 Bugfix for StlexvarImm4Imm4 * [baselineJit]Bugfix for StlexvarImm4Imm4 !246 [BaselineJIT] remove ldfunction * [BaselineJIT] remove ldfunction !248 [BaselineJIT] save result of DEFINECLASSWITHBUFFER_IMM8_ID16_ID16_IMM16_V8 * [BaselineJIT] fix return !247 [baselineJit]Bugfix for Stlexvar and Ldlexvar * [baselineJit]Bugfix for Stlexvar and Ldlexvar !249 [BaselineJIT] Revert "!242[BaselineJIT] return JSCallDispatch result" * Revert "!242 [BaselineJIT] return JSCallDispatch result" !251 Bugfix for BaselineCreateobjectwithexcludedkeysImm8V8V8 * [baselineJit]Bugfix for BaselineCreateobjectwithexcludedkeysImm8V8V8 !252 [baselineJit]Bugfix for notException branch * [baselineJit]Bugfix for notException branch !250 [BaselineJIT] save result to acc in JSCallDispatch for baselinemethodcode * [BaselineJIT] save result of JSCallDispatch to acc for baselinecode !254 [BaselineJIT] fix type bug * [BaselineJIT] fix type bug !255 [BaselineJIT] fix bug of LDAI_IMM32 * [BaselineJIT] fix bug of LDAI_IMM32 !253 Bugfix for Poplexenv * [baselineJit]Bugfix for Poplexenv !256 [BaselineJIT] fix pc & refractor jscalldispatch for baseline-jit * [BaselineJIT] fix pc of baseline-jit & refactor jscalldispatch for baseline-jit !257 [BaselineJIT] replace indirectly jscalldispatch with jscalldispatchforbaseline * [BaselineJIT] replace indirectly jscalldispatch with jscalldispatchforbaseline !258 [BaselineJIT] fix using shl2 builtin bug * [BaselineJIT] fix using shl2 builtin bug !259 Bugfix and enable BaselineIstrue and BaselineIsFalse * [baselineJit]Bugfix and enable BaselineIstrue and BaselineIsFalse !260 [BaselineJIT] fix bug about passing FUNC parameter * [BaselineJIT] fix bug about passing FUNC parameter !261 [BaselineJIT] support passing parameters by stack and fix offset param bug * [BaselineJIT] support passing parameters by stack and fix offset param bug !263 [BaselineJIT] fix parameters bug of LdobjbyvalueImm16V8 & StobjbyvalueImm16V8V8 * [BaselineJIT] fix parameters bug of LdobjbyvalueImm16V8 & StobjbyvalueImm16V8V8 !262 Bugfix for jump offset * [baselineJit]Bugfix for jump offset !264 [BaselineJIT] fix intermediates v8 parameters bug * [BaselineJIT] fix intermediates v8 parameters bug Change-Id: I8bf4fdf7621770a1976925423de23693570365c9 !267 [BaselineJIT] fix bug of BaselineInstanceofImm8V8 * [BaselineJIT] fix bug of BaselineInstanceofImm8V8 !269 [BaselineJIT] support NEWOBJRANGE_IMM16_IMM8_V8 & fix calling DefineMethod runtimeStub * [BaselineJIT] support NEWOBJRANGE_IMM16_IMM8_V8 & fix calling DefineMe… !268 [BaselineJIT]support update hotness * [BaselineJIT]enable update hotness part2 * [BaselineJIT]support update hotness Change-Id: I24b02a9e015df7263b1e9d7210377add0bfc558c CI bugfix Change-Id: I2d5aef07a1f14b3c64585790cff99d64be0d6396 Signed-off-by: w00443755 <wangzhilei2@huawei.com>
465 lines
14 KiB
C++
465 lines
14 KiB
C++
/*
|
|
* Copyright (c) 2022 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_METHOD_H
|
|
#define ECMASCRIPT_METHOD_H
|
|
|
|
#include "ecmascript/ecma_macros.h"
|
|
#include "ecmascript/jspandafile/method_literal.h"
|
|
#include "ecmascript/js_tagged_value.h"
|
|
#include "ecmascript/mem/barriers.h"
|
|
#include "ecmascript/mem/c_string.h"
|
|
#include "ecmascript/mem/visitor.h"
|
|
|
|
#include "libpandafile/file.h"
|
|
|
|
namespace panda::ecmascript {
|
|
class JSPandaFile;
|
|
struct Reference;
|
|
using EntityId = panda_file::File::EntityId;
|
|
class Method : public TaggedObject {
|
|
public:
|
|
CAST_CHECK(Method, IsMethod);
|
|
|
|
uint64_t SetNumArgsWithCallField(uint64_t callField, uint32_t numargs)
|
|
{
|
|
return NumArgsBits::Update(callField, numargs);
|
|
}
|
|
|
|
uint64_t SetNativeBit(uint64_t callField, bool isNative)
|
|
{
|
|
return IsNativeBit::Update(callField, isNative);
|
|
}
|
|
|
|
uint64_t SetAotCodeBit(uint64_t callField, bool isCompiled)
|
|
{
|
|
return IsAotCodeBit::Update(callField, isCompiled);
|
|
}
|
|
|
|
uint64_t SetFastBuiltinBit(uint64_t callField, bool isFastBuiltin)
|
|
{
|
|
return IsFastBuiltinBit::Update(callField, isFastBuiltin);
|
|
}
|
|
|
|
static bool HaveThisWithCallField(uint64_t callField)
|
|
{
|
|
return HaveThisBit::Decode(callField);
|
|
}
|
|
|
|
static bool HaveNewTargetWithCallField(uint64_t callField)
|
|
{
|
|
return HaveNewTargetBit::Decode(callField);
|
|
}
|
|
|
|
bool HaveExtraWithCallField(uint64_t callField)
|
|
{
|
|
return HaveExtraBit::Decode(callField);
|
|
}
|
|
|
|
static bool HaveFuncWithCallField(uint64_t callField)
|
|
{
|
|
return HaveFuncBit::Decode(callField);
|
|
}
|
|
|
|
bool IsNativeWithCallField(uint64_t callField) const
|
|
{
|
|
return IsNativeBit::Decode(callField);
|
|
}
|
|
|
|
bool OnlyHaveThisWithCallField(uint64_t callField) const
|
|
{
|
|
return (callField & CALL_TYPE_MASK) == 1; // 1: the first bit of callFiled is HaveThisBit
|
|
}
|
|
|
|
bool OnlyHaveNewTagetAndThisWithCallField(uint64_t callField) const
|
|
{
|
|
return (callField & CALL_TYPE_MASK) == 0b11; // the first two bit of callFiled is `This` and `NewTarget`
|
|
}
|
|
|
|
static uint32_t GetNumArgsWithCallField(uint64_t callField)
|
|
{
|
|
return NumArgsBits::Decode(callField);
|
|
}
|
|
|
|
static uint64_t SetCallNapi(uint64_t extraLiteralInfo, bool isCallNapi)
|
|
{
|
|
return IsCallNapiBit::Update(extraLiteralInfo, isCallNapi);
|
|
}
|
|
|
|
static bool IsCallNapi(uint64_t extraLiteralInfo)
|
|
{
|
|
return IsCallNapiBit::Decode(extraLiteralInfo);
|
|
}
|
|
|
|
static uint64_t SetIsFastCall(uint64_t callField, bool isFastCall)
|
|
{
|
|
return IsFastCallBit::Update(callField, isFastCall);
|
|
}
|
|
|
|
static bool IsFastCall(uint64_t callField)
|
|
{
|
|
return IsFastCallBit::Decode(callField);
|
|
}
|
|
|
|
void SetNumArgsWithCallField(uint32_t numargs)
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
uint64_t newValue = SetNumArgsWithCallField(callField, numargs);
|
|
SetCallField(newValue);
|
|
}
|
|
|
|
void SetNativeBit(bool isNative)
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
uint64_t newValue = SetNativeBit(callField, isNative);
|
|
SetCallField(newValue);
|
|
}
|
|
|
|
void SetAotCodeBit(bool isCompiled)
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
uint64_t newValue = SetAotCodeBit(callField, isCompiled);
|
|
SetCallField(newValue);
|
|
}
|
|
|
|
void SetFastBuiltinBit(bool isFastBuiltin)
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
uint64_t newValue = SetFastBuiltinBit(callField, isFastBuiltin);
|
|
SetCallField(newValue);
|
|
}
|
|
|
|
bool HaveThisWithCallField() const
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
return HaveThisWithCallField(callField);
|
|
}
|
|
|
|
bool HaveNewTargetWithCallField() const
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
return HaveNewTargetWithCallField(callField);
|
|
}
|
|
|
|
bool HaveExtraWithCallField()
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
return HaveExtraWithCallField(callField);
|
|
}
|
|
|
|
bool HaveFuncWithCallField() const
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
return HaveFuncWithCallField(callField);
|
|
}
|
|
|
|
bool IsNativeWithCallField() const
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
return IsNativeWithCallField(callField);
|
|
}
|
|
|
|
bool IsAotWithCallField() const
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
return MethodLiteral::IsAotWithCallField(callField);
|
|
}
|
|
|
|
bool OnlyHaveThisWithCallField() const
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
return MethodLiteral::OnlyHaveThisWithCallField(callField);
|
|
}
|
|
|
|
bool OnlyHaveNewTagetAndThisWithCallField() const
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
return MethodLiteral::OnlyHaveNewTagetAndThisWithCallField(callField);
|
|
}
|
|
|
|
static uint32_t GetNumVregsWithCallField(uint64_t callField)
|
|
{
|
|
return NumVregsBits::Decode(callField);
|
|
}
|
|
|
|
uint32_t GetNumVregsWithCallField() const
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
return GetNumVregsWithCallField(callField);
|
|
}
|
|
|
|
uint32_t GetNumArgsWithCallField() const
|
|
{
|
|
uint64_t callField = GetCallField();
|
|
return MethodLiteral::GetNumArgsWithCallField(callField);
|
|
}
|
|
|
|
uint32_t GetNumArgs() const
|
|
{
|
|
return GetNumArgsWithCallField() + GetNumRevervedArgs();
|
|
}
|
|
|
|
uint32_t GetNumRevervedArgs() const
|
|
{
|
|
return HaveFuncWithCallField() +
|
|
HaveNewTargetWithCallField() + HaveThisWithCallField();
|
|
}
|
|
|
|
uint32_t GetNumberVRegs() const
|
|
{
|
|
return GetNumVregsWithCallField() + GetNumArgs();
|
|
}
|
|
|
|
inline int16_t GetHotnessCounter() const
|
|
{
|
|
uint64_t literalInfo = GetLiteralInfo();
|
|
return MethodLiteral::GetHotnessCounter(literalInfo);
|
|
}
|
|
|
|
inline NO_THREAD_SANITIZE void SetHotnessCounter(int16_t counter)
|
|
{
|
|
uint64_t literalInfo = GetLiteralInfo();
|
|
uint64_t newValue = MethodLiteral::SetHotnessCounter(literalInfo, counter);
|
|
SetLiteralInfo(newValue);
|
|
}
|
|
|
|
EntityId GetMethodId() const
|
|
{
|
|
uint64_t literalInfo = GetLiteralInfo();
|
|
return MethodLiteral::GetMethodId(literalInfo);
|
|
}
|
|
|
|
uint16_t GetSlotSize() const
|
|
{
|
|
uint64_t literalInfo = GetLiteralInfo();
|
|
return MethodLiteral::GetSlotSize(literalInfo);
|
|
}
|
|
|
|
uint8_t GetBuiltinId(uint64_t literalInfo) const
|
|
{
|
|
return BuiltinIdBits::Decode(literalInfo);
|
|
}
|
|
|
|
uint64_t SetBuiltinId(uint64_t literalInfo, uint8_t id)
|
|
{
|
|
return BuiltinIdBits::Update(literalInfo, id);
|
|
}
|
|
|
|
uint64_t SetFunctionKind(uint64_t extraLiteralInfo, FunctionKind kind)
|
|
{
|
|
return FunctionKindBits::Update(extraLiteralInfo, kind);
|
|
}
|
|
|
|
FunctionKind GetFunctionKind(uint64_t extraLiteralInfo) const
|
|
{
|
|
return static_cast<FunctionKind>(FunctionKindBits::Decode(extraLiteralInfo));
|
|
}
|
|
|
|
uint64_t SetDeoptThreshold(uint64_t literalInfo, uint8_t count)
|
|
{
|
|
return DeoptCountBits::Update(literalInfo, count);
|
|
}
|
|
|
|
uint16_t GetDeoptThreshold(uint64_t literalInfo) const
|
|
{
|
|
return DeoptCountBits::Decode(literalInfo);
|
|
}
|
|
|
|
uint64_t SetDeoptType(uint64_t extraLiteralInfo, kungfu::DeoptType type)
|
|
{
|
|
return DeoptTypeBits::Update(extraLiteralInfo, type);
|
|
}
|
|
|
|
void SetDeoptType(kungfu::DeoptType type)
|
|
{
|
|
uint64_t extraLiteralInfo = GetExtraLiteralInfo();
|
|
uint64_t newValue = SetDeoptType(extraLiteralInfo, type);
|
|
SetExtraLiteralInfo(newValue);
|
|
}
|
|
|
|
kungfu::DeoptType GetDeoptType(uint64_t extraLiteralInfo) const
|
|
{
|
|
return static_cast<kungfu::DeoptType>(DeoptTypeBits::Decode(extraLiteralInfo));
|
|
}
|
|
|
|
kungfu::DeoptType GetDeoptType() const
|
|
{
|
|
uint64_t extraLiteralInfo = GetExtraLiteralInfo();
|
|
return GetDeoptType(extraLiteralInfo);
|
|
}
|
|
|
|
void SetFunctionKind(FunctionKind kind)
|
|
{
|
|
uint64_t extraLiteralInfo = GetExtraLiteralInfo();
|
|
uint64_t newValue = SetFunctionKind(extraLiteralInfo, kind);
|
|
SetExtraLiteralInfo(newValue);
|
|
}
|
|
|
|
FunctionKind GetFunctionKind() const
|
|
{
|
|
uint64_t extraLiteralInfo = GetExtraLiteralInfo();
|
|
return GetFunctionKind(extraLiteralInfo);
|
|
}
|
|
|
|
uint8_t GetBuiltinId() const
|
|
{
|
|
uint64_t extraLiteralInfo = GetExtraLiteralInfo();
|
|
return GetBuiltinId(extraLiteralInfo);
|
|
}
|
|
|
|
void SetIsFastCall(bool isFastCall)
|
|
{
|
|
uint64_t callFiled = GetCallField();
|
|
uint64_t newValue = SetIsFastCall(callFiled, isFastCall);
|
|
SetCallField(newValue);
|
|
}
|
|
|
|
bool IsFastCall() const
|
|
{
|
|
uint64_t callFiled = GetCallField();
|
|
return IsFastCall(callFiled);
|
|
}
|
|
|
|
void SetCallNapi(bool isCallNapi)
|
|
{
|
|
uint64_t extraLiteralInfo = GetExtraLiteralInfo();
|
|
uint64_t newValue = SetCallNapi(extraLiteralInfo, isCallNapi);
|
|
SetExtraLiteralInfo(newValue);
|
|
}
|
|
|
|
bool IsCallNapi() const
|
|
{
|
|
uint64_t extraLiteralInfo = GetExtraLiteralInfo();
|
|
return IsCallNapi(extraLiteralInfo);
|
|
}
|
|
|
|
void SetBuiltinId(uint8_t id)
|
|
{
|
|
uint64_t extraLiteralInfo = GetExtraLiteralInfo();
|
|
uint64_t newValue = SetBuiltinId(extraLiteralInfo, id);
|
|
SetExtraLiteralInfo(newValue);
|
|
}
|
|
|
|
void SetDeoptThreshold(uint8_t count)
|
|
{
|
|
uint64_t extraLiteralInfo = GetExtraLiteralInfo();
|
|
uint64_t newValue = SetDeoptThreshold(extraLiteralInfo, count);
|
|
SetExtraLiteralInfo(newValue);
|
|
}
|
|
|
|
uint16_t GetDeoptThreshold() const
|
|
{
|
|
uint64_t extraLiteralInfo = GetExtraLiteralInfo();
|
|
return GetDeoptThreshold(extraLiteralInfo);
|
|
}
|
|
|
|
const void* GetNativePointer() const
|
|
{
|
|
return GetNativePointerOrBytecodeArray();
|
|
}
|
|
|
|
void SetNativePointer(void *nativePointer)
|
|
{
|
|
SetNativePointerOrBytecodeArray(nativePointer);
|
|
}
|
|
|
|
const uint8_t *GetBytecodeArray() const
|
|
{
|
|
return reinterpret_cast<const uint8_t *>(GetNativePointerOrBytecodeArray());
|
|
}
|
|
|
|
// add for AOT
|
|
void SetCodeEntryAndMarkAOTWhenBinding(uintptr_t codeEntry);
|
|
|
|
void ClearAOTStatusWhenDeopt();
|
|
|
|
void ClearAOTFlagsWhenInit();
|
|
|
|
void SetCompiledFuncEntry(uintptr_t codeEntry, bool isFastCall);
|
|
|
|
// jit code
|
|
bool IsJitCompiledCode() const;
|
|
void SetJitCompiledCode(bool flag);
|
|
void ClearJitCompiledCodeFlags();
|
|
|
|
bool CanSerializeCodeEntry() const;
|
|
|
|
static constexpr size_t Size()
|
|
{
|
|
return sizeof(Method);
|
|
}
|
|
|
|
const JSPandaFile *PUBLIC_API GetJSPandaFile() const;
|
|
uint32_t PUBLIC_API GetCodeSize() const;
|
|
MethodLiteral *PUBLIC_API GetMethodLiteral() const;
|
|
|
|
const char *PUBLIC_API GetMethodName() const;
|
|
const char *PUBLIC_API GetMethodName(const JSPandaFile *file) const;
|
|
std::string PUBLIC_API ParseFunctionName() const;
|
|
const CString GetRecordNameStr() const;
|
|
|
|
uint32_t FindCatchBlock(uint32_t pc) const;
|
|
|
|
/* callfield */
|
|
static constexpr size_t VREGS_ARGS_NUM_BITS = 28; // 28: maximum 268,435,455
|
|
static constexpr uint64_t AOT_FASTCALL_BITS = 0x5; // 0x5LU: aot and fastcall bit field
|
|
using HaveThisBit = BitField<bool, 0, 1>; // offset 0
|
|
using HaveNewTargetBit = HaveThisBit::NextFlag; // offset 1
|
|
using HaveExtraBit = HaveNewTargetBit::NextFlag; // offset 2
|
|
using HaveFuncBit = HaveExtraBit::NextFlag; // offset 3
|
|
using NumVregsBits = HaveFuncBit::NextField<uint32_t, VREGS_ARGS_NUM_BITS>; // offset 4-31
|
|
using NumArgsBits = NumVregsBits::NextField<uint32_t, VREGS_ARGS_NUM_BITS>; // offset 32-59
|
|
using IsNativeBit = NumArgsBits::NextFlag; // offset 60
|
|
using IsAotCodeBit = IsNativeBit::NextFlag; // offset 61
|
|
using IsFastBuiltinBit = IsAotCodeBit::NextFlag; // offset 62
|
|
using IsFastCallBit = IsFastBuiltinBit::NextFlag; // offset 63
|
|
|
|
/* ExtraLiteralInfo */
|
|
static constexpr size_t BUILTINID_NUM_BITS = 8;
|
|
static constexpr size_t FUNCTION_KIND_NUM_BITS = 4;
|
|
static constexpr size_t DEOPT_THRESHOLD_BITS = 8;
|
|
static constexpr size_t DEOPTTYPE_NUM_BITS = 8;
|
|
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<uint8_t, DEOPT_THRESHOLD_BITS>; // offset 12-19
|
|
using DeoptTypeBits = DeoptCountBits::NextField<kungfu::DeoptType, DEOPTTYPE_NUM_BITS>; // offset 20-27
|
|
using IsCallNapiBit = DeoptTypeBits::NextFlag; // offset 28
|
|
using IsJitCompiledCodeBit = IsCallNapiBit::NextFlag; // offset 29
|
|
|
|
static constexpr size_t CONSTANT_POOL_OFFSET = TaggedObjectSize();
|
|
ACCESSORS(ConstantPool, CONSTANT_POOL_OFFSET, CALL_FIELD_OFFSET)
|
|
ACCESSORS_PRIMITIVE_FIELD(CallField, uint64_t, CALL_FIELD_OFFSET, NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET)
|
|
// Native method decides this filed is NativePointer or BytecodeArray pointer.
|
|
ACCESSORS_NATIVE_FIELD(
|
|
NativePointerOrBytecodeArray, void, NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET, CODEENTRY_LITERAL_OFFSET)
|
|
ACCESSORS_PRIMITIVE_FIELD(CodeEntryOrLiteral, uintptr_t, CODEENTRY_LITERAL_OFFSET, LITERAL_INFO_OFFSET)
|
|
// hotness counter is encoded in a js method field, the first uint16_t in a uint64_t.
|
|
ACCESSORS_PRIMITIVE_FIELD(LiteralInfo, uint64_t, LITERAL_INFO_OFFSET, EXTRA_LITERAL_INFO_OFFSET)
|
|
ACCESSORS_PRIMITIVE_FIELD(ExtraLiteralInfo, uint64_t, EXTRA_LITERAL_INFO_OFFSET, LAST_OFFSET)
|
|
DEFINE_ALIGN_SIZE(LAST_OFFSET);
|
|
|
|
DECL_VISIT_OBJECT(CONSTANT_POOL_OFFSET, CALL_FIELD_OFFSET);
|
|
|
|
DECL_DUMP()
|
|
|
|
private:
|
|
static JSHandle<Method> Create(JSThread *thread, const JSPandaFile *jsPandaFile, MethodLiteral *methodLiteral);
|
|
|
|
friend class ObjectFactory;
|
|
};
|
|
} // namespace panda::ecmascript
|
|
|
|
#endif // ECMASCRIPT_METHOD_H
|