Move ProfileTypeInfo from JSFunction to Method

Signed-off-by: g00416891 <guobingbing3@huawei.com>
Change-Id: Ic791f4577120806f39754aa783f49d1f84dc078e
This commit is contained in:
g00416891 2022-10-22 15:50:58 +08:00
parent a2c1c52e33
commit facdbd970e
23 changed files with 87 additions and 96 deletions

View File

@ -240,9 +240,9 @@ GateRef InterpreterStubBuilder::GetEnvFromFunction(GateRef function)
return Load(VariableType::JS_POINTER(), function, IntPtr(JSFunction::LEXICAL_ENV_OFFSET));
}
GateRef InterpreterStubBuilder::GetProfileTypeInfoFromFunction(GateRef function)
GateRef InterpreterStubBuilder::GetProfileTypeInfoFromMethod(GateRef method)
{
return Load(VariableType::JS_POINTER(), function, IntPtr(JSFunction::PROFILE_TYPE_INFO_OFFSET));
return Load(VariableType::JS_POINTER(), method, IntPtr(Method::PROFILE_TYPE_INFO_OFFSET));
}
GateRef InterpreterStubBuilder::GetModuleFromFunction(GateRef function)
@ -255,11 +255,9 @@ GateRef InterpreterStubBuilder::GetHomeObjectFromFunction(GateRef function)
return Load(VariableType::JS_POINTER(), function, IntPtr(JSFunction::HOME_OBJECT_OFFSET));
}
GateRef InterpreterStubBuilder::GetConstpoolFromFunction(GateRef function)
GateRef InterpreterStubBuilder::GetConstpoolFromMethod(GateRef method)
{
GateRef method = GetMethodFromJSFunction(function);
GateRef offset = IntPtr(Method::CONSTANT_POOL_OFFSET);
return Load(VariableType::JS_POINTER(), method, offset);
return Load(VariableType::JS_POINTER(), method, IntPtr(Method::CONSTANT_POOL_OFFSET));
}
GateRef InterpreterStubBuilder::GetResumeModeFromGeneratorObject(GateRef obj)

View File

@ -3693,10 +3693,9 @@ DECLARE_ASM_HANDLER(HandleReturn)
Bind(&pcNotEqualNullptr);
{
GateRef function = GetFunctionFromFrame(prevState);
varConstpool = GetConstpoolFromFunction(function);
varProfileTypeInfo = GetProfileTypeInfoFromFunction(function);
GateRef method = Load(VariableType::JS_ANY(), function,
IntPtr(JSFunctionBase::METHOD_OFFSET));
GateRef method = Load(VariableType::JS_ANY(), function, IntPtr(JSFunctionBase::METHOD_OFFSET));
varConstpool = GetConstpoolFromMethod(method);
varProfileTypeInfo = GetProfileTypeInfoFromMethod(method);
varHotnessCounter = GetHotnessCounterFromMethod(method);
GateRef jumpSize = GetCallSizeFromFrame(prevState);
CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
@ -3754,10 +3753,9 @@ DECLARE_ASM_HANDLER(HandleReturnundefined)
Bind(&pcNotEqualNullptr);
{
GateRef function = GetFunctionFromFrame(prevState);
varConstpool = GetConstpoolFromFunction(function);
varProfileTypeInfo = GetProfileTypeInfoFromFunction(function);
GateRef method = Load(VariableType::JS_ANY(), function,
IntPtr(JSFunctionBase::METHOD_OFFSET));
GateRef method = Load(VariableType::JS_ANY(), function, IntPtr(JSFunctionBase::METHOD_OFFSET));
varConstpool = GetConstpoolFromMethod(method);
varProfileTypeInfo = GetProfileTypeInfoFromMethod(method);
varHotnessCounter = GetHotnessCounterFromMethod(method);
GateRef jumpSize = GetCallSizeFromFrame(prevState);
CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
@ -3826,10 +3824,9 @@ DECLARE_ASM_HANDLER(HandleSuspendgeneratorV8)
Bind(&pcNotEqualNullptr);
{
GateRef function = GetFunctionFromFrame(prevState);
varConstpool = GetConstpoolFromFunction(function);
varProfileTypeInfo = GetProfileTypeInfoFromFunction(function);
GateRef method = Load(VariableType::JS_ANY(), function,
IntPtr(JSFunctionBase::METHOD_OFFSET));
GateRef method = Load(VariableType::JS_ANY(), function, IntPtr(JSFunctionBase::METHOD_OFFSET));
varConstpool = GetConstpoolFromMethod(method);
varProfileTypeInfo = GetProfileTypeInfoFromMethod(method);
varHotnessCounter = GetHotnessCounterFromMethod(method);
GateRef jumpSize = GetCallSizeFromFrame(prevState);
CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
@ -3898,10 +3895,9 @@ DECLARE_ASM_HANDLER(HandleDeprecatedSuspendgeneratorPrefV8V8)
Bind(&pcNotEqualNullptr);
{
GateRef function = GetFunctionFromFrame(prevState);
varConstpool = GetConstpoolFromFunction(function);
varProfileTypeInfo = GetProfileTypeInfoFromFunction(function);
GateRef method = Load(VariableType::JS_ANY(), function,
IntPtr(JSFunctionBase::METHOD_OFFSET));
GateRef method = Load(VariableType::JS_ANY(), function, IntPtr(JSFunctionBase::METHOD_OFFSET));
varConstpool = GetConstpoolFromMethod(method);
varProfileTypeInfo = GetProfileTypeInfoFromMethod(method);
varHotnessCounter = GetHotnessCounterFromMethod(method);
GateRef jumpSize = GetCallSizeFromFrame(prevState);
CallNGCRuntime(glue, RTSTUB_ID(ResumeRspAndDispatch),
@ -6569,10 +6565,9 @@ DECLARE_ASM_HANDLER_NOPRINT(ExceptionHandler)
// clear exception
Store(VariableType::INT64(), glue, glue, exceptionOffset, Hole());
GateRef function = GetFunctionFromFrame(GetFrame(*varSp));
varConstpool = GetConstpoolFromFunction(function);
varProfileTypeInfo = GetProfileTypeInfoFromFunction(function);
GateRef method = Load(VariableType::JS_ANY(), function,
IntPtr(JSFunctionBase::METHOD_OFFSET));
GateRef method = Load(VariableType::JS_ANY(), function, IntPtr(JSFunctionBase::METHOD_OFFSET));
varConstpool = GetConstpoolFromMethod(method);
varProfileTypeInfo = GetProfileTypeInfoFromMethod(method);
varHotnessCounter = GetHotnessCounterFromMethod(method);
CallNGCRuntime(glue, RTSTUB_ID(ResumeCaughtFrameAndDispatch), {
glue, *varSp, *varPc, *varConstpool,
@ -6612,10 +6607,9 @@ DECLARE_ASM_HANDLER(SingleStepDebugging)
{
varAcc = GetAccFromFrame(frame);
GateRef function = GetFunctionFromFrame(frame);
varProfileTypeInfo = GetProfileTypeInfoFromFunction(function);
varConstpool = GetConstpoolFromFunction(function);
GateRef method = Load(VariableType::JS_ANY(), function,
IntPtr(JSFunctionBase::METHOD_OFFSET));
GateRef method = Load(VariableType::JS_ANY(), function, IntPtr(JSFunctionBase::METHOD_OFFSET));
varProfileTypeInfo = GetProfileTypeInfoFromMethod(method);
varConstpool = GetConstpoolFromMethod(method);
varHotnessCounter = GetHotnessCounterFromMethod(method);
}
Label isException(env);

View File

@ -72,8 +72,8 @@ public:
inline GateRef GetAccFromFrame(GateRef frame);
inline GateRef GetEnvFromFrame(GateRef frame);
inline GateRef GetEnvFromFunction(GateRef frame);
inline GateRef GetConstpoolFromFunction(GateRef function);
inline GateRef GetProfileTypeInfoFromFunction(GateRef function);
inline GateRef GetConstpoolFromMethod(GateRef function);
inline GateRef GetProfileTypeInfoFromMethod(GateRef function);
inline GateRef GetModuleFromFunction(GateRef function);
inline GateRef GetHomeObjectFromFunction(GateRef function);
inline GateRef GetResumeModeFromGeneratorObject(GateRef obj);

View File

@ -173,7 +173,7 @@ void AsmInterpreterCall::JSCallCommonEntry(ExtendedAssembler *assembler, JSCallM
__ Mov(temp, callTargetRegister);
__ Ldr(Register(X20), MemoryOperand(methodRegister, Method::NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET));
// Reload constpool and profileInfo to make sure gc map work normally
__ Ldr(Register(X22), MemoryOperand(temp, JSFunction::PROFILE_TYPE_INFO_OFFSET));
__ Ldr(Register(X22), MemoryOperand(methodRegister, Method::PROFILE_TYPE_INFO_OFFSET));
__ Ldr(Register(X21), MemoryOperand(methodRegister, Method::CONSTANT_POOL_OFFSET));
__ Mov(temp, kungfu::BytecodeStubCSigns::ID_ThrowStackOverflowException);
@ -934,7 +934,7 @@ void AsmInterpreterCall::GeneratorReEnterAsmInterpDispatch(ExtendedAssembler *as
__ Align16(currentSlotRegister);
__ Mov(Register(SP), currentSlotRegister);
// call bc stub
CallBCStub(assembler, newSp, glue, callTarget, method, pc, temp);
CallBCStub(assembler, newSp, glue, method, pc, temp);
__ Bind(&stackOverflow);
{
@ -1043,7 +1043,6 @@ void AsmInterpreterCall::DispatchCall(ExtendedAssembler *assembler, Register pcR
Register newSpRegister, Register accRegister)
{
Register glueRegister = __ GlueRegister();
Register callTargetRegister = __ CallDispatcherArgument(kungfu::CallDispatchInputs::CALL_TARGET);
Register methodRegister = __ CallDispatcherArgument(kungfu::CallDispatchInputs::METHOD);
if (glueRegister.GetId() != X19) {
@ -1055,7 +1054,7 @@ void AsmInterpreterCall::DispatchCall(ExtendedAssembler *assembler, Register pcR
} else {
ASSERT(accRegister == Register(X23));
}
__ Ldr(Register(X22), MemoryOperand(callTargetRegister, JSFunction::PROFILE_TYPE_INFO_OFFSET));
__ Ldr(Register(X22), MemoryOperand(methodRegister, Method::PROFILE_TYPE_INFO_OFFSET));
__ Ldr(Register(X21), MemoryOperand(methodRegister, Method::CONSTANT_POOL_OFFSET));
__ Mov(Register(X20), pcRegister);
__ Mov(Register(FP), newSpRegister);
@ -1176,14 +1175,14 @@ void AsmInterpreterCall::PushGeneratorFrameState(ExtendedAssembler *assembler, R
}
void AsmInterpreterCall::CallBCStub(ExtendedAssembler *assembler, Register &newSp, Register &glue,
Register &callTarget, Register &method, Register &pc, Register &temp)
Register &method, Register &pc, Register &temp)
{
// prepare call entry
__ Mov(Register(X19), glue); // X19 - glue
__ Mov(Register(FP), newSp); // FP - sp
__ Mov(Register(X20), pc); // X20 - pc
__ Ldr(Register(X21), MemoryOperand(method, Method::CONSTANT_POOL_OFFSET)); // X21 - constantpool
__ Ldr(Register(X22), MemoryOperand(callTarget, JSFunction::PROFILE_TYPE_INFO_OFFSET)); // X22 - profileTypeInfo
__ Ldr(Register(X22), MemoryOperand(method, Method::PROFILE_TYPE_INFO_OFFSET)); // X22 - profileTypeInfo
__ Mov(Register(X23), Immediate(JSTaggedValue::Hole().GetRawData())); // X23 - acc
__ Ldr(Register(X24), MemoryOperand(method, Method::LITERAL_INFO_OFFSET)); // X24 - hotnessCounter

View File

@ -207,7 +207,7 @@ private:
Register &contextRegister, Register &pcRegister, Register &operatorRegister);
static void CallBCStub(ExtendedAssembler *assembler, Register &newSp, Register &glue,
Register &callTarget, Register &method, Register &pc, Register &temp);
Register &method, Register &pc, Register &temp);
static void CallNativeEntry(ExtendedAssembler *assembler);

View File

@ -106,7 +106,7 @@ void AsmInterpreterCall::GeneratorReEnterAsmInterpDispatch(ExtendedAssembler *as
contextRegister, pcRegister, tempRegister);
// call bc stub
DispatchCall(assembler, pcRegister, newSpRegister, callTargetRegister, methodRegister);
DispatchCall(assembler, pcRegister, newSpRegister, methodRegister);
__ Bind(&stackOverflow);
{
ThrowStackOverflowExceptionAndReturn(assembler, glueRegister, fpRegister, tempRegister);
@ -303,7 +303,7 @@ void AsmInterpreterCall::JSCallCommonEntry(ExtendedAssembler *assembler, JSCallM
__ Movq(callTargetRegister, tempRegister);
__ Movq(Operand(methodRegister, Method::NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET), r12); // pc: r12
// Reload constpool and profileInfo to make sure gc map work normally
__ Movq(Operand(tempRegister, JSFunction::PROFILE_TYPE_INFO_OFFSET), r14); // profileTypeInfo: r14
__ Movq(Operand(methodRegister, Method::PROFILE_TYPE_INFO_OFFSET), r14); // profileTypeInfo: r14
__ Movq(Operand(methodRegister, Method::CONSTANT_POOL_OFFSET), rbx); // constantPool: rbx
__ Movq(kungfu::BytecodeStubCSigns::ID_ThrowStackOverflowException, tempRegister);
@ -666,7 +666,7 @@ void AsmInterpreterCall::PushVregs(ExtendedAssembler *assembler, Label *stackOve
PushFrameState(assembler, prevSpRegister, fpRegister,
callTargetRegister, thisRegister, methodRegister, pcRegister, tempRegister);
}
DispatchCall(assembler, pcRegister, newSpRegister, callTargetRegister, methodRegister);
DispatchCall(assembler, pcRegister, newSpRegister, methodRegister);
}
// Input: %r13 - glue
@ -674,8 +674,7 @@ void AsmInterpreterCall::PushVregs(ExtendedAssembler *assembler, Label *stackOve
// %r12 - callTarget
// %rbx - method
void AsmInterpreterCall::DispatchCall(ExtendedAssembler *assembler, Register pcRegister,
Register newSpRegister, Register callTargetRegister, Register methodRegister,
Register accRegister)
Register newSpRegister, Register methodRegister, Register accRegister)
{
Register glueRegister = __ GlueRegister();
Label dispatchCall;
@ -685,7 +684,7 @@ void AsmInterpreterCall::DispatchCall(ExtendedAssembler *assembler, Register pcR
__ PushAlignBytes();
__ Bind(&dispatchCall);
// profileTypeInfo: r14
__ Movq(Operand(callTargetRegister, JSFunction::PROFILE_TYPE_INFO_OFFSET), r14);
__ Movq(Operand(methodRegister, Method::PROFILE_TYPE_INFO_OFFSET), r14);
// glue may rdi
if (glueRegister != r13) {
__ Movq(glueRegister, r13);

View File

@ -160,8 +160,7 @@ private:
static Register GetNewTargetRegsiter(ExtendedAssembler *assembler, JSCallMode mode, Register defaultRegister);
static void PushVregs(ExtendedAssembler *assembler, Label *stackOverflow);
static void DispatchCall(ExtendedAssembler *assembler, Register pcRegister, Register newSpRegister,
Register callTargetRegister, Register methodRegister,
Register accRegister = rInvalid);
Register methodRegister, Register accRegister = rInvalid);
static void CallNativeEntry(ExtendedAssembler *assemblSer);
static void CallNativeWithArgv(ExtendedAssembler *assembler, bool callNew);
static void CallNativeInternal(ExtendedAssembler *assembler, Register nativeCode);

View File

@ -1358,7 +1358,7 @@ void OptimizedCall::DeoptEnterAsmInterp(ExtendedAssembler *assembler)
__ Movq(Operand(callTargetRegister, JSFunctionBase::METHOD_OFFSET), methodRegister);
__ Leaq(Operand(rsp, AsmInterpretedFrame::GetSize(false)), opRegister);
AsmInterpreterCall::DispatchCall(assembler, r12, opRegister, callTargetRegister, methodRegister, rsi);
AsmInterpreterCall::DispatchCall(assembler, r12, opRegister, methodRegister, rsi);
}
__ Bind(&stackOverflow);

View File

@ -1366,9 +1366,6 @@ void JSFunction::Dump(std::ostream &os) const
os << " - FunctionExtraInfo: ";
GetFunctionExtraInfo().Dump(os);
os << "\n";
os << " - ProfileTypeInfo: ";
GetProfileTypeInfo().Dump(os);
os << "\n";
os << " - Module: ";
GetModule().Dump(os);
os << "\n";
@ -3403,6 +3400,9 @@ void Method::Dump(std::ostream &os) const
os << " - ConstantPool: ";
GetConstantPool().Dump(os);
os << "\n";
os << " - ProfileTypeInfo: ";
GetProfileTypeInfo().Dump(os);
os << "\n";
os << " - FunctionKind: " << static_cast<int>(GetFunctionKind());
os << "\n";
os << " - CodeEntryOrLiteral: " << std::hex << GetCodeEntryOrLiteral() << "\n";
@ -4109,13 +4109,13 @@ void JSFunction::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>>
vec.push_back(std::make_pair(CString("HomeObject"), GetHomeObject()));
vec.push_back(std::make_pair(CString("FunctionKind"), JSTaggedValue(static_cast<int>(GetFunctionKind()))));
vec.push_back(std::make_pair(CString("FunctionExtraInfo"), GetFunctionExtraInfo()));
vec.push_back(std::make_pair(CString("ProfileTypeInfo"), GetProfileTypeInfo()));
JSObject::DumpForSnapshot(vec);
}
void Method::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const
{
vec.push_back(std::make_pair(CString("ConstantPool"), GetConstantPool()));
vec.push_back(std::make_pair(CString("ProfileTypeInfo"), GetProfileTypeInfo()));
}
void Program::DumpForSnapshot(std::vector<std::pair<CString, JSTaggedValue>> &vec) const

View File

@ -846,9 +846,10 @@ JSTaggedValue FastRuntimeStub::NewThisObject(JSThread *thread, JSTaggedValue cto
JSHandle<JSObject> obj = factory->NewJSObjectByConstructor(ctorHandle, newTargetHandle);
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception());
Method *method = Method::Cast(ctorHandle->GetMethod().GetTaggedObject());
state->function = ctorHandle.GetTaggedValue();
state->constpool = Method::Cast(ctorHandle->GetMethod().GetTaggedObject())->GetConstantPool();
state->profileTypeInfo = ctorHandle->GetProfileTypeInfo();
state->constpool = method->GetConstantPool();
state->profileTypeInfo = method->GetProfileTypeInfo();
state->env = ctorHandle->GetLexicalEnv();
return obj.GetTaggedValue();

View File

@ -702,7 +702,7 @@ JSTaggedValue EcmaInterpreter::Execute(EcmaRuntimeCallInfo *info)
state->constpool = method->GetConstantPool();
JSHandle<JSFunction> thisFunc = JSHandle<JSFunction>::Cast(func);
state->profileTypeInfo = thisFunc->GetProfileTypeInfo();
state->profileTypeInfo = method->GetProfileTypeInfo();
state->base.prev = sp;
state->base.type = FrameType::INTERPRETER_FRAME;
state->env = thisFunc->GetLexicalEnv();
@ -783,7 +783,7 @@ JSTaggedValue EcmaInterpreter::GeneratorReEnterInterpreter(JSThread *thread, JSH
state->function = func.GetTaggedValue();
state->thisObj = context->GetThis();
state->constpool = method->GetConstantPool();
state->profileTypeInfo = func->GetProfileTypeInfo();
state->profileTypeInfo = method->GetProfileTypeInfo();
state->acc = context->GetAcc();
state->base.prev = breakSp;
state->base.type = FrameType::INTERPRETER_FRAME;
@ -1299,7 +1299,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
state->thisObj = JSTaggedValue(thisObj);
state->acc = JSTaggedValue::Hole();
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = JSFunction::Cast(funcObject)->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
JSTaggedValue env = JSFunction::Cast(funcObject)->GetLexicalEnv();
state->env = env;
thread->SetCurrentSPFrame(newSp);
@ -3075,7 +3075,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
state->function = superCtor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = superCtorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = superCtorFunc->GetLexicalEnv();
}
@ -3212,7 +3212,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
state->function = superCtor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = superCtorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = superCtorFunc->GetLexicalEnv();
}
@ -3349,7 +3349,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
state->function = superCtor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = superCtorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = superCtorFunc->GetLexicalEnv();
}
@ -3486,7 +3486,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
state->function = superCtor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = superCtorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = superCtorFunc->GetLexicalEnv();
}
@ -3834,7 +3834,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
state->function = ctor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = ctorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = ctorFunc->GetLexicalEnv();
}
@ -3972,7 +3972,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
state->function = ctor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = ctorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = ctorFunc->GetLexicalEnv();
}
@ -4109,7 +4109,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
state->function = ctor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = ctorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = ctorFunc->GetLexicalEnv();
}
@ -7152,7 +7152,7 @@ bool EcmaInterpreter::UpdateHotnessCounter(JSThread* thread, JSTaggedType *sp, J
auto thisFunc = JSFunction::Cast(state->function.GetTaggedObject());
method = thisFunc->GetCallTarget(); // for CheckSafepoint, method need retrieve.
method->SetHotnessCounter(EcmaInterpreter::METHOD_HOTNESS_THRESHOLD);
auto res = SlowRuntimeStub::NotifyInlineCache(thread, thisFunc, method);
auto res = SlowRuntimeStub::NotifyInlineCache(thread, method);
state->profileTypeInfo = res;
return true;
} else {

View File

@ -3369,7 +3369,7 @@ void InterpreterAssembly::HandleWideSupercallarrowrangePrefImm16V8(
state->function = superCtor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = superCtorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = superCtorFunc->GetLexicalEnv();
}
@ -3512,7 +3512,7 @@ void InterpreterAssembly::HandleWideSupercallthisrangePrefImm16V8(
state->function = superCtor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = superCtorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = superCtorFunc->GetLexicalEnv();
}
@ -3700,7 +3700,7 @@ void InterpreterAssembly::HandleWideNewobjrangePrefImm16V8(
state->function = ctor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = ctorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = ctorFunc->GetLexicalEnv();
}
@ -6594,7 +6594,7 @@ void InterpreterAssembly::HandleSupercallarrowrangeImm8Imm8V8(
state->function = superCtor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = superCtorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = superCtorFunc->GetLexicalEnv();
}
@ -6737,7 +6737,7 @@ void InterpreterAssembly::HandleSupercallthisrangeImm8Imm8V8(
state->function = superCtor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = superCtorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = superCtorFunc->GetLexicalEnv();
}
@ -6913,7 +6913,7 @@ void InterpreterAssembly::HandleNewobjrangeImm16Imm8V8(
state->function = ctor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = ctorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = ctorFunc->GetLexicalEnv();
}
@ -7055,7 +7055,7 @@ void InterpreterAssembly::HandleNewobjrangeImm8Imm8V8(
state->function = ctor;
state->constpool = methodHandle->GetConstantPool();
state->profileTypeInfo = ctorFunc->GetProfileTypeInfo();
state->profileTypeInfo = methodHandle->GetProfileTypeInfo();
state->env = ctorFunc->GetLexicalEnv();
}
@ -7373,8 +7373,8 @@ JSTaggedValue InterpreterAssembly::GetProfileTypeInfo(JSTaggedType *sp)
{
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
AsmInterpretedFrame *state = reinterpret_cast<AsmInterpretedFrame *>(sp) - 1;
JSFunction* function = JSFunction::Cast(state->function.GetTaggedObject());
return function->GetProfileTypeInfo();
Method *method = JSFunction::Cast(state->function.GetTaggedObject())->GetCallTarget();
return method->GetProfileTypeInfo();
}
JSTaggedType *InterpreterAssembly::GetAsmInterpreterFramePointer(AsmInterpretedFrame *state)
@ -7419,11 +7419,10 @@ inline JSTaggedValue InterpreterAssembly::UpdateHotnessCounter(JSThread* thread,
AsmInterpretedFrame *state = GET_ASM_FRAME(sp);
thread->CheckSafepoint();
JSFunction* function = JSFunction::Cast(state->function.GetTaggedObject());
JSTaggedValue profileTypeInfo = function->GetProfileTypeInfo();
Method *method = function->GetCallTarget();
JSTaggedValue profileTypeInfo = method->GetProfileTypeInfo();
if (profileTypeInfo == JSTaggedValue::Undefined()) {
auto method = function->GetCallTarget();
auto res = SlowRuntimeStub::NotifyInlineCache(thread, function, method);
return res;
return SlowRuntimeStub::NotifyInlineCache(thread, method);
}
return profileTypeInfo;
}

View File

@ -1031,14 +1031,14 @@ void SlowRuntimeStub::ThrowDeleteSuperProperty(JSThread *thread)
return RuntimeStubs::RuntimeThrowDeleteSuperProperty(thread);
}
JSTaggedValue SlowRuntimeStub::NotifyInlineCache(JSThread *thread, JSFunction *func, Method *method)
JSTaggedValue SlowRuntimeStub::NotifyInlineCache(JSThread *thread, Method *method)
{
INTERPRETER_TRACE(thread, NotifyInlineCache);
[[maybe_unused]] EcmaHandleScope handleScope(thread);
JSHandle<JSFunction> funcHandle(thread, func);
uint32_t slotSize = method->GetSlotSize();
return RuntimeStubs::RuntimeNotifyInlineCache(thread, funcHandle, slotSize);
JSHandle<Method> methodHandle(thread, method);
uint32_t slotSize = methodHandle->GetSlotSize();
return RuntimeStubs::RuntimeNotifyInlineCache(thread, methodHandle, slotSize);
}
JSTaggedValue SlowRuntimeStub::ResolveClass(JSThread *thread, JSTaggedValue ctor, TaggedArray *literal,

View File

@ -150,7 +150,7 @@ public:
static JSTaggedValue LdSuperByValue(JSThread *thread, JSTaggedValue obj, JSTaggedValue key, JSTaggedValue thisFunc);
static JSTaggedValue StSuperByValue(JSThread *thread, JSTaggedValue obj, JSTaggedValue key, JSTaggedValue value,
JSTaggedValue thisFunc);
static JSTaggedValue NotifyInlineCache(JSThread *thread, JSFunction *func, Method *method);
static JSTaggedValue NotifyInlineCache(JSThread *thread, Method *method);
static JSTaggedValue ThrowReferenceError(JSThread *thread, JSTaggedValue prop, const char *desc);
static JSTaggedValue ResolveClass(JSThread *thread, JSTaggedValue ctor, TaggedArray *literal, JSTaggedValue base,

View File

@ -37,7 +37,6 @@ void JSFunction::InitializeJSFunction(JSThread *thread, const JSHandle<JSFunctio
func->SetHomeObject(thread, JSTaggedValue::Undefined(), SKIP_BARRIER);
func->SetLexicalEnv(thread, JSTaggedValue::Undefined(), SKIP_BARRIER);
func->SetModule(thread, JSTaggedValue::Undefined(), SKIP_BARRIER);
func->SetProfileTypeInfo(thread, JSTaggedValue::Undefined(), SKIP_BARRIER);
func->SetMethod(thread, JSTaggedValue::Undefined(), SKIP_BARRIER);
auto globalConst = thread->GlobalConstants();

View File

@ -221,8 +221,7 @@ public:
static constexpr size_t PROTO_OR_DYNCLASS_OFFSET = JSFunctionBase::SIZE;
ACCESSORS(ProtoOrHClass, PROTO_OR_DYNCLASS_OFFSET, LEXICAL_ENV_OFFSET)
ACCESSORS(LexicalEnv, LEXICAL_ENV_OFFSET, HOME_OBJECT_OFFSET)
ACCESSORS(HomeObject, HOME_OBJECT_OFFSET, PROFILE_TYPE_INFO_OFFSET)
ACCESSORS(ProfileTypeInfo, PROFILE_TYPE_INFO_OFFSET, ECMA_MODULE_OFFSET)
ACCESSORS(HomeObject, HOME_OBJECT_OFFSET, ECMA_MODULE_OFFSET)
ACCESSORS(Module, ECMA_MODULE_OFFSET, LAST_OFFSET)
DEFINE_ALIGN_SIZE(LAST_OFFSET);

View File

@ -506,6 +506,7 @@ void QuickFixLoader::ReplaceMethodInner(JSThread *thread,
destMethod->SetExtraLiteralInfo(srcMethodLiteral->GetExtraLiteralInfo());
destMethod->SetNativePointerOrBytecodeArray(const_cast<void *>(srcMethodLiteral->GetNativePointer()));
destMethod->SetConstantPool(thread, srcConstpool);
destMethod->SetProfileTypeInfo(thread, JSTaggedValue::Undefined());
destMethod->SetAotCodeBit(false);
}

View File

@ -238,7 +238,8 @@ public:
std::string PUBLIC_API ParseFunctionName() const;
static constexpr size_t CONSTANT_POOL_OFFSET = TaggedObjectSize();
ACCESSORS(ConstantPool, CONSTANT_POOL_OFFSET, CALL_FIELD_OFFSET)
ACCESSORS(ConstantPool, CONSTANT_POOL_OFFSET, PROFILE_TYPE_INFO_OFFSET)
ACCESSORS(ProfileTypeInfo, PROFILE_TYPE_INFO_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(

View File

@ -1513,6 +1513,7 @@ JSHandle<Method> ObjectFactory::NewMethod(const MethodLiteral *methodLiteral)
}
method->SetCodeEntryOrLiteral(reinterpret_cast<uintptr_t>(methodLiteral));
method->SetConstantPool(thread_, JSTaggedValue::Undefined());
method->SetProfileTypeInfo(thread_, JSTaggedValue::Undefined());
return method;
}

View File

@ -853,7 +853,7 @@ JSTaggedValue RuntimeStubs::RuntimeSetClassConstructorLength(JSThread *thread, J
return JSTaggedValue::Undefined();
}
JSTaggedValue RuntimeStubs::RuntimeNotifyInlineCache(JSThread *thread, const JSHandle<JSFunction> &func,
JSTaggedValue RuntimeStubs::RuntimeNotifyInlineCache(JSThread *thread, const JSHandle<Method> &method,
uint32_t icSlotSize)
{
if (icSlotSize == 0) {
@ -867,7 +867,7 @@ JSTaggedValue RuntimeStubs::RuntimeNotifyInlineCache(JSThread *thread, const JSH
profileTypeInfo->Set(thread, ProfileTypeInfo::INVALID_SLOT_INDEX, JSTaggedValue::Hole());
ASSERT(icSlotSize <= ProfileTypeInfo::MAX_SLOT_INDEX + 1);
}
func->SetProfileTypeInfo(thread, profileTypeInfo.GetTaggedValue());
method->SetProfileTypeInfo(thread, profileTypeInfo.GetTaggedValue());
return profileTypeInfo.GetTaggedValue();
}

View File

@ -917,10 +917,11 @@ DEF_RUNTIME_STUBS(UpdateHotnessCounter)
RUNTIME_STUBS_HEADER(UpdateHotnessCounter);
JSHandle<JSFunction> thisFunc = GetHArg<JSFunction>(argv, argc, 0); // 0: means the zeroth parameter
thread->CheckSafepoint();
auto profileTypeInfo = thisFunc->GetProfileTypeInfo();
JSHandle<Method> method(thread, thisFunc->GetMethod());
auto profileTypeInfo = method->GetProfileTypeInfo();
if (profileTypeInfo == JSTaggedValue::Undefined()) {
uint32_t slotSize = thisFunc->GetCallTarget()->GetSlotSize();
auto res = RuntimeNotifyInlineCache(thread, thisFunc, slotSize);
uint32_t slotSize = method->GetSlotSize();
auto res = RuntimeNotifyInlineCache(thread, method, slotSize);
return res.GetRawData();
}
return profileTypeInfo.GetRawData();

View File

@ -439,7 +439,7 @@ private:
const JSHandle<JSTaggedValue> &base);
static inline JSTaggedValue RuntimeSetClassConstructorLength(JSThread *thread, JSTaggedValue ctor,
JSTaggedValue length);
static inline JSTaggedValue RuntimeNotifyInlineCache(JSThread *thread, const JSHandle<JSFunction> &func,
static inline JSTaggedValue RuntimeNotifyInlineCache(JSThread *thread, const JSHandle<Method> &method,
uint32_t icSlotSize);
static inline JSTaggedValue RuntimeStOwnByValueWithNameSet(JSThread *thread, const JSHandle<JSTaggedValue> &obj,
const JSHandle<JSTaggedValue> &key,

View File

@ -432,9 +432,9 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump)
}
case JSType::METHOD: {
#ifdef PANDA_TARGET_64
CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 6U);
CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 7U);
#else
CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 5U);
CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 6U);
#endif
break;
}
@ -443,7 +443,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump)
break;
}
case JSType::JS_FUNCTION: {
CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSFunction::SIZE, 5U);
CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSFunction::SIZE, 4U);
JSHandle<JSTaggedValue> jsFunc = globalEnv->GetFunctionFunction();
DUMP_FOR_HANDLE(jsFunc)
break;