[Inline Call part2] Refactor Common Args Accessor

1. Modify JSBytecode and FramState opcode which have framestate in.
2. Changes the way common args are fetched during lowering.
3. Common args are no longer fetched from the stack during deopt.

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I6L28B
Signed-off-by: xujie <xujie101@huawei.com>
Change-Id: I1e26ad526209f27edc42aa2a5f364b1566ed4d26
This commit is contained in:
xujie 2023-03-27 17:23:59 +08:00
parent 6d277e7ffb
commit 6d377f01d8
28 changed files with 483 additions and 228 deletions

View File

@ -105,6 +105,8 @@ int Main(const int argc, const char **argv)
size_t maxAotMethodSize = runtimeOptions.GetMaxAotMethodSize();
bool isEnableTypeLowering = runtimeOptions.IsEnableTypeLowering();
bool isEnableOptInlining = runtimeOptions.IsEnableOptInlining();
bool isEnableTypeInfer = isEnableTypeLowering || vm->GetTSManager()->AssertTypes();
PassOptions passOptions(isEnableTypeLowering, isEnableTypeInfer, isEnableOptInlining);
uint32_t hotnessThreshold = runtimeOptions.GetPGOHotnessThreshold();
AOTInitialize(vm);
@ -117,7 +119,7 @@ int Main(const int argc, const char **argv)
entrypoint = runtimeOptions.GetEntryPoint();
}
PassManager passManager(vm, entrypoint, triple, optLevel, relocMode, &log, &logList, maxAotMethodSize,
isEnableTypeLowering, profilerIn, hotnessThreshold, isEnableOptInlining);
profilerIn, hotnessThreshold, &passOptions);
for (const auto &fileName : pandaFileNames) {
auto extendedFilePath = panda::os::file::File::GetExtendedFilePath(fileName);
LOG_COMPILER(INFO) << "AOT compile: " << extendedFilePath;

View File

@ -130,4 +130,12 @@ void ArgumentAccessor::CollectArgs()
std::reverse(args_.begin(), args_.end());
}
}
GateRef ArgumentAccessor::GetFrameArgsIn(GateRef gate, FrameArgIdx idx)
{
GateAccessor gateAcc(circuit_);
ASSERT(gateAcc.GetOpCode(gate) == OpCode::JS_BYTECODE || gateAcc.GetOpCode(gate) == OpCode::FRAME_STATE);
GateRef frameArgs = gateAcc.GetFrameState(gate);
return gateAcc.GetValueIn(frameArgs, static_cast<size_t>(idx));
}
} // namespace panda::ecmascript::kungfu

View File

@ -33,6 +33,14 @@ enum class CommonArgIdx : uint8_t {
NUM_OF_ARGS,
};
enum class FrameArgIdx : uint8_t {
FUNC = 0,
NEW_TARGET,
THIS_OBJECT,
ACTUAL_ARGC,
NUM_OF_ARGS,
};
class ArgumentAccessor {
public:
explicit ArgumentAccessor(
@ -40,7 +48,8 @@ public:
: circuit_(circuit),
method_(methodLiteral),
argRoot_(circuit->GetArgRoot()),
args_(0)
args_(0),
frameArgs_{Circuit::NullGate()}
{
CollectArgs();
}
@ -52,7 +61,6 @@ public:
size_t GetActualNumArgs() const;
// method must be set
GateRef GetArgGate(const size_t currentVreg) const;
GateRef GetCommonArgGate(const CommonArgIdx arg) const;
GateRef ArgsAt(const size_t index) const
{
return args_.at(index);
@ -68,7 +76,20 @@ public:
return static_cast<size_t>(CommonArgIdx::NUM_OF_ARGS) - static_cast<size_t>(CommonArgIdx::FUNC);
}
GateRef GetFrameArgs() const
{
return frameArgs_;
}
void SetFrameArgs(GateRef frameArgs)
{
frameArgs_ = frameArgs;
}
GateRef GetFrameArgsIn(GateRef gate, FrameArgIdx idx);
private:
// Disables using this interface during lowering, only allows it to be used during building graph.
GateRef GetCommonArgGate(const CommonArgIdx arg) const;
size_t GetFunctionArgIndex(const size_t currentVreg, const bool haveFunc,
const bool haveNewTarget, const bool haveThis) const;
GateRef GetTypedArgGate(const size_t argIndex) const;
@ -77,6 +98,10 @@ private:
const MethodLiteral *method_ {nullptr};
GateRef argRoot_;
std::vector<GateRef> args_;
GateRef frameArgs_;
friend class BytecodeCircuitBuilder;
friend class AsyncFunctionLowering;
};
}
#endif // ECMASCRIPT_COMPILER_ARGUMENT_ACCESSOR_H

View File

@ -540,6 +540,21 @@ void BytecodeCircuitBuilder::BuildCircuitArgs()
if (HasTypes()) {
argAcc_.FillArgsGateType(&typeRecorder_);
}
BuildFrameArgs();
}
void BytecodeCircuitBuilder::BuildFrameArgs()
{
size_t numArgs = static_cast<size_t>(FrameArgIdx::NUM_OF_ARGS);
std::vector<GateRef> args(numArgs, Circuit::NullGate());
size_t idx = 0;
args[idx++] = argAcc_.GetCommonArgGate(CommonArgIdx::FUNC);
args[idx++] = argAcc_.GetCommonArgGate(CommonArgIdx::NEW_TARGET);
args[idx++] = argAcc_.GetCommonArgGate(CommonArgIdx::THIS_OBJECT);
args[idx++] = argAcc_.GetCommonArgGate(CommonArgIdx::ACTUAL_ARGC);
GateRef frameArgs = circuit_->NewGate(circuit_->FrameArgs(), args);
argAcc_.SetFrameArgs(frameArgs);
}
bool BytecodeCircuitBuilder::ShouldBeDead(BytecodeRegion &curBlock)
@ -692,7 +707,8 @@ std::vector<GateRef> BytecodeCircuitBuilder::CreateGateInList(
if (std::holds_alternative<ConstDataId>(input)) {
if (std::get<ConstDataId>(input).IsStringId()) {
inList[i + length] = circuit_->GetConstantDataGate(std::get<ConstDataId>(input).CaculateBitField(),
GateType::StringType());
GateType::StringType(),
argAcc_.GetCommonArgGate(CommonArgIdx::FUNC));
} else {
inList[i + length] = circuit_->GetConstantGate(MachineType::I64,
std::get<ConstDataId>(input).GetId(),
@ -714,8 +730,9 @@ std::vector<GateRef> BytecodeCircuitBuilder::CreateGateInList(
if (info.AccIn()) {
inputSize++;
}
if (info.ThisObjectIn()) {
inList[inputSize + length] = argAcc_.GetCommonArgGate(CommonArgIdx::THIS_OBJECT);
if (info.HasFrameState()) {
GateRef frameArgs = argAcc_.GetFrameArgs();
inList[inputSize + length] = frameArgs;
}
return inList;
}
@ -804,7 +821,8 @@ GateRef BytecodeCircuitBuilder::NewConst(const BytecodeInfo &info)
break;
case EcmaOpcode::LDA_STR_ID16: {
auto input = std::get<ConstDataId>(info.inputs.at(0));
gate = circuit_->GetConstantDataGate(input.CaculateBitField(), GateType::StringType());
gate = circuit_->GetConstantDataGate(input.CaculateBitField(), GateType::StringType(),
argAcc_.GetCommonArgGate(CommonArgIdx::FUNC));
break;
}
default:
@ -821,9 +839,9 @@ void BytecodeCircuitBuilder::NewJSGate(BytecodeRegion &bb, GateRef &state, GateR
size_t numValueInputs = bytecodeInfo.ComputeValueInputCount();
GateRef gate = 0;
bool writable = !bytecodeInfo.NoSideEffects();
bool hasFrameState = bytecodeInfo.HasFrameState();
size_t pcOffset = GetPcOffset(iterator.Index());
auto meta = circuit_->JSBytecode(numValueInputs,
bytecodeInfo.GetOpcode(), pcOffset, writable);
auto meta = circuit_->JSBytecode(numValueInputs, bytecodeInfo.GetOpcode(), pcOffset, writable, hasFrameState);
std::vector<GateRef> inList = CreateGateInList(bytecodeInfo, meta);
if (bytecodeInfo.IsDef()) {
gate = circuit_->NewGate(meta, MachineType::I64, inList.size(),
@ -837,7 +855,8 @@ void BytecodeCircuitBuilder::NewJSGate(BytecodeRegion &bb, GateRef &state, GateR
auto offsetGate = circuit_->GetConstantGate(MachineType::I32,
GetJumpOffset(iterator.Index()),
GateType::NJSValue());
auto updateHotness = circuit_->NewGate(circuit_->UpdateHotness(), {state, depend, offsetGate});
GateRef jsFunc = argAcc_.GetCommonArgGate(CommonArgIdx::FUNC);
auto updateHotness = circuit_->NewGate(circuit_->UpdateHotness(), {state, depend, offsetGate, jsFunc});
gateAcc_.NewIn(gate, 0, updateHotness);
gateAcc_.NewIn(gate, 1, updateHotness);
} else {
@ -908,7 +927,7 @@ void BytecodeCircuitBuilder::NewJump(BytecodeRegion &bb, GateRef &state, GateRef
if (bytecodeInfo.IsCondJump()) {
ASSERT(!bytecodeInfo.Deopt());
size_t pcOffset = GetPcOffset(iterator.Index());
auto meta = circuit_->JSBytecode(numValueInputs, bytecodeInfo.GetOpcode(), pcOffset, false);
auto meta = circuit_->JSBytecode(numValueInputs, bytecodeInfo.GetOpcode(), pcOffset, false, false);
auto numValues = meta->GetNumIns();
GateRef gate = circuit_->NewGate(meta, std::vector<GateRef>(numValues, Circuit::NullGate()));
gateAcc_.NewIn(gate, 0, state);
@ -920,7 +939,8 @@ void BytecodeCircuitBuilder::NewJump(BytecodeRegion &bb, GateRef &state, GateRef
auto offsetGate = circuit_->GetConstantGate(MachineType::I32,
offset,
GateType::NJSValue());
ifTrue = circuit_->NewGate(circuit_->UpdateHotness(), {ifTrue, trueRelay, offsetGate});
GateRef jsFunc = argAcc_.GetCommonArgGate(CommonArgIdx::FUNC);
ifTrue = circuit_->NewGate(circuit_->UpdateHotness(), {ifTrue, trueRelay, offsetGate, jsFunc});
trueRelay = ifTrue;
}
auto ifFalse = circuit_->NewGate(circuit_->IfFalse(), {gate});
@ -961,7 +981,8 @@ void BytecodeCircuitBuilder::NewJump(BytecodeRegion &bb, GateRef &state, GateRef
auto offsetGate = circuit_->GetConstantGate(MachineType::I32,
offset,
GateType::NJSValue());
auto updateHotness = circuit_->NewGate(circuit_->UpdateHotness(), {state, depend, offsetGate});
GateRef jsFunc = argAcc_.GetCommonArgGate(CommonArgIdx::FUNC);
auto updateHotness = circuit_->NewGate(circuit_->UpdateHotness(), {state, depend, offsetGate, jsFunc});
SetBlockPred(*bbNext, updateHotness, updateHotness, isLoopBack);
} else {
SetBlockPred(*bbNext, state, depend, isLoopBack);
@ -978,7 +999,8 @@ void BytecodeCircuitBuilder::NewReturn(BytecodeRegion &bb, GateRef &state, GateR
auto offsetGate = circuit_->GetConstantGate(MachineType::I32,
GetJumpOffset(iterator.Index()),
GateType::NJSValue());
auto updateHotness = circuit_->NewGate(circuit_->UpdateHotness(), {state, depend, offsetGate});
GateRef jsFunc = argAcc_.GetCommonArgGate(CommonArgIdx::FUNC);
auto updateHotness = circuit_->NewGate(circuit_->UpdateHotness(), {state, depend, offsetGate, jsFunc});
if (bytecodeInfo.GetOpcode() == EcmaOpcode::RETURN) {
// handle return.dyn bytecode
auto gate = circuit_->NewGate(circuit_->Return(),
@ -1191,7 +1213,7 @@ GateRef BytecodeCircuitBuilder::ResolveDef(const size_t bbId, int32_t bcId, cons
// find def-site in function args
ASSERT(!tmpAcc);
if (tmpReg == GetEnvVregIdx()) {
ans = argAcc_.GetCommonArgGate(CommonArgIdx::LEXENV);
ans = gateAcc_.GetInitialEnvGate(argAcc_.GetCommonArgGate(CommonArgIdx::FUNC));
} else {
ans = argAcc_.GetArgGate(tmpReg);
}
@ -1258,7 +1280,7 @@ void BytecodeCircuitBuilder::BuildCircuit()
auto vregId = std::get<VirtualRegister>(bytecodeInfo.inputs.at(valueIdx)).GetId();
GateRef defVreg = Circuit::NullGate();
if (IsFirstBCEnvIn(bbIndex, bcIndex, vregId)) {
defVreg = argAcc_.GetCommonArgGate(CommonArgIdx::LEXENV);
defVreg = gateAcc_.GetInitialEnvGate(argAcc_.GetCommonArgGate(CommonArgIdx::FUNC));
} else {
defVreg = ResolveDef(bbIndex, bcIndex - 1, vregId, false);
}
@ -1273,7 +1295,8 @@ void BytecodeCircuitBuilder::BuildCircuit()
}
if (IsTypeLoweringEnabled()) {
frameStateBuilder_.BuildFrameState();
GateRef frameArgs = argAcc_.GetFrameArgs();
frameStateBuilder_.BuildFrameState(frameArgs);
}
if (IsLogEnabled()) {

View File

@ -459,6 +459,7 @@ private:
void PrintBytecodeInfo(BytecodeRegion& region);
void PrintDefsitesInfo(const std::unordered_map<uint16_t, std::set<size_t>> &defsitesInfo);
void BuildRegionInfo();
void BuildFrameArgs();
inline bool IsEntryBlock(const size_t bbId) const
{

View File

@ -243,6 +243,81 @@ BytecodeMetaData BytecodeMetaData::InitBytecodeMetaData(const uint8_t *pc)
break;
}
switch (inst.GetOpcode()) {
case EcmaOpcode::SUSPENDGENERATOR_V8:
case EcmaOpcode::TRYLDGLOBALBYNAME_IMM8_ID16:
case EcmaOpcode::TRYLDGLOBALBYNAME_IMM16_ID16:
case EcmaOpcode::STGLOBALVAR_IMM16_ID16:
case EcmaOpcode::THROW_UNDEFINEDIFHOLEWITHNAME_PREF_ID16:
case EcmaOpcode::DEFINEFUNC_IMM8_ID16_IMM8:
case EcmaOpcode::DEFINEFUNC_IMM16_ID16_IMM8:
case EcmaOpcode::DEFINEMETHOD_IMM8_ID16_IMM8:
case EcmaOpcode::DEFINEMETHOD_IMM16_ID16_IMM8:
case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM8_ID16_ID16_IMM16_V8:
case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM16_ID16_ID16_IMM16_V8:
case EcmaOpcode::INSTANCEOF_IMM8_V8:
case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM8_ID16:
case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM16_ID16:
case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM8_ID16:
case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM16_ID16:
case EcmaOpcode::STMODULEVAR_IMM8:
case EcmaOpcode::WIDE_STMODULEVAR_PREF_IMM16:
case EcmaOpcode::SETGENERATORSTATE_IMM8:
case EcmaOpcode::DYNAMICIMPORT:
case EcmaOpcode::LDEXTERNALMODULEVAR_IMM8:
case EcmaOpcode::WIDE_LDEXTERNALMODULEVAR_PREF_IMM16:
case EcmaOpcode::GETMODULENAMESPACE_IMM8:
case EcmaOpcode::WIDE_GETMODULENAMESPACE_PREF_IMM16:
case EcmaOpcode::NEWLEXENVWITHNAME_IMM8_ID16:
case EcmaOpcode::WIDE_NEWLEXENVWITHNAME_PREF_IMM16_ID16:
case EcmaOpcode::LDSUPERBYVALUE_IMM8_V8:
case EcmaOpcode::LDSUPERBYVALUE_IMM16_V8:
case EcmaOpcode::STSUPERBYVALUE_IMM16_V8_V8:
case EcmaOpcode::TRYSTGLOBALBYNAME_IMM8_ID16:
case EcmaOpcode::TRYSTGLOBALBYNAME_IMM16_ID16:
case EcmaOpcode::LDGLOBALVAR_IMM16_ID16:
case EcmaOpcode::LDOBJBYNAME_IMM8_ID16:
case EcmaOpcode::LDOBJBYNAME_IMM16_ID16:
case EcmaOpcode::STOBJBYNAME_IMM8_ID16_V8:
case EcmaOpcode::STOBJBYNAME_IMM16_ID16_V8:
case EcmaOpcode::LDOBJBYVALUE_IMM8_V8:
case EcmaOpcode::LDOBJBYVALUE_IMM16_V8:
case EcmaOpcode::LDTHISBYVALUE_IMM8:
case EcmaOpcode::LDTHISBYVALUE_IMM16:
case EcmaOpcode::STOBJBYVALUE_IMM8_V8_V8:
case EcmaOpcode::STOBJBYVALUE_IMM16_V8_V8:
case EcmaOpcode::STTHISBYVALUE_IMM8_V8:
case EcmaOpcode::STTHISBYVALUE_IMM16_V8:
case EcmaOpcode::LDSUPERBYNAME_IMM8_ID16:
case EcmaOpcode::LDSUPERBYNAME_IMM16_ID16:
case EcmaOpcode::STSUPERBYNAME_IMM8_ID16_V8:
case EcmaOpcode::STSUPERBYNAME_IMM16_ID16_V8:
case EcmaOpcode::LDLOCALMODULEVAR_IMM8:
case EcmaOpcode::WIDE_LDLOCALMODULEVAR_PREF_IMM16:
case EcmaOpcode::LDTHISBYNAME_IMM8_ID16:
case EcmaOpcode::LDTHISBYNAME_IMM16_ID16:
case EcmaOpcode::STTHISBYNAME_IMM8_ID16:
case EcmaOpcode::STTHISBYNAME_IMM16_ID16:
flags |= BytecodeFlags::READ_FUNC;
break;
case EcmaOpcode::SUPERCALLTHISRANGE_IMM8_IMM8_V8:
case EcmaOpcode::WIDE_SUPERCALLTHISRANGE_PREF_IMM16_V8:
flags |= BytecodeFlags::READ_FUNC;
flags |= BytecodeFlags::READ_NEWTARGET;
break;
case EcmaOpcode::SUPERCALLARROWRANGE_IMM8_IMM8_V8:
case EcmaOpcode::WIDE_SUPERCALLARROWRANGE_PREF_IMM16_V8:
case EcmaOpcode::SUPERCALLSPREAD_IMM8_V8:
flags |= BytecodeFlags::READ_NEWTARGET;
break;
case EcmaOpcode::GETUNMAPPEDARGS:
case EcmaOpcode::COPYRESTARGS_IMM8:
case EcmaOpcode::WIDE_COPYRESTARGS_PREF_IMM16:
flags |= BytecodeFlags::READ_ARGC;
default:
break;
}
if (kind == BytecodeKind::GENERAL ||
kind == BytecodeKind::THROW_BC ||
kind == BytecodeKind::RESUME ||

View File

@ -46,6 +46,9 @@ enum BytecodeFlags : uint32_t {
NO_THROW = 1 << 6,
READ_ENV = 1 << 7,
WRITE_ENV = 1 << 8,
READ_FUNC = 1 << 9,
READ_NEWTARGET = 1 << 10,
READ_ARGC = 1 << 11,
};
enum BytecodeKind : uint32_t {
@ -65,7 +68,7 @@ class BytecodeMetaData {
public:
static constexpr uint32_t MAX_OPCODE_SIZE = 16;
static constexpr uint32_t MAX_SIZE_BITS = 4;
static constexpr uint32_t BYTECODE_FLAGS_SIZE = 9;
static constexpr uint32_t BYTECODE_FLAGS_SIZE = 12;
static constexpr uint32_t BYTECODE_KIND_SIZE = 4;
using OpcodeField = panda::BitField<EcmaOpcode, 0, MAX_OPCODE_SIZE>;
@ -173,6 +176,21 @@ public:
return GetKind() == BytecodeKind::DISCARDED;
}
bool HasFuncIn() const
{
return HasFlag(BytecodeFlags::READ_FUNC);
}
bool HasNewTargetIn() const
{
return HasFlag(BytecodeFlags::READ_NEWTARGET);
}
bool HasArgcIn() const
{
return HasFlag(BytecodeFlags::READ_ARGC);
}
inline EcmaOpcode GetOpcode() const
{
return OpcodeField::Get(value_);
@ -556,7 +574,7 @@ public:
size_t ComputeValueInputCount() const
{
return (AccIn() ? 1 : 0) + (ThisObjectIn() ? 1 : 0) + inputs.size();
return (AccIn() ? 1 : 0) + inputs.size();
}
size_t ComputeOutCount() const
@ -569,6 +587,26 @@ public:
return metaData_.GetOpcode() == ecmaOpcode;
}
bool HasFuncIn() const
{
return metaData_.HasFuncIn();
}
bool HasNewTargetIn() const
{
return metaData_.HasNewTargetIn();
}
bool HasArgcIn() const
{
return metaData_.HasArgcIn();
}
bool HasFrameState() const
{
return HasFuncIn() || HasNewTargetIn() || ThisObjectIn() || HasArgcIn();
}
inline EcmaOpcode GetOpcode() const
{
return metaData_.GetOpcode();

View File

@ -408,19 +408,30 @@ GateRef Circuit::GetConstantStringGate(MachineType machineType, const std::strin
return gate;
}
GateRef Circuit::GetInitialEnvGate(GateRef jsFunc)
{
auto search = initialEnvCache_.find(jsFunc);
if (search != initialEnvCache_.end()) {
return initialEnvCache_.at(jsFunc);
}
auto gate = NewGate(GetEnv(), MachineType::I64, {jsFunc}, GateType::AnyType());
initialEnvCache_[jsFunc] = gate;
return gate;
}
GateRef Circuit::NewArg(MachineType machineType, size_t index,
GateType type, GateRef argRoot)
{
return NewGate(metaBuilder_.Arg(index), machineType, { argRoot }, type);
}
GateRef Circuit::GetConstantDataGate(uint64_t value, GateType type)
GateRef Circuit::GetConstantDataGate(uint64_t value, GateType type, GateRef jsFunc)
{
auto search = constantDataCache_.find(value);
if (search != constantDataCache_.end()) {
return constantDataCache_.at(value);
}
auto gate = NewGate(metaBuilder_.ConstData(value), MachineType::ARCH, type);
auto gate = NewGate(metaBuilder_.ConstData(value), MachineType::ARCH, { jsFunc }, type);
constantDataCache_[value] = gate;
return gate;
}

View File

@ -54,7 +54,8 @@ public:
GateRef GetConstantGate(MachineType machineType, uint64_t value, GateType type);
GateRef GetConstantStringGate(MachineType machineType, const std::string &str, GateType type);
GateRef NewArg(MachineType machineType, size_t index, GateType type, GateRef argRoot);
GateRef GetConstantDataGate(uint64_t value, GateType type);
GateRef GetConstantDataGate(uint64_t value, GateType type, GateRef jsFunc);
GateRef GetInitialEnvGate(GateRef jsFunc);
size_t GetGateCount() const;
TimeStamp GetTime() const;
void AdvanceTime() const;
@ -137,9 +138,11 @@ public:
}
const GateMetaData* JSBytecode(size_t valuesIn, EcmaOpcode opcode,
uint32_t pcOffset, bool writable)
uint32_t pcOffset, bool writable, bool hasFrameState)
{
GateFlags flags = writable ? GateFlags::NONE_FLAG : GateFlags::NO_WRITE;
GateFlags writableFlags = writable ? GateFlags::NONE_FLAG : GateFlags::NO_WRITE;
GateFlags frameStateFlags = hasFrameState ? GateFlags::HAS_FRAME_STATE : GateFlags::NONE_FLAG;
GateFlags flags = static_cast<GateFlags>(writableFlags | frameStateFlags);
return metaBuilder_.JSBytecode(valuesIn, opcode, pcOffset, flags);
}
@ -216,6 +219,7 @@ private:
TimeStamp time_;
std::map<std::tuple<MachineType, BitField, GateType>, GateRef> constantCache_ {};
std::map<BitField, GateRef> constantDataCache_ {};
std::map<GateRef, GateRef> initialEnvCache_ {};
panda::ecmascript::FrameType frameType_ {panda::ecmascript::FrameType::OPTIMIZED_FRAME};
bool isArch64_ { false };

View File

@ -90,6 +90,14 @@ GateRef CircuitBuilder::Load(VariableType type, GateRef base, GateRef offset)
return result;
}
GateRef CircuitBuilder::Load(VariableType type, GateRef base, GateRef offset, GateRef depend)
{
GateRef val = PtrAdd(base, offset);
GateRef result = GetCircuit()->NewGate(GetCircuit()->Load(), type.GetMachineType(),
{ depend, val }, type.GetGateType());
return result;
}
// Js World
// cast operation
GateRef CircuitBuilder::GetInt64OfTInt(GateRef x)

View File

@ -325,6 +325,7 @@ public:
// memory
inline GateRef Load(VariableType type, GateRef base, GateRef offset);
inline GateRef Load(VariableType type, GateRef base, GateRef offset, GateRef depend);
void Store(VariableType type, GateRef glue, GateRef base, GateRef offset, GateRef value);
#define ARITHMETIC_BINARY_OP_WITH_BITWIDTH(NAME, OPCODEID, MACHINETYPEID) \

View File

@ -51,7 +51,7 @@ FrameStateBuilder::~FrameStateBuilder()
GateRef FrameStateBuilder::FrameState(size_t pcOffset, FrameStateInfo *stateInfo)
{
size_t frameStateInputs = numVregs_ + 1; // +1: for pc
std::vector<GateRef> inList(frameStateInputs, Circuit::NullGate());
std::vector<GateRef> inList(frameStateInputs + 1, Circuit::NullGate()); // 1: frameArgs
auto optimizedGate = circuit_->GetConstantGate(MachineType::I64,
JSTaggedValue::VALUE_OPTIMIZED_OUT,
GateType::TaggedValue());
@ -66,6 +66,7 @@ GateRef FrameStateBuilder::FrameState(size_t pcOffset, FrameStateInfo *stateInfo
pcOffset,
GateType::NJSValue());
inList[numVregs_] = pcGate;
inList[numVregs_ + 1] = argAcc_.GetFrameArgs();
return circuit_->NewGate(circuit_->FrameState(frameStateInputs), inList);
}
@ -285,9 +286,10 @@ void FrameStateBuilder::ComputeLiveState()
}
}
void FrameStateBuilder::BuildFrameState()
void FrameStateBuilder::BuildFrameState(GateRef frameArgs)
{
argAcc_.CollectArgs();
argAcc_.SetFrameArgs(frameArgs);
bcEndStateInfos_.resize(builder_->GetLastBcIndex() + 1, nullptr); // 1: +1 pcOffsets size
auto size = builder_->GetBasicBlockCount();
bbBeginStateInfos_.resize(size, nullptr);

View File

@ -75,7 +75,7 @@ public:
Circuit *circuit, const MethodLiteral *literal);
~FrameStateBuilder();
void BuildFrameState();
void BuildFrameState(GateRef frameArgs);
private:
GateRef ValuesAt(size_t index) const
{

View File

@ -723,6 +723,11 @@ GateRef GateAccessor::GetConstantGate(MachineType bitValue, BitField bitfield, G
return circuit_->GetConstantGate(bitValue, bitfield, type);
}
GateRef GateAccessor::GetInitialEnvGate(GateRef jsFunc) const
{
return circuit_->GetInitialEnvGate(jsFunc);
}
bool GateAccessor::IsConstantNumber(GateRef gate) const
{
DISALLOW_GARBAGE_COLLECTION;

View File

@ -417,6 +417,7 @@ public:
MachineType GetMachineType(GateRef gate) const;
void SetMachineType(GateRef gate, MachineType type);
GateRef GetConstantGate(MachineType bitValue, BitField bitfield, GateType type) const;
GateRef GetInitialEnvGate(GateRef jsFunc) const;
double GetFloat64FromConstant(GateRef gate) const;
int GetInt32FromConstant(GateRef gate) const;
bool IsInGateNull(GateRef gate, size_t idx) const;

View File

@ -207,14 +207,16 @@ std::string MachineTypeToStr(MachineType machineType);
V(TypedNewAllocateThis, TYPED_NEW_ALLOCATE_THIS, GateFlags::CHECKABLE, 1, 1, 2) \
V(TypedSuperAllocateThis, TYPED_SUPER_ALLOCATE_THIS, GateFlags::CHECKABLE, 1, 1, 2) \
V(GetSuperConstructor, GET_SUPER_CONSTRUCTOR, GateFlags::NO_WRITE, 1, 1, 1) \
V(UpdateHotness, UPDATE_HOTNESS, GateFlags::NO_WRITE, 1, 1, 1) \
V(UpdateHotness, UPDATE_HOTNESS, GateFlags::NO_WRITE, 1, 1, 2) \
V(Dead, DEAD, GateFlags::NONE_FLAG, 0, 0, 0) \
V(FrameArgs, FRAME_ARGS, GateFlags::NONE_FLAG, 0, 0, 4) \
V(GetEnv, GET_ENV, GateFlags::NONE_FLAG, 0, 0, 1) \
BINARY_GATE_META_DATA_CACHE_LIST(V) \
UNARY_GATE_META_DATA_CACHE_LIST(V)
#define GATE_META_DATA_LIST_WITH_VALUE_IN(V) \
V(ValueSelector, VALUE_SELECTOR, GateFlags::FIXED, 1, 0, value) \
V(FrameState, FRAME_STATE, GateFlags::NONE_FLAG, 0, 0, value) \
V(FrameState, FRAME_STATE, GateFlags::HAS_FRAME_STATE, 0, 0, value) \
V(RuntimeCall, RUNTIME_CALL, GateFlags::NONE_FLAG, 0, 1, value) \
V(RuntimeCallWithArgv, RUNTIME_CALL_WITH_ARGV, GateFlags::NONE_FLAG, 0, 1, value) \
V(NoGcRuntimeCall, NOGC_RUNTIME_CALL, GateFlags::NONE_FLAG, 0, 1, value) \
@ -262,9 +264,9 @@ std::string MachineTypeToStr(MachineType machineType);
V(LoadElement, LOAD_ELEMENT, GateFlags::NO_WRITE, 1, 1, 2) \
V(StoreElement, STORE_ELEMENT, GateFlags::NONE_FLAG, 1, 1, 3) \
V(RestoreRegister, RESTORE_REGISTER, GateFlags::NONE_FLAG, 0, 1, 0) \
V(ConstData, CONST_DATA, GateFlags::NONE_FLAG, 0, 0, 0) \
V(ConstData, CONST_DATA, GateFlags::NONE_FLAG, 0, 0, 1) \
V(Constant, CONSTANT, GateFlags::NONE_FLAG, 0, 0, 0) \
V(RelocatableData, RELOCATABLE_DATA, GateFlags::NONE_FLAG, 0, 0, 0)
V(RelocatableData, RELOCATABLE_DATA, GateFlags::NONE_FLAG, 0, 0, 0) \
#define GATE_META_DATA_LIST_WITH_ONE_PARAMETER(V) \
V(Arg, ARG, GateFlags::HAS_ROOT, 0, 0, 0) \

View File

@ -191,7 +191,7 @@ void LLVMIRBuilder::InitializeHandlers()
OpCode::DEAD, OpCode::RETURN_LIST,
OpCode::ARG_LIST, OpCode::THROW,
OpCode::DEPEND_SELECTOR, OpCode::DEPEND_RELAY,
OpCode::FRAME_STATE, OpCode::STATE_SPLIT
OpCode::FRAME_STATE, OpCode::STATE_SPLIT, OpCode::FRAME_ARGS
};
}
@ -2039,6 +2039,10 @@ void LLVMIRBuilder::VisitDeopt(GateRef gate)
GateRef env = acc_.GetValueIn(frameState, envIndex);
GateRef acc = acc_.GetValueIn(frameState, accIndex);
GateRef pc = acc_.GetValueIn(frameState, pcIndex);
ArgumentAccessor argAcc(const_cast<Circuit *>(circuit_));
GateRef jsFunc = argAcc.GetFrameArgsIn(frameState, FrameArgIdx::FUNC);
GateRef newTarget = argAcc.GetFrameArgsIn(frameState, FrameArgIdx::NEW_TARGET);
GateRef thisObj = argAcc.GetFrameArgsIn(frameState, FrameArgIdx::THIS_OBJECT);
std::vector<LLVMValueRef> values;
for (size_t i = 0; i < envIndex; i++) {
GateRef vregValue = acc_.GetValueIn(frameState, i);
@ -2058,6 +2062,12 @@ void LLVMIRBuilder::VisitDeopt(GateRef gate)
}
values.emplace_back(LLVMConstInt(LLVMInt32Type(), static_cast<int>(SpecVregIndex::PC_OFFSET_INDEX), false));
values.emplace_back(gate2LValue_.at(pc));
values.emplace_back(LLVMConstInt(LLVMInt32Type(), static_cast<int>(SpecVregIndex::FUNC_INDEX), false));
values.emplace_back(gate2LValue_.at(jsFunc));
values.emplace_back(LLVMConstInt(LLVMInt32Type(), static_cast<int>(SpecVregIndex::NEWTARGET_INDEX), false));
values.emplace_back(gate2LValue_.at(newTarget));
values.emplace_back(LLVMConstInt(LLVMInt32Type(), static_cast<int>(SpecVregIndex::THIS_OBJECT_INDEX), false));
values.emplace_back(gate2LValue_.at(thisObj));
LLVMValueRef runtimeCall =
LLVMBuildCall3(builder_, funcType, callee, params.data(), params.size(), "", values.data(), values.size());
gate2LValue_[gate] = runtimeCall;

View File

@ -39,7 +39,7 @@ bool PassManager::Compile(const std::string &fileName, AOTFileGenerator &generat
LOG_COMPILER(ERROR) << "Load and verify profiler failure";
return false;
}
bool enableCollectLiteralInfo = EnableTypeInfer() &&
bool enableCollectLiteralInfo = passOptions_->EnableTypeInfer() &&
(profilerLoader_.IsLoaded() || vm_->GetTSManager()->AssertTypes());
BytecodeInfoCollector bcInfoCollector(vm_, jsPandaFile, maxAotMethodSize_,
enableCollectLiteralInfo);
@ -93,7 +93,7 @@ bool PassManager::Compile(const std::string &fileName, AOTFileGenerator &generat
circuit.SetFrameType(FrameType::OPTIMIZED_JS_FUNCTION_FRAME);
BytecodeCircuitBuilder builder(jsPandaFile, methodLiteral, methodPCInfo, tsManager, &circuit,
info.GetByteCodes(), hasTypes, enableMethodLog && log_->OutputCIR(),
EnableTypeLowering(), fullName, recordName);
passOptions_->EnableTypeLowering(), fullName, recordName);
{
TimeScope timeScope("BytecodeToCircuit", methodName, methodOffset, log_);
builder.BytecodeToCircuit();
@ -103,17 +103,17 @@ bool PassManager::Compile(const std::string &fileName, AOTFileGenerator &generat
&methodInfo, hasTypes, recordName,
methodLiteral, methodOffset, vm_->GetNativeAreaAllocator());
PassRunner<PassData> pipeline(&data);
if (EnableTypeInfer()) {
if (passOptions_->EnableTypeInfer()) {
pipeline.RunPass<TypeInferPass>();
}
if (data.IsTypeAbort()) {
return;
}
if (EnableOptInlining()) {
if (passOptions_->EnableOptInlining()) {
pipeline.RunPass<TSInlineLoweringPass>();
}
pipeline.RunPass<AsyncFunctionLoweringPass>();
if (EnableTypeLowering()) {
if (passOptions_->EnableTypeLowering()) {
pipeline.RunPass<TSTypeLoweringPass>();
pipeline.RunPass<EarlyEliminationPass>();
pipeline.RunPass<NumberSpeculativePass>();

View File

@ -98,25 +98,14 @@ private:
LLVMModule *aotModule_ {nullptr};
};
class PassManager {
class PassOptions {
public:
PassManager(EcmaVM* vm, std::string entry, std::string &triple, size_t optLevel, size_t relocMode,
CompilerLog *log, AotMethodLogList *logList, size_t maxAotMethodSize, bool enableTypeLowering,
const std::string &profIn, uint32_t hotnessThreshold, bool enableOptInlining)
: vm_(vm), entry_(entry), triple_(triple), optLevel_(optLevel), relocMode_(relocMode), log_(log),
logList_(logList), maxAotMethodSize_(maxAotMethodSize),
enableTypeLowering_(enableTypeLowering),
enableTypeInfer_(enableTypeLowering || vm_->GetTSManager()->AssertTypes()),
profilerLoader_(profIn, hotnessThreshold), enableOptInlining_(enableOptInlining) {};
PassManager() = default;
~PassManager() = default;
bool Compile(const std::string &fileName, AOTFileGenerator &generator);
private:
JSPandaFile *CreateAndVerifyJSPandaFile(const CString &fileName);
bool IsReleasedPandaFile(const JSPandaFile *jsPandaFile) const;
void ResolveModule(const JSPandaFile *jsPandaFile, const std::string &fileName);
PassOptions(bool enableTypeLowering, bool enableTypeInfer, bool enableOptInlining)
: enableTypeLowering_(enableTypeLowering),
enableTypeInfer_(enableTypeInfer),
enableOptInlining_(enableOptInlining)
{
}
bool EnableTypeLowering() const
{
@ -132,6 +121,29 @@ private:
{
return enableOptInlining_;
}
private:
bool enableTypeLowering_ {false};
bool enableTypeInfer_ {false};
bool enableOptInlining_ {false};
};
class PassManager {
public:
PassManager(EcmaVM* vm, std::string entry, std::string &triple, size_t optLevel, size_t relocMode,
CompilerLog *log, AotMethodLogList *logList, size_t maxAotMethodSize, const std::string &profIn,
uint32_t hotnessThreshold, PassOptions *passOptions)
: vm_(vm), entry_(entry), triple_(triple), optLevel_(optLevel), relocMode_(relocMode), log_(log),
logList_(logList), maxAotMethodSize_(maxAotMethodSize),
profilerLoader_(profIn, hotnessThreshold), passOptions_(passOptions) {};
PassManager() = default;
~PassManager() = default;
bool Compile(const std::string &fileName, AOTFileGenerator &generator);
private:
JSPandaFile *CreateAndVerifyJSPandaFile(const CString &fileName);
bool IsReleasedPandaFile(const JSPandaFile *jsPandaFile) const;
void ResolveModule(const JSPandaFile *jsPandaFile, const std::string &fileName);
EcmaVM *vm_ {nullptr};
std::string entry_ {};
@ -141,10 +153,8 @@ private:
CompilerLog *log_ {nullptr};
AotMethodLogList *logList_ {nullptr};
size_t maxAotMethodSize_ {0};
bool enableTypeLowering_ {true};
bool enableTypeInfer_ {true};
PGOProfilerLoader profilerLoader_;
bool enableOptInlining_ {true};
PassOptions *passOptions_ {nullptr};
};
}
#endif // ECMASCRIPT_COMPILER_PASS_MANAGER_H

View File

@ -66,6 +66,8 @@ void SlowPathLowering::CallRuntimeLowering()
LowerUpdateHotness(gate);
} else if (op == OpCode::STATE_SPLIT) {
DeleteStateSplit(gate);
} else if (op == OpCode::GET_ENV) {
LowerGetEnv(gate);
}
}
@ -173,19 +175,8 @@ GateRef SlowPathLowering::GetProfileTypeInfo(GateRef jsFunc)
return builder_.Load(VariableType::JS_ANY(), method, builder_.IntPtr(Method::PROFILE_TYPE_INFO_OFFSET));
}
// labelmanager must be initialized
GateRef SlowPathLowering::GetHomeObjectFromJSFunction(GateRef jsFunc)
{
GateRef offset = builder_.IntPtr(JSFunction::HOME_OBJECT_OFFSET);
return builder_.Load(VariableType::JS_ANY(), jsFunc, offset);
}
void SlowPathLowering::Lower(GateRef gate)
{
GateRef newTarget = argAcc_.GetCommonArgGate(CommonArgIdx::NEW_TARGET);
GateRef jsFunc = argAcc_.GetCommonArgGate(CommonArgIdx::FUNC);
GateRef actualArgc = argAcc_.GetCommonArgGate(CommonArgIdx::ACTUAL_ARGC);
EcmaOpcode ecmaOpcode = acc_.GetByteCodeOpcode(gate);
// initialize label manager
Environment env(gate, circuit_, &builder_);
@ -231,7 +222,7 @@ void SlowPathLowering::Lower(GateRef gate)
LowerCallrangeImm8Imm8V8(gate);
break;
case EcmaOpcode::GETUNMAPPEDARGS:
LowerGetUnmappedArgs(gate, actualArgc);
LowerGetUnmappedArgs(gate);
break;
case EcmaOpcode::ASYNCFUNCTIONENTER:
LowerAsyncFunctionEnter(gate);
@ -292,7 +283,7 @@ void SlowPathLowering::Lower(GateRef gate)
LowerCreateIterResultObj(gate);
break;
case EcmaOpcode::SUSPENDGENERATOR_V8:
LowerSuspendGenerator(gate, jsFunc);
LowerSuspendGenerator(gate);
break;
case EcmaOpcode::ASYNCFUNCTIONAWAITUNCAUGHT_V8:
LowerAsyncFunctionAwaitUncaught(gate);
@ -305,10 +296,10 @@ void SlowPathLowering::Lower(GateRef gate)
break;
case EcmaOpcode::TRYLDGLOBALBYNAME_IMM8_ID16:
case EcmaOpcode::TRYLDGLOBALBYNAME_IMM16_ID16:
LowerTryLdGlobalByName(gate, jsFunc);
LowerTryLdGlobalByName(gate);
break;
case EcmaOpcode::STGLOBALVAR_IMM16_ID16:
LowerStGlobalVar(gate, jsFunc);
LowerStGlobalVar(gate);
break;
case EcmaOpcode::GETITERATOR_IMM8:
case EcmaOpcode::GETITERATOR_IMM16:
@ -344,7 +335,7 @@ void SlowPathLowering::Lower(GateRef gate)
LowerThrowUndefinedIfHole(gate);
break;
case EcmaOpcode::THROW_UNDEFINEDIFHOLEWITHNAME_PREF_ID16:
LowerThrowUndefinedIfHoleWithName(gate, jsFunc);
LowerThrowUndefinedIfHoleWithName(gate);
break;
case EcmaOpcode::THROW_IFSUPERNOTCORRECTCALL_PREF_IMM8:
case EcmaOpcode::THROW_IFSUPERNOTCORRECTCALL_PREF_IMM16:
@ -391,7 +382,7 @@ void SlowPathLowering::Lower(GateRef gate)
break;
case EcmaOpcode::DEFINEMETHOD_IMM8_ID16_IMM8:
case EcmaOpcode::DEFINEMETHOD_IMM16_ID16_IMM8:
LowerDefineMethod(gate, jsFunc);
LowerDefineMethod(gate);
break;
case EcmaOpcode::EXP_IMM8_V8:
LowerExp(gate);
@ -400,7 +391,7 @@ void SlowPathLowering::Lower(GateRef gate)
LowerIsIn(gate);
break;
case EcmaOpcode::INSTANCEOF_IMM8_V8:
LowerInstanceof(gate, jsFunc);
LowerInstanceof(gate);
break;
case EcmaOpcode::STRICTNOTEQ_IMM8_V8:
LowerFastStrictNotEqual(gate);
@ -417,18 +408,18 @@ void SlowPathLowering::Lower(GateRef gate)
break;
case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM8_ID16:
case EcmaOpcode::CREATEOBJECTWITHBUFFER_IMM16_ID16:
LowerCreateObjectWithBuffer(gate, jsFunc);
LowerCreateObjectWithBuffer(gate);
break;
case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM8_ID16:
case EcmaOpcode::CREATEARRAYWITHBUFFER_IMM16_ID16:
LowerCreateArrayWithBuffer(gate, jsFunc);
LowerCreateArrayWithBuffer(gate);
break;
case EcmaOpcode::STMODULEVAR_IMM8:
case EcmaOpcode::WIDE_STMODULEVAR_PREF_IMM16:
LowerStModuleVar(gate, jsFunc);
LowerStModuleVar(gate);
break;
case EcmaOpcode::SETGENERATORSTATE_IMM8:
LowerSetGeneratorState(gate, jsFunc);
LowerSetGeneratorState(gate);
break;
case EcmaOpcode::GETTEMPLATEOBJECT_IMM8:
case EcmaOpcode::GETTEMPLATEOBJECT_IMM16:
@ -445,15 +436,15 @@ void SlowPathLowering::Lower(GateRef gate)
LowerToNumeric(gate);
break;
case EcmaOpcode::DYNAMICIMPORT:
LowerDynamicImport(gate, jsFunc);
LowerDynamicImport(gate);
break;
case EcmaOpcode::LDEXTERNALMODULEVAR_IMM8:
case EcmaOpcode::WIDE_LDEXTERNALMODULEVAR_PREF_IMM16:
LowerExternalModule(gate, jsFunc);
LowerExternalModule(gate);
break;
case EcmaOpcode::GETMODULENAMESPACE_IMM8:
case EcmaOpcode::WIDE_GETMODULENAMESPACE_PREF_IMM16:
LowerGetModuleNamespace(gate, jsFunc);
LowerGetModuleNamespace(gate);
break;
case EcmaOpcode::NEWOBJRANGE_IMM8_IMM8_V8:
case EcmaOpcode::NEWOBJRANGE_IMM16_IMM8_V8:
@ -472,14 +463,14 @@ void SlowPathLowering::Lower(GateRef gate)
break;
case EcmaOpcode::SUPERCALLTHISRANGE_IMM8_IMM8_V8:
case EcmaOpcode::WIDE_SUPERCALLTHISRANGE_PREF_IMM16_V8:
LowerSuperCall(gate, jsFunc, newTarget);
LowerSuperCall(gate);
break;
case EcmaOpcode::SUPERCALLARROWRANGE_IMM8_IMM8_V8:
case EcmaOpcode::WIDE_SUPERCALLARROWRANGE_PREF_IMM16_V8:
LowerSuperCallArrow(gate, newTarget);
LowerSuperCallArrow(gate);
break;
case EcmaOpcode::SUPERCALLSPREAD_IMM8_V8:
LowerSuperCallSpread(gate, newTarget);
LowerSuperCallSpread(gate);
break;
case EcmaOpcode::ISTRUE:
LowerIsTrueOrFalse(gate, true);
@ -520,21 +511,21 @@ void SlowPathLowering::Lower(GateRef gate)
break;
case EcmaOpcode::NEWLEXENVWITHNAME_IMM8_ID16:
case EcmaOpcode::WIDE_NEWLEXENVWITHNAME_PREF_IMM16_ID16:
LowerNewLexicalEnvWithName(gate, jsFunc);
LowerNewLexicalEnvWithName(gate);
break;
case EcmaOpcode::POPLEXENV:
LowerPopLexicalEnv(gate);
break;
case EcmaOpcode::LDSUPERBYVALUE_IMM8_V8:
case EcmaOpcode::LDSUPERBYVALUE_IMM16_V8:
LowerLdSuperByValue(gate, jsFunc);
LowerLdSuperByValue(gate);
break;
case EcmaOpcode::STSUPERBYVALUE_IMM16_V8_V8:
LowerStSuperByValue(gate, jsFunc);
LowerStSuperByValue(gate);
break;
case EcmaOpcode::TRYSTGLOBALBYNAME_IMM8_ID16:
case EcmaOpcode::TRYSTGLOBALBYNAME_IMM16_ID16:
LowerTryStGlobalByName(gate, jsFunc);
LowerTryStGlobalByName(gate);
break;
case EcmaOpcode::STCONSTTOGLOBALRECORD_IMM16_ID16:
LowerStConstToGlobalRecord(gate, true);
@ -551,15 +542,15 @@ void SlowPathLowering::Lower(GateRef gate)
LowerStOwnByNameWithNameSet(gate);
break;
case EcmaOpcode::LDGLOBALVAR_IMM16_ID16:
LowerLdGlobalVar(gate, jsFunc);
LowerLdGlobalVar(gate);
break;
case EcmaOpcode::LDOBJBYNAME_IMM8_ID16:
case EcmaOpcode::LDOBJBYNAME_IMM16_ID16:
LowerLdObjByName(gate, jsFunc);
LowerLdObjByName(gate);
break;
case EcmaOpcode::STOBJBYNAME_IMM8_ID16_V8:
case EcmaOpcode::STOBJBYNAME_IMM16_ID16_V8:
LowerStObjByName(gate, jsFunc, false);
LowerStObjByName(gate, false);
break;
case EcmaOpcode::DEFINEGETTERSETTERBYVALUE_V8_V8_V8_V8:
LowerDefineGetterSetterByValue(gate);
@ -576,27 +567,27 @@ void SlowPathLowering::Lower(GateRef gate)
break;
case EcmaOpcode::LDOBJBYVALUE_IMM8_V8:
case EcmaOpcode::LDOBJBYVALUE_IMM16_V8:
LowerLdObjByValue(gate, jsFunc, false);
LowerLdObjByValue(gate, false);
break;
case EcmaOpcode::LDTHISBYVALUE_IMM8:
case EcmaOpcode::LDTHISBYVALUE_IMM16:
LowerLdObjByValue(gate, jsFunc, true);
LowerLdObjByValue(gate, true);
break;
case EcmaOpcode::STOBJBYVALUE_IMM8_V8_V8:
case EcmaOpcode::STOBJBYVALUE_IMM16_V8_V8:
LowerStObjByValue(gate, jsFunc, false);
LowerStObjByValue(gate, false);
break;
case EcmaOpcode::STTHISBYVALUE_IMM8_V8:
case EcmaOpcode::STTHISBYVALUE_IMM16_V8:
LowerStObjByValue(gate, jsFunc, true);
LowerStObjByValue(gate, true);
break;
case EcmaOpcode::LDSUPERBYNAME_IMM8_ID16:
case EcmaOpcode::LDSUPERBYNAME_IMM16_ID16:
LowerLdSuperByName(gate, jsFunc);
LowerLdSuperByName(gate);
break;
case EcmaOpcode::STSUPERBYNAME_IMM8_ID16_V8:
case EcmaOpcode::STSUPERBYNAME_IMM16_ID16_V8:
LowerStSuperByName(gate, jsFunc);
LowerStSuperByName(gate);
break;
case EcmaOpcode::CREATEGENERATOROBJ_V8:
LowerCreateGeneratorObj(gate);
@ -625,15 +616,15 @@ void SlowPathLowering::Lower(GateRef gate)
break;
case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM8_ID16_ID16_IMM16_V8:
case EcmaOpcode::DEFINECLASSWITHBUFFER_IMM16_ID16_ID16_IMM16_V8:
LowerDefineClassWithBuffer(gate, jsFunc);
LowerDefineClassWithBuffer(gate);
break;
case EcmaOpcode::DEFINEFUNC_IMM8_ID16_IMM8:
case EcmaOpcode::DEFINEFUNC_IMM16_ID16_IMM8:
LowerDefineFunc(gate, jsFunc);
LowerDefineFunc(gate);
break;
case EcmaOpcode::COPYRESTARGS_IMM8:
case EcmaOpcode::WIDE_COPYRESTARGS_PREF_IMM16:
LowerCopyRestArgs(gate, actualArgc);
LowerCopyRestArgs(gate);
break;
case EcmaOpcode::WIDE_LDPATCHVAR_PREF_IMM16:
LowerWideLdPatchVar(gate);
@ -643,7 +634,7 @@ void SlowPathLowering::Lower(GateRef gate)
break;
case EcmaOpcode::LDLOCALMODULEVAR_IMM8:
case EcmaOpcode::WIDE_LDLOCALMODULEVAR_PREF_IMM16:
LowerLdLocalModuleVarByIndex(gate, jsFunc);
LowerLdLocalModuleVarByIndex(gate);
break;
case EcmaOpcode::DEBUGGER:
case EcmaOpcode::JSTRICTEQZ_IMM8:
@ -677,11 +668,11 @@ void SlowPathLowering::Lower(GateRef gate)
break;
case EcmaOpcode::LDTHISBYNAME_IMM8_ID16:
case EcmaOpcode::LDTHISBYNAME_IMM16_ID16:
LowerLdThisByName(gate, jsFunc);
LowerLdThisByName(gate);
break;
case EcmaOpcode::STTHISBYNAME_IMM8_ID16:
case EcmaOpcode::STTHISBYNAME_IMM16_ID16:
LowerStObjByName(gate, jsFunc, true);
LowerStObjByName(gate, true);
break;
case EcmaOpcode::CALLRUNTIME_NOTIFYCONCURRENTRESULT_PREF_NONE:
LowerNotifyConcurrentResult(gate);
@ -737,7 +728,7 @@ void SlowPathLowering::LowerCreateIterResultObj(GateRef gate)
// When executing to SUSPENDGENERATOR instruction, save contextual information to GeneratorContext,
// including registers, acc, etc.
void SlowPathLowering::SaveFrameToContext(GateRef gate, GateRef jsFunc)
void SlowPathLowering::SaveFrameToContext(GateRef gate)
{
GateRef genObj = acc_.GetValueIn(gate, 1);
GateRef saveRegister = acc_.GetDep(gate);
@ -772,11 +763,12 @@ void SlowPathLowering::SaveFrameToContext(GateRef gate, GateRef jsFunc)
// set this
GateRef thisOffset = builder_.IntPtr(GeneratorContext::GENERATOR_THIS_OFFSET);
GateRef thisObj = acc_.GetValueIn(gate, 3); // 3: this object
GateRef thisObj = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::THIS_OBJECT);
builder_.Store(VariableType::JS_ANY(), glue_, context, thisOffset, thisObj);
// set method
GateRef methodOffset = builder_.IntPtr(GeneratorContext::GENERATOR_METHOD_OFFSET);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
builder_.Store(VariableType::JS_ANY(), glue_, context, methodOffset, jsFunc);
// set acc
@ -810,9 +802,9 @@ void SlowPathLowering::SaveFrameToContext(GateRef gate, GateRef jsFunc)
builder_.Store(VariableType::JS_POINTER(), glue_, context, generatorObjectOffset, genObj);
}
void SlowPathLowering::LowerSuspendGenerator(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerSuspendGenerator(GateRef gate)
{
SaveFrameToContext(gate, jsFunc);
SaveFrameToContext(gate);
acc_.SetDep(gate, builder_.GetDepend());
AddProfiling(gate, false);
const int id = RTSTUB_ID(OptSuspendGenerator);
@ -851,22 +843,13 @@ void SlowPathLowering::LowerAsyncFunctionReject(GateRef gate)
ReplaceHirWithValue(gate, newGate);
}
void SlowPathLowering::LowerLoadStr(GateRef gate, GateRef jsFunc)
{
Label successExit(&builder_);
Label exceptionExit(&builder_);
GateRef newGate = builder_.GetObjectFromConstPool(glue_, gate, jsFunc,
builder_.ZExtInt16ToInt32(acc_.GetValueIn(gate, 0)),
ConstPoolType::STRING);
ReplaceHirWithValue(gate, newGate);
}
void SlowPathLowering::LowerTryLdGlobalByName(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerTryLdGlobalByName(GateRef gate)
{
Label updateProfileTypeInfo(&builder_);
Label accessObject(&builder_);
// 2: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 2);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef slotId = builder_.ZExtInt16ToInt32(acc_.GetValueIn(gate, 0));
GateRef prop = acc_.GetValueIn(gate, 1); // 1: the second parameter
DEFVAlUE(profileTypeInfo, (&builder_), VariableType::JS_ANY(), GetProfileTypeInfo(jsFunc));
@ -882,12 +865,13 @@ void SlowPathLowering::LowerTryLdGlobalByName(GateRef gate, GateRef jsFunc)
ReplaceHirWithValue(gate, result);
}
void SlowPathLowering::LowerStGlobalVar(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerStGlobalVar(GateRef gate)
{
Label updateProfileTypeInfo(&builder_);
Label accessObject(&builder_);
// 3: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 3);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef slotId = builder_.ZExtInt16ToInt32(acc_.GetValueIn(gate, 0));
GateRef prop = acc_.GetValueIn(gate, 1); // 1: the second parameter
GateRef value = acc_.GetValueIn(gate, 2); // 2: the 2nd para is value
@ -1107,10 +1091,11 @@ void SlowPathLowering::LowerThrowUndefinedIfHole(GateRef gate)
acc_.ReplaceHirWithIfBranch(gate, successControl, failControl, Circuit::NullGate());
}
void SlowPathLowering::LowerThrowUndefinedIfHoleWithName(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerThrowUndefinedIfHoleWithName(GateRef gate)
{
// 2: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 2);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef hole = acc_.GetValueIn(gate, 1);
Label successExit(&builder_);
Label exceptionExit(&builder_);
@ -1430,13 +1415,13 @@ void SlowPathLowering::LowerIsIn(GateRef gate)
ReplaceHirWithValue(gate, newGate);
}
void SlowPathLowering::LowerInstanceof(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerInstanceof(GateRef gate)
{
Label updateProfileTypeInfo(&builder_);
Label doInstanceofWithIC(&builder_);
// 3: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 3);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef slotId = builder_.ZExtInt16ToInt32(acc_.GetValueIn(gate, 0));
GateRef obj = acc_.GetValueIn(gate, 1); // 1: the second parameter
GateRef target = acc_.GetValueIn(gate, 2); // 2: the third parameter
@ -1485,17 +1470,19 @@ void SlowPathLowering::LowerCreateEmptyObject(GateRef gate)
ReplaceHirWithValue(gate, result, true);
}
void SlowPathLowering::LowerCreateArrayWithBuffer(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerCreateArrayWithBuffer(GateRef gate)
{
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef index = builder_.TruncInt64ToInt32(acc_.GetValueIn(gate, 0));
GateRef result = builder_.CallStub(glue_, gate, CommonStubCSigns::CreateArrayWithBuffer, { glue_, index, jsFunc });
ReplaceHirWithValue(gate, result, true);
}
void SlowPathLowering::LowerCreateObjectWithBuffer(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerCreateObjectWithBuffer(GateRef gate)
{
// 2: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 2);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef index = acc_.GetValueIn(gate, 0);
GateRef obj = builder_.GetObjectFromConstPool(glue_, gate, jsFunc, builder_.TruncInt64ToInt32(index),
ConstPoolType::OBJECT_LITERAL);
@ -1504,20 +1491,22 @@ void SlowPathLowering::LowerCreateObjectWithBuffer(GateRef gate, GateRef jsFunc)
ReplaceHirWithValue(gate, result);
}
void SlowPathLowering::LowerStModuleVar(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerStModuleVar(GateRef gate)
{
// 2: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 2);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef index = builder_.ToTaggedInt(acc_.GetValueIn(gate, 0));
auto result = LowerCallRuntime(gate, RTSTUB_ID(StModuleVarByIndexOnJSFunc),
{index, acc_.GetValueIn(gate, 1), jsFunc}, true);
ReplaceHirWithValue(gate, result, true);
}
void SlowPathLowering::LowerSetGeneratorState(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerSetGeneratorState(GateRef gate)
{
// 2: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 2);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef index = builder_.ToTaggedInt(acc_.GetValueIn(gate, 0));
auto result = LowerCallRuntime(gate, RTSTUB_ID(SetGeneratorState),
{index, acc_.GetValueIn(gate, 1), jsFunc}, true);
@ -1572,46 +1561,52 @@ void SlowPathLowering::LowerToNumeric(GateRef gate)
ReplaceHirWithValue(gate, *result);
}
void SlowPathLowering::LowerDynamicImport(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerDynamicImport(GateRef gate)
{
const int id = RTSTUB_ID(DynamicImport);
// 1: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 1);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef newGate = LowerCallRuntime(gate, id, {acc_.GetValueIn(gate, 0), jsFunc});
ReplaceHirWithValue(gate, newGate);
}
void SlowPathLowering::LowerLdLocalModuleVarByIndex(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerLdLocalModuleVarByIndex(GateRef gate)
{
// 2: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 1);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef index = builder_.ToTaggedInt(acc_.GetValueIn(gate, 0));
GateRef result = LowerCallRuntime(gate, RTSTUB_ID(LdLocalModuleVarByIndexOnJSFunc), {index, jsFunc}, true);
ReplaceHirWithValue(gate, result);
}
void SlowPathLowering::LowerExternalModule(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerExternalModule(GateRef gate)
{
ASSERT(acc_.GetNumValueIn(gate) == 1);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef index = builder_.ToTaggedInt(acc_.GetValueIn(gate, 0));
GateRef result = LowerCallRuntime(gate, RTSTUB_ID(LdExternalModuleVarByIndexOnJSFunc), {index, jsFunc}, true);
ReplaceHirWithValue(gate, result);
}
void SlowPathLowering::LowerGetModuleNamespace(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerGetModuleNamespace(GateRef gate)
{
// 1: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 1);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef index = builder_.ToTaggedInt(acc_.GetValueIn(gate, 0));
GateRef result = LowerCallRuntime(gate, RTSTUB_ID(GetModuleNamespaceByIndexOnJSFunc), {index, jsFunc}, true);
ReplaceHirWithValue(gate, result);
}
void SlowPathLowering::LowerSuperCall(GateRef gate, GateRef func, GateRef newTarget)
void SlowPathLowering::LowerSuperCall(GateRef gate)
{
const int id = RTSTUB_ID(OptSuperCall);
std::vector<GateRef> vec;
ASSERT(acc_.GetNumValueIn(gate) >= 0);
GateRef func = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef newTarget = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::NEW_TARGET);
size_t numIns = acc_.GetNumValueIn(gate);
vec.emplace_back(func);
vec.emplace_back(newTarget);
@ -1622,11 +1617,12 @@ void SlowPathLowering::LowerSuperCall(GateRef gate, GateRef func, GateRef newTar
ReplaceHirWithValue(gate, newGate);
}
void SlowPathLowering::LowerSuperCallArrow(GateRef gate, GateRef newTarget)
void SlowPathLowering::LowerSuperCallArrow(GateRef gate)
{
const int id = RTSTUB_ID(OptSuperCall);
std::vector<GateRef> vec;
ASSERT(acc_.GetNumValueIn(gate) > 0);
GateRef newTarget = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::NEW_TARGET);
size_t numIns = acc_.GetNumValueIn(gate);
size_t funcIndex = numIns - 1;
GateRef func = acc_.GetValueIn(gate, funcIndex);
@ -1639,11 +1635,12 @@ void SlowPathLowering::LowerSuperCallArrow(GateRef gate, GateRef newTarget)
ReplaceHirWithValue(gate, newGate);
}
void SlowPathLowering::LowerSuperCallSpread(GateRef gate, GateRef newTarget)
void SlowPathLowering::LowerSuperCallSpread(GateRef gate)
{
const int id = RTSTUB_ID(OptSuperCallSpread);
// 2: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 2);
GateRef newTarget = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::NEW_TARGET);
GateRef func = acc_.GetValueIn(gate, 1);
GateRef array = acc_.GetValueIn(gate, 0);
GateRef newGate = LowerCallRuntime(gate, id, { func, newTarget, array });
@ -1948,10 +1945,11 @@ void SlowPathLowering::LowerNewLexicalEnv(GateRef gate)
ReplaceHirWithValue(gate, result);
}
void SlowPathLowering::LowerNewLexicalEnvWithName(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerNewLexicalEnvWithName(GateRef gate)
{
// 3: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 3);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef lexEnv = acc_.GetValueIn(gate, 2); // 2: Get current lexEnv
auto args = { builder_.ToTaggedInt(acc_.GetValueIn(gate, 0)),
builder_.ToTaggedInt(acc_.GetValueIn(gate, 1)),
@ -1968,22 +1966,24 @@ void SlowPathLowering::LowerPopLexicalEnv(GateRef gate)
ReplaceHirWithValue(gate, parentEnv, true);
}
void SlowPathLowering::LowerLdSuperByValue(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerLdSuperByValue(GateRef gate)
{
const int id = RTSTUB_ID(OptLdSuperByValue);
// 2: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 2);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef receiver = acc_.GetValueIn(gate, 0);
GateRef propKey = acc_.GetValueIn(gate, 1);
GateRef newGate = LowerCallRuntime(gate, id, { receiver, propKey, jsFunc });
ReplaceHirWithValue(gate, newGate);
}
void SlowPathLowering::LowerStSuperByValue(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerStSuperByValue(GateRef gate)
{
const int id = RTSTUB_ID(OptStSuperByValue);
// 3: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 3);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef receiver = acc_.GetValueIn(gate, 0);
GateRef propKey = acc_.GetValueIn(gate, 1);
GateRef value = acc_.GetValueIn(gate, 2);
@ -1991,12 +1991,13 @@ void SlowPathLowering::LowerStSuperByValue(GateRef gate, GateRef jsFunc)
ReplaceHirWithValue(gate, newGate);
}
void SlowPathLowering::LowerTryStGlobalByName(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerTryStGlobalByName(GateRef gate)
{
Label updateProfileTypeInfo(&builder_);
Label accessObject(&builder_);
// 3: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 3);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef slotId = builder_.ZExtInt16ToInt32(acc_.GetValueIn(gate, 0));
GateRef prop = acc_.GetValueIn(gate, 1); // 1: the second parameter
GateRef value = acc_.GetValueIn(gate, 2); // 2: the 2nd para is value
@ -2126,12 +2127,13 @@ void SlowPathLowering::LowerStOwnByNameWithNameSet(GateRef gate)
acc_.ReplaceHirWithIfBranch(gate, successControl, failControl, Circuit::NullGate());
}
void SlowPathLowering::LowerLdGlobalVar(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerLdGlobalVar(GateRef gate)
{
Label updateProfileTypeInfo(&builder_);
Label accessObject(&builder_);
// 2: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 2);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef slotId = builder_.ZExtInt16ToInt32(acc_.GetValueIn(gate, 0));
GateRef prop = acc_.GetValueIn(gate, 1); // 1: the second parameter
DEFVAlUE(profileTypeInfo, (&builder_), VariableType::JS_ANY(), GetProfileTypeInfo(jsFunc));
@ -2147,12 +2149,13 @@ void SlowPathLowering::LowerLdGlobalVar(GateRef gate, GateRef jsFunc)
ReplaceHirWithValue(gate, result);
}
void SlowPathLowering::LowerLdObjByName(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerLdObjByName(GateRef gate)
{
Label updateProfileTypeInfo(&builder_);
Label accessObject(&builder_);
// 3: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 3);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef slotId = builder_.ZExtInt16ToInt32(acc_.GetValueIn(gate, 0));
GateRef prop = acc_.GetValueIn(gate, 1); // 1: the second parameter
GateRef receiver = acc_.GetValueIn(gate, 2); // 2: the third parameter
@ -2169,15 +2172,16 @@ void SlowPathLowering::LowerLdObjByName(GateRef gate, GateRef jsFunc)
ReplaceHirWithValue(gate, result);
}
void SlowPathLowering::LowerStObjByName(GateRef gate, GateRef jsFunc, bool isThis)
void SlowPathLowering::LowerStObjByName(GateRef gate, bool isThis)
{
Label updateProfileTypeInfo(&builder_);
Label accessObject(&builder_);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef receiver;
GateRef value;
if (isThis) {
ASSERT(acc_.GetNumValueIn(gate) == 4); // 4: number of value inputs
receiver = acc_.GetValueIn(gate, 3); // 3: this object
ASSERT(acc_.GetNumValueIn(gate) == 3); // 3: number of value inputs
receiver = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::THIS_OBJECT);
value = acc_.GetValueIn(gate, 2); // 2: the third para is value
} else {
// 4: number of value inputs
@ -2273,17 +2277,18 @@ void SlowPathLowering::LowerStObjByIndex(GateRef gate)
ReplaceHirWithValue(gate, *result);
}
void SlowPathLowering::LowerLdObjByValue(GateRef gate, GateRef jsFunc, bool isThis)
void SlowPathLowering::LowerLdObjByValue(GateRef gate, bool isThis)
{
Label updateProfileTypeInfo(&builder_);
Label accessObject(&builder_);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef receiver;
GateRef propKey;
if (isThis) {
// 3: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 3);
receiver = acc_.GetValueIn(gate, 2); // 2: this object
// 2: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 2);
receiver = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::THIS_OBJECT);
propKey = acc_.GetValueIn(gate, 1);
} else {
// 3: number of value inputs
@ -2305,16 +2310,17 @@ void SlowPathLowering::LowerLdObjByValue(GateRef gate, GateRef jsFunc, bool isTh
ReplaceHirWithValue(gate, result);
}
void SlowPathLowering::LowerStObjByValue(GateRef gate, GateRef jsFunc, bool isThis)
void SlowPathLowering::LowerStObjByValue(GateRef gate, bool isThis)
{
Label updateProfileTypeInfo(&builder_);
Label accessObject(&builder_);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef receiver;
GateRef propKey;
GateRef value;
if (isThis) {
ASSERT(acc_.GetNumValueIn(gate) == 4); // 4: number of value inputs
receiver = acc_.GetValueIn(gate, 3); // 3: this object
ASSERT(acc_.GetNumValueIn(gate) == 3); // 3: number of value inputs
receiver = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::THIS_OBJECT);
propKey = acc_.GetValueIn(gate, 1);
value = acc_.GetValueIn(gate, 2); // 2: the third parameter
} else {
@ -2338,20 +2344,22 @@ void SlowPathLowering::LowerStObjByValue(GateRef gate, GateRef jsFunc, bool isTh
ReplaceHirWithValue(gate, result);
}
void SlowPathLowering::LowerLdSuperByName(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerLdSuperByName(GateRef gate)
{
// 2: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 2);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef prop = acc_.GetValueIn(gate, 0);
GateRef result =
LowerCallRuntime(gate, RTSTUB_ID(OptLdSuperByValue), {acc_.GetValueIn(gate, 1), prop, jsFunc}, true);
ReplaceHirWithValue(gate, result);
}
void SlowPathLowering::LowerStSuperByName(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerStSuperByName(GateRef gate)
{
// 3: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 3);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef prop = acc_.GetValueIn(gate, 0);
auto args2 = { acc_.GetValueIn(gate, 1), prop, acc_.GetValueIn(gate, 2), jsFunc };
GateRef result = LowerCallRuntime(gate, RTSTUB_ID(OptStSuperByValue), args2, true);
@ -2475,12 +2483,13 @@ void SlowPathLowering::LowerStLexVar(GateRef gate)
ReplaceHirWithValue(gate, result, true);
}
void SlowPathLowering::LowerDefineClassWithBuffer(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerDefineClassWithBuffer(GateRef gate)
{
GateType type = acc_.GetGateType(gate);
// 5: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 5);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef methodId = acc_.GetValueIn(gate, 0);
GateRef proto = acc_.GetValueIn(gate, 3);
GateRef literalId = acc_.GetValueIn(gate, 1);
@ -2528,8 +2537,9 @@ void SlowPathLowering::LowerDefineClassWithBuffer(GateRef gate, GateRef jsFunc)
acc_.ReplaceHirWithIfBranch(gate, successControl, failControl, result);
}
void SlowPathLowering::LowerDefineFunc(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerDefineFunc(GateRef gate)
{
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef methodId = builder_.TruncInt64ToInt32(acc_.GetValueIn(gate, 0));
GateRef length = acc_.GetValueIn(gate, 1);
auto method = builder_.GetObjectFromConstPool(glue_, gate, jsFunc, methodId, ConstPoolType::METHOD);
@ -2805,10 +2815,11 @@ void SlowPathLowering::LowerGetResumeMode(GateRef gate)
ReplaceHirWithValue(gate, *result, true);
}
void SlowPathLowering::LowerDefineMethod(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerDefineMethod(GateRef gate)
{
// 4: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 4);
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef methodId = builder_.TruncInt64ToInt32(acc_.GetValueIn(gate, 0));
auto method = builder_.GetObjectFromConstPool(glue_, gate, jsFunc, methodId, ConstPoolType::METHOD);
GateRef length = acc_.GetValueIn(gate, 1);
@ -2834,15 +2845,17 @@ void SlowPathLowering::LowerDefineMethod(GateRef gate, GateRef jsFunc)
acc_.ReplaceHirWithIfBranch(gate, successControl, failControl, result);
}
void SlowPathLowering::LowerGetUnmappedArgs(GateRef gate, GateRef actualArgc)
void SlowPathLowering::LowerGetUnmappedArgs(GateRef gate)
{
GateRef actualArgc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::ACTUAL_ARGC);
GateRef newGate = builder_.CallStub(glue_, gate, CommonStubCSigns::GetUnmapedArgs,
{ glue_, builder_.TruncInt64ToInt32(actualArgc) });
ReplaceHirWithValue(gate, newGate);
}
void SlowPathLowering::LowerCopyRestArgs(GateRef gate, GateRef actualArgc)
void SlowPathLowering::LowerCopyRestArgs(GateRef gate)
{
GateRef actualArgc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::ACTUAL_ARGC);
GateRef taggedArgc = builder_.ToTaggedInt(actualArgc);
GateRef restIdx = acc_.GetValueIn(gate, 0);
GateRef taggedRestIdx = builder_.ToTaggedInt(restIdx);
@ -3033,13 +3046,14 @@ void SlowPathLowering::LowerCallthis3Imm8V8V8V8V8(GateRef gate)
LowerToJSCall(gate, {glue_, env, actualArgc, func, newTarget, thisObj, a0Value, a1Value, a2Value});
}
void SlowPathLowering::LowerLdThisByName(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerLdThisByName(GateRef gate)
{
Label updateProfileTypeInfo(&builder_);
Label accessObject(&builder_);
ASSERT(acc_.GetNumValueIn(gate) == 3); // 3: number of parameter
GateRef thisObj = acc_.GetValueIn(gate, 2); // 2: this object
ASSERT(acc_.GetNumValueIn(gate) == 2); // 2: number of parameter
GateRef jsFunc = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateRef thisObj = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::THIS_OBJECT);
GateRef slotId = builder_.ZExtInt16ToInt32(acc_.GetValueIn(gate, 0));
GateRef prop = acc_.GetValueIn(gate, 1); // 1: the second parameter
DEFVAlUE(profileTypeInfo, (&builder_), VariableType::JS_ANY(), GetProfileTypeInfo(jsFunc));
@ -3058,7 +3072,7 @@ void SlowPathLowering::LowerLdThisByName(GateRef gate, GateRef jsFunc)
void SlowPathLowering::LowerConstPoolData(GateRef gate)
{
Environment env(0, &builder_);
GateRef jsFunc = argAcc_.GetCommonArgGate(CommonArgIdx::FUNC);
GateRef jsFunc = acc_.GetValueIn(gate, 0);
ConstDataId dataId = acc_.GetConstDataId(gate);
auto newGate = LoadObjectFromConstPool(jsFunc, builder_.Int32(dataId.GetId()));
// replace newGate
@ -3160,7 +3174,17 @@ void SlowPathLowering::LowerNotifyConcurrentResult(GateRef gate)
{
const int id = RTSTUB_ID(NotifyConcurrentResult);
GateRef newGate = LowerCallRuntime(gate, id, {acc_.GetValueIn(gate, 0), acc_.GetValueIn(gate, 1)});
GateRef newGate = LowerCallRuntime(gate, id, {acc_.GetValueIn(gate, 0),
argAcc_.GetFrameArgsIn(gate, FrameArgIdx::THIS_OBJECT)});
ReplaceHirWithValue(gate, newGate);
}
void SlowPathLowering::LowerGetEnv(GateRef gate)
{
GateRef jsFunc = acc_.GetValueIn(gate, 0);
GateRef envOffset = builder_.IntPtr(JSFunction::LEXICAL_ENV_OFFSET);
GateRef env = builder_.Load(VariableType::JS_ANY(), jsFunc, envOffset, acc_.GetDependRoot());
acc_.UpdateAllUses(gate, env);
acc_.DeleteGate(gate);
}
} // namespace panda::ecmascript

View File

@ -153,19 +153,16 @@ private:
// environment must be initialized
GateRef LoadObjectFromConstPool(GateRef jsFunc, GateRef index);
GateRef GetProfileTypeInfo(GateRef jsFunc);
// environment must be initialized
GateRef GetHomeObjectFromJSFunction(GateRef jsFunc);
void Lower(GateRef gate);
void LowerAdd2(GateRef gate);
void LowerCreateIterResultObj(GateRef gate);
void SaveFrameToContext(GateRef gate, GateRef jsFunc);
void LowerSuspendGenerator(GateRef gate, GateRef jsFunc);
void SaveFrameToContext(GateRef gate);
void LowerSuspendGenerator(GateRef gate);
void LowerAsyncFunctionAwaitUncaught(GateRef gate);
void LowerAsyncFunctionResolve(GateRef gate);
void LowerAsyncFunctionReject(GateRef gate);
void LowerLoadStr(GateRef gate, GateRef jsFunc);
void LowerStGlobalVar(GateRef gate, GateRef jsFunc);
void LowerTryLdGlobalByName(GateRef gate, GateRef jsFunc);
void LowerStGlobalVar(GateRef gate);
void LowerTryLdGlobalByName(GateRef gate);
void LowerGetIterator(GateRef gate);
void LowerGetAsyncIterator(GateRef gate);
void LowerToJSCall(GateRef gate, const std::vector<GateRef> &args);
@ -189,7 +186,7 @@ private:
void LowerThrowPatternNonCoercible(GateRef gate);
void LowerThrowIfNotObject(GateRef gate);
void LowerThrowUndefinedIfHole(GateRef gate);
void LowerThrowUndefinedIfHoleWithName(GateRef gate, GateRef jsFunc);
void LowerThrowUndefinedIfHoleWithName(GateRef gate);
void LowerThrowIfSuperNotCorrectCall(GateRef gate);
void LowerThrowDeleteSuperProperty(GateRef gate);
void LowerLdSymbol(GateRef gate);
@ -220,25 +217,25 @@ private:
void LowerDelObjProp(GateRef gate);
void LowerExp(GateRef gate);
void LowerIsIn(GateRef gate);
void LowerInstanceof(GateRef gate, GateRef jsFunc);
void LowerInstanceof(GateRef gate);
void LowerFastStrictNotEqual(GateRef gate);
void LowerFastStrictEqual(GateRef gate);
void LowerCreateEmptyArray(GateRef gate);
void LowerCreateEmptyObject(GateRef gate);
void LowerCreateArrayWithBuffer(GateRef gate, GateRef jsFunc);
void LowerCreateObjectWithBuffer(GateRef gate, GateRef jsFunc);
void LowerStModuleVar(GateRef gate, GateRef jsFunc);
void LowerCreateArrayWithBuffer(GateRef gate);
void LowerCreateObjectWithBuffer(GateRef gate);
void LowerStModuleVar(GateRef gate);
void LowerGetTemplateObject(GateRef gate);
void LowerSetObjectWithProto(GateRef gate);
void LowerLdBigInt(GateRef gate);
void LowerToNumeric(GateRef gate);
void LowerDynamicImport(GateRef gate, GateRef jsFunc);
void LowerLdLocalModuleVarByIndex(GateRef gate, GateRef jsFunc);
void LowerExternalModule(GateRef gate, GateRef jsFunc);
void LowerGetModuleNamespace(GateRef gate, GateRef jsFunc);
void LowerSuperCall(GateRef gate, GateRef func, GateRef newTarget);
void LowerSuperCallArrow(GateRef gate, GateRef newTarget);
void LowerSuperCallSpread(GateRef gate, GateRef newTarget);
void LowerDynamicImport(GateRef gate);
void LowerLdLocalModuleVarByIndex(GateRef gate);
void LowerExternalModule(GateRef gate);
void LowerGetModuleNamespace(GateRef gate);
void LowerSuperCall(GateRef gate);
void LowerSuperCallArrow(GateRef gate);
void LowerSuperCallSpread(GateRef gate);
void LowerIsTrueOrFalse(GateRef gate, bool flag);
void LowerNewObjRange(GateRef gate);
void LowerConditionJump(GateRef gate, bool isEqualJump);
@ -249,50 +246,50 @@ private:
void LowerStOwnByValue(GateRef gate);
void LowerStOwnByIndex(GateRef gate);
void LowerStOwnByName(GateRef gate);
void LowerDefineFunc(GateRef gate, GateRef jsFunc);
void LowerDefineFunc(GateRef gate);
void LowerNewLexicalEnv(GateRef gate);
void LowerNewLexicalEnvWithName(GateRef gate, GateRef jsFunc);
void LowerNewLexicalEnvWithName(GateRef gate);
void LowerPopLexicalEnv(GateRef gate);
void LowerLdSuperByValue(GateRef gate, GateRef jsFunc);
void LowerStSuperByValue(GateRef gate, GateRef jsFunc);
void LowerTryStGlobalByName(GateRef gate, GateRef jsFunc);
void LowerLdSuperByValue(GateRef gate);
void LowerStSuperByValue(GateRef gate);
void LowerTryStGlobalByName(GateRef gate);
void LowerStConstToGlobalRecord(GateRef gate, bool isConst);
void LowerStOwnByValueWithNameSet(GateRef gate);
void LowerStOwnByNameWithNameSet(GateRef gate);
void LowerLdGlobalVar(GateRef gate, GateRef jsFunc);
void LowerLdObjByName(GateRef gate, GateRef jsFunc);
void LowerStObjByName(GateRef gate, GateRef jsFunc, bool isThis);
void LowerLdSuperByName(GateRef gate, GateRef jsFunc);
void LowerStSuperByName(GateRef gate, GateRef jsFunc);
void LowerLdGlobalVar(GateRef gate);
void LowerLdObjByName(GateRef gate);
void LowerStObjByName(GateRef gate, bool isThis);
void LowerLdSuperByName(GateRef gate);
void LowerStSuperByName(GateRef gate);
void LowerDefineGetterSetterByValue(GateRef gate);
void LowerLdObjByIndex(GateRef gate);
void LowerStObjByIndex(GateRef gate);
void LowerLdObjByValue(GateRef gate, GateRef jsFunc, bool isThis);
void LowerStObjByValue(GateRef gate, GateRef jsFunc, bool isThis);
void LowerLdObjByValue(GateRef gate, bool isThis);
void LowerStObjByValue(GateRef gate, bool isThis);
void LowerCreateGeneratorObj(GateRef gate);
void LowerStArraySpread(GateRef gate);
void LowerLdLexVar(GateRef gate);
void LowerStLexVar(GateRef gate);
void LowerDefineClassWithBuffer(GateRef gate, GateRef jsFunc);
void LowerDefineClassWithBuffer(GateRef gate);
void LowerAsyncFunctionEnter(GateRef gate);
void LowerTypeof(GateRef gate);
void LowerResumeGenerator(GateRef gate);
void LowerGetResumeMode(GateRef gate);
void LowerDefineMethod(GateRef gate, GateRef jsFunc);
void LowerGetUnmappedArgs(GateRef gate, GateRef actualArgc);
void LowerCopyRestArgs(GateRef gate, GateRef actualArgc);
void LowerDefineMethod(GateRef gate);
void LowerGetUnmappedArgs(GateRef gate);
void LowerCopyRestArgs(GateRef gate);
GateRef LowerCallRuntime(GateRef gate, int index, const std::vector<GateRef> &args, bool useLabel = false);
GateRef LowerCallNGCRuntime(GateRef gate, int index, const std::vector<GateRef> &args, bool useLabel = false);
void LowerCreateAsyncGeneratorObj(GateRef gate);
void LowerAsyncGeneratorResolve(GateRef gate);
void LowerAsyncGeneratorReject(GateRef gate);
void LowerSetGeneratorState(GateRef gate, GateRef jsFunc);
void LowerSetGeneratorState(GateRef gate);
GateRef GetValueFromTaggedArray(GateRef arrayGate, GateRef indexOffset);
void AddProfiling(GateRef gate, bool skipGenerator = true);
GateRef FastStrictEqual(GateRef left, GateRef right);
void LowerWideLdPatchVar(GateRef gate);
void LowerWideStPatchVar(GateRef gate);
void LowerLdThisByName(GateRef gate, GateRef jsFunc);
void LowerLdThisByName(GateRef gate);
void LowerConstPoolData(GateRef gate);
void LowerDeoptCheck(GateRef gate);
void LowerConstruct(GateRef gate);
@ -300,6 +297,7 @@ private:
void LowerUpdateHotness(GateRef gate);
void LowerNotifyConcurrentResult(GateRef gate);
void DeleteStateSplit(GateRef gate);
void LowerGetEnv(GateRef gate);
TSManager *tsManager_ {nullptr};
const MethodLiteral *methodLiteral_ {nullptr};

View File

@ -54,7 +54,9 @@ HWTEST_F_L0(LoweringRelateGateTests, TypeCheckFramework)
auto state = acc.GetStateRoot();
auto arg0 = builder.Arguments(0);
auto pcGate = circuit.GetConstantGate(MachineType::I64, 0, GateType::NJSValue());
auto frameState = circuit.NewGate(circuit.FrameState(1), {pcGate});
auto frameArgs = circuit.NewGate(
circuit.FrameArgs(), {builder.Arguments(3), builder.Arguments(4), builder.Arguments(5), builder.Arguments(2)});
auto frameState = circuit.NewGate(circuit.FrameState(1), {pcGate, frameArgs});
auto stateSplit = circuit.NewGate(circuit.StateSplit(), {state, depend, frameState});
builder.SetDepend(stateSplit);
auto check = builder.TryPrimitiveTypeCheck(GateType::NumberType(), arg0);
@ -147,7 +149,9 @@ HWTEST_F_L0(LoweringRelateGateTests, TypeOpCodeFramework)
auto arg0 = builder.Arguments(0);
auto arg1 = builder.Arguments(1);
auto pcGate = circuit.GetConstantGate(MachineType::I64, 0, GateType::NJSValue());
auto frameState = circuit.NewGate(circuit.FrameState(1), {pcGate});
auto frameArgs = circuit.NewGate(
circuit.FrameArgs(), {builder.Arguments(3), builder.Arguments(4), builder.Arguments(5), builder.Arguments(2)});
auto frameState = circuit.NewGate(circuit.FrameState(1), {pcGate, frameArgs});
auto stateSplit = circuit.NewGate(circuit.StateSplit(), {state, depend, frameState});
builder.SetDepend(stateSplit);
builder.TryPrimitiveTypeCheck(GateType::NumberType(), arg0);

View File

@ -106,10 +106,6 @@ bool TSTypeLowering::IsTrustedType(GateRef gate) const
void TSTypeLowering::Lower(GateRef gate)
{
auto argAcc = ArgumentAccessor(circuit_);
GateRef jsFunc = argAcc.GetCommonArgGate(CommonArgIdx::FUNC);
GateRef newTarget = argAcc.GetCommonArgGate(CommonArgIdx::NEW_TARGET);
EcmaOpcode ecmaOpcode = acc_.GetByteCodeOpcode(gate);
// initialize label manager
Environment env(gate, circuit_, &builder_);
@ -233,7 +229,7 @@ void TSTypeLowering::Lower(GateRef gate)
break;
case EcmaOpcode::SUPERCALLTHISRANGE_IMM8_IMM8_V8:
case EcmaOpcode::WIDE_SUPERCALLTHISRANGE_PREF_IMM16_V8:
LowerTypedSuperCall(gate, jsFunc, newTarget);
LowerTypedSuperCall(gate);
break;
case EcmaOpcode::CALLTHIS1_IMM8_V8_V8:
LowerCallThis1Imm8V8V8(gate);
@ -682,9 +678,9 @@ void TSTypeLowering::LowerTypedStObjByName(GateRef gate, bool isThis)
GateRef receiver = Circuit::NullGate();
GateRef value = Circuit::NullGate();
if (isThis) {
// 4: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 4);
receiver = acc_.GetValueIn(gate, 3); // 3: this object
// 3: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 3);
receiver = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::THIS_OBJECT);
value = acc_.GetValueIn(gate, 2); // 2: acc
} else {
// 4: number of value inputs
@ -800,9 +796,9 @@ void TSTypeLowering::LowerTypedLdObjByValue(GateRef gate, bool isThis)
GateRef receiver = Circuit::NullGate();
GateRef propKey = Circuit::NullGate();
if (isThis) {
// 3: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 3);
receiver = acc_.GetValueIn(gate, 2); // 2: this object
// 2: number of value inputs
ASSERT(acc_.GetNumValueIn(gate) == 2);
receiver = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::THIS_OBJECT);
propKey = acc_.GetValueIn(gate, 1);
} else {
// 3: number of value inputs
@ -882,8 +878,9 @@ void TSTypeLowering::LowerTypedNewObjRange(GateRef gate)
acc_.ReplaceGate(gate, builder_.GetState(), builder_.GetDepend(), constructGate);
}
void TSTypeLowering::LowerTypedSuperCall(GateRef gate, GateRef ctor, GateRef newTarget)
void TSTypeLowering::LowerTypedSuperCall(GateRef gate)
{
GateRef ctor = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
GateType ctorType = acc_.GetGateType(ctor); // ldfunction in derived constructor get function type
if (!tsManager_->IsClassTypeKind(ctorType) && !tsManager_->IsFunctionTypeKind(ctorType)) {
acc_.DeleteStateSplitAndFrameState(gate);
@ -898,6 +895,7 @@ void TSTypeLowering::LowerTypedSuperCall(GateRef gate, GateRef ctor, GateRef new
GateRef frameState = acc_.GetFrameState(stateSplit);
GateRef superCtor = builder_.GetSuperConstructor(ctor);
GateRef newTarget = argAcc_.GetFrameArgsIn(gate, FrameArgIdx::NEW_TARGET);
GateRef thisObj = builder_.TypedSuperAllocateThis(superCtor, newTarget, frameState);
// call constructor

View File

@ -32,7 +32,8 @@ public:
tsManager_(info->GetTSManager()),
enableLog_(enableLog),
profiling_(info->GetCompilerConfig()->IsProfiling()),
methodName_(name), glue_(acc_.GetGlueFromArgList()) {}
methodName_(name), glue_(acc_.GetGlueFromArgList()),
argAcc_(circuit) {}
~TSTypeLowering() = default;
@ -88,7 +89,7 @@ private:
void LowerTypedLdObjByValue(GateRef gate, bool isThis);
void LowerTypedIsTrueOrFalse(GateRef gate, bool flag);
void LowerTypedNewObjRange(GateRef gate);
void LowerTypedSuperCall(GateRef gate, GateRef ctor, GateRef newTarget);
void LowerTypedSuperCall(GateRef gate);
void LowerCallThis1Imm8V8V8(GateRef gate);
void LowerTypedCallArg0(GateRef gate);
@ -121,6 +122,7 @@ private:
bool profiling_ {false};
std::string methodName_;
GateRef glue_ {Circuit::NullGate()};
ArgumentAccessor argAcc_;
};
} // panda::ecmascript::kungfu
#endif // ECMASCRIPT_COMPILER_TS_TYPE_LOWERING_H

View File

@ -802,7 +802,7 @@ bool TypeInfer::InferDefineGetterSetterByValue(GateRef gate)
bool TypeInfer::InferSuperCall(GateRef gate)
{
ArgumentAccessor argAcc(circuit_);
auto newTarget = argAcc.GetCommonArgGate(CommonArgIdx::NEW_TARGET);
auto newTarget = argAcc.GetFrameArgsIn(gate, FrameArgIdx::NEW_TARGET);
auto classType = gateAccessor_.GetGateType(newTarget);
if (tsManager_->IsClassTypeKind(classType)) {
auto classInstanceType = tsManager_->CreateClassInstanceType(classType);
@ -836,8 +836,8 @@ bool TypeInfer::InferSuperPropertyByValue(GateRef gate)
bool TypeInfer::GetSuperProp(GateRef gate, uint64_t index, bool isString)
{
ArgumentAccessor argAcc(circuit_);
auto func = argAcc.GetCommonArgGate(CommonArgIdx::FUNC);
auto newTarget = argAcc.GetCommonArgGate(CommonArgIdx::NEW_TARGET);
auto func = argAcc.GetFrameArgsIn(gate, FrameArgIdx::FUNC);
auto newTarget = argAcc.GetFrameArgsIn(gate, FrameArgIdx::NEW_TARGET);
auto funcType = gateAccessor_.GetGateType(func);
auto classType = gateAccessor_.GetGateType(newTarget);
if (!funcType.IsAnyType() && !classType.IsAnyType()) {

View File

@ -283,7 +283,7 @@ void TypeLowering::LowerTSSubtypingCheck(GateRef gate)
GateRef frameState = GetFrameState(gate);
ArgumentAccessor argAcc(circuit_);
GateRef jsFunc = argAcc.GetCommonArgGate(CommonArgIdx::FUNC);
GateRef jsFunc = argAcc.GetFrameArgsIn(frameState, FrameArgIdx::FUNC);
GateRef receiver = acc_.GetValueIn(gate, 0);
GateRef aotHCIndex = acc_.GetValueIn(gate, 1);
@ -2999,8 +2999,8 @@ void TypeLowering::LowerJSCallTargetTypeCheck(GateRef gate)
auto type = acc_.GetParamGateType(gate);
if (tsManager_->IsFunctionTypeKind(type)) {
ArgumentAccessor argAcc(circuit_);
GateRef jsFunc = argAcc.GetCommonArgGate(CommonArgIdx::FUNC);
GateRef frameState = GetFrameState(gate);
GateRef jsFunc = argAcc.GetFrameArgsIn(frameState, FrameArgIdx::FUNC);
auto func = acc_.GetValueIn(gate, 0);
auto methodIndex = acc_.GetValueIn(gate, 1);
GateRef isObj = builder_.TaggedIsHeapObject(func);
@ -3037,7 +3037,8 @@ void TypeLowering::LowerTypedNewAllocateThis(GateRef gate, GateRef glue)
{
Environment env(gate, circuit_, &builder_);
ArgumentAccessor argAcc(circuit_);
GateRef jsFunc = argAcc.GetCommonArgGate(CommonArgIdx::FUNC);
GateRef frameState = GetFrameState(gate);
GateRef jsFunc = argAcc.GetFrameArgsIn(frameState, FrameArgIdx::FUNC);
GateRef ctor = acc_.GetValueIn(gate, 0);
@ -3056,7 +3057,6 @@ void TypeLowering::LowerTypedNewAllocateThis(GateRef gate, GateRef glue)
GateRef ihclassIndex = acc_.GetValueIn(gate, 1);
GateRef ihclass = GetObjectFromConstPool(jsFunc, ihclassIndex);
GateRef check = builder_.Equal(protoOrHclass, ihclass);
GateRef frameState = GetFrameState(gate);
builder_.DeoptCheck(check, frameState);
thisObj = builder_.CallStub(glue, gate, CommonStubCSigns::NewJSObject, { glue, protoOrHclass });

View File

@ -257,17 +257,17 @@ bool Deoptimizier::CollectVirtualRegisters(Method* method, FrameWriter *frameWri
// [reserved args]
if (method->HaveThisWithCallField()) {
JSTaggedValue value = GetFrameArgv(kungfu::CommonArgIdx::THIS_OBJECT);
JSTaggedValue value = deoptVregs_.at(static_cast<kungfu::OffsetType>(SpecVregIndex::THIS_OBJECT_INDEX));
frameWriter->PushValue(value.GetRawData());
virtualIndex--;
}
if (method->HaveNewTargetWithCallField()) {
JSTaggedValue value = GetFrameArgv(kungfu::CommonArgIdx::NEW_TARGET);
JSTaggedValue value = deoptVregs_.at(static_cast<kungfu::OffsetType>(SpecVregIndex::NEWTARGET_INDEX));
frameWriter->PushValue(value.GetRawData());
virtualIndex--;
}
if (method->HaveFuncWithCallField()) {
JSTaggedValue value = GetFrameArgv(kungfu::CommonArgIdx::FUNC);
JSTaggedValue value = deoptVregs_.at(static_cast<kungfu::OffsetType>(SpecVregIndex::FUNC_INDEX));
frameWriter->PushValue(value.GetRawData());
virtualIndex--;
}
@ -335,7 +335,7 @@ std::string Deoptimizier::DisplayItems(kungfu::DeoptType type)
JSTaggedType Deoptimizier::ConstructAsmInterpretFrame(kungfu::DeoptType type)
{
JSTaggedValue callTarget = GetFrameArgv(kungfu::CommonArgIdx::FUNC);
JSTaggedValue callTarget = GetDeoptValue(static_cast<int32_t>(SpecVregIndex::FUNC_INDEX));
auto method = GetMethod(callTarget);
Dump(method, type);
ASSERT(thread_ != nullptr);
@ -357,7 +357,7 @@ JSTaggedType Deoptimizier::ConstructAsmInterpretFrame(kungfu::DeoptType type)
AsmInterpretedFrame *statePtr = frameWriter.ReserveAsmInterpretedFrame();
const uint8_t *resumePc = method->GetBytecodeArray() + pc_;
JSTaggedValue thisObj = GetFrameArgv(kungfu::CommonArgIdx::THIS_OBJECT);
JSTaggedValue thisObj = GetDeoptValue(static_cast<int32_t>(SpecVregIndex::THIS_OBJECT_INDEX));
auto acc = GetDeoptValue(static_cast<int32_t>(SpecVregIndex::ACC_INDEX));
statePtr->function = callTarget;
statePtr->acc = acc;

View File

@ -29,6 +29,9 @@ enum class SpecVregIndex: int {
PC_OFFSET_INDEX = -1,
ACC_INDEX = -2,
ENV_INDEX = -3,
FUNC_INDEX = -4,
NEWTARGET_INDEX = -5,
THIS_OBJECT_INDEX = -6,
};
struct Context {