mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
!4186 Move module from Function to Method
Merge pull request !4186 from lijiamin/hotreload
This commit is contained in:
commit
cea62dfb64
@ -1645,8 +1645,9 @@ GateRef CircuitBuilder::GetMethodFromFunction(GateRef function)
|
||||
|
||||
GateRef CircuitBuilder::GetModuleFromFunction(GateRef function)
|
||||
{
|
||||
GateRef offset = IntPtr(JSFunction::ECMA_MODULE_OFFSET);
|
||||
return Load(VariableType::JS_POINTER(), function, offset);
|
||||
GateRef method = GetMethodFromFunction(function);
|
||||
GateRef offset = IntPtr(Method::ECMA_MODULE_OFFSET);
|
||||
return Load(VariableType::JS_POINTER(), method, offset);
|
||||
}
|
||||
|
||||
GateRef CircuitBuilder::GetHomeObjectFromFunction(GateRef function)
|
||||
@ -1700,7 +1701,7 @@ GateRef CircuitBuilder::GetObjectFromConstPool(GateRef glue, GateRef hirGate, Ga
|
||||
{ constPool, Int32ToTaggedInt(index), module }, hirGate);
|
||||
} else {
|
||||
result = CallRuntime(glue, RTSTUB_ID(GetMethodFromCache), Gate::InvalidGateRef,
|
||||
{ constPool, Int32ToTaggedInt(index) }, hirGate);
|
||||
{ constPool, Int32ToTaggedInt(index), module }, hirGate);
|
||||
}
|
||||
Jump(&exit);
|
||||
}
|
||||
@ -1712,7 +1713,7 @@ GateRef CircuitBuilder::GetObjectFromConstPool(GateRef glue, GateRef hirGate, Ga
|
||||
Bind(&isInt);
|
||||
{
|
||||
result = CallRuntime(glue, RTSTUB_ID(GetMethodFromCache), Gate::InvalidGateRef,
|
||||
{ constPool, Int32ToTaggedInt(index) }, hirGate);
|
||||
{ constPool, Int32ToTaggedInt(index), module }, hirGate);
|
||||
Jump(&exit);
|
||||
}
|
||||
} else if (type == ConstPoolType::ARRAY_LITERAL) {
|
||||
@ -1891,12 +1892,6 @@ GateRef CircuitBuilder::GetFunctionLexicalEnv(GateRef function)
|
||||
return Load(VariableType::JS_POINTER(), function, IntPtr(JSFunction::LEXICAL_ENV_OFFSET));
|
||||
}
|
||||
|
||||
void CircuitBuilder::SetModuleToFunction(GateRef glue, GateRef function, GateRef value)
|
||||
{
|
||||
GateRef offset = IntPtr(JSFunction::ECMA_MODULE_OFFSET);
|
||||
Store(VariableType::JS_POINTER(), glue, function, offset, value);
|
||||
}
|
||||
|
||||
void CircuitBuilder::SetPropertyInlinedProps(GateRef glue, GateRef obj, GateRef hClass,
|
||||
GateRef value, GateRef attrOffset, VariableType type)
|
||||
{
|
||||
|
@ -641,7 +641,6 @@ public:
|
||||
GateRef TaggedIsBigInt(GateRef obj);
|
||||
void SetLexicalEnvToFunction(GateRef glue, GateRef function, GateRef value);
|
||||
GateRef GetFunctionLexicalEnv(GateRef function);
|
||||
void SetModuleToFunction(GateRef glue, GateRef function, GateRef value);
|
||||
void SetPropertyInlinedProps(GateRef glue, GateRef obj, GateRef hClass,
|
||||
GateRef value, GateRef attrOffset, VariableType type);
|
||||
void SetHomeObjectToFunction(GateRef glue, GateRef function, GateRef value);
|
||||
|
@ -247,7 +247,8 @@ GateRef InterpreterStubBuilder::GetProfileTypeInfoFromMethod(GateRef method)
|
||||
|
||||
GateRef InterpreterStubBuilder::GetModuleFromFunction(GateRef function)
|
||||
{
|
||||
return Load(VariableType::JS_POINTER(), function, IntPtr(JSFunction::ECMA_MODULE_OFFSET));
|
||||
GateRef method = GetMethodFromFunction(function);
|
||||
return Load(VariableType::JS_POINTER(), method, IntPtr(Method::ECMA_MODULE_OFFSET));
|
||||
}
|
||||
|
||||
GateRef InterpreterStubBuilder::GetHomeObjectFromFunction(GateRef function)
|
||||
@ -260,6 +261,12 @@ GateRef InterpreterStubBuilder::GetConstpoolFromMethod(GateRef method)
|
||||
return Load(VariableType::JS_POINTER(), method, IntPtr(Method::CONSTANT_POOL_OFFSET));
|
||||
}
|
||||
|
||||
GateRef InterpreterStubBuilder::GetModule(GateRef sp)
|
||||
{
|
||||
GateRef currentFunc = GetFunctionFromFrame(GetFrame(sp));
|
||||
return GetModuleFromFunction(currentFunc);
|
||||
}
|
||||
|
||||
GateRef InterpreterStubBuilder::GetResumeModeFromGeneratorObject(GateRef obj)
|
||||
{
|
||||
GateRef bitfieldOffset = IntPtr(JSGeneratorObject::BIT_FIELD_OFFSET);
|
||||
@ -314,12 +321,6 @@ void InterpreterStubBuilder::SetHomeObjectToFunction(GateRef glue, GateRef funct
|
||||
Store(VariableType::JS_ANY(), glue, function, offset, value);
|
||||
}
|
||||
|
||||
void InterpreterStubBuilder::SetModuleToFunction(GateRef glue, GateRef function, GateRef value)
|
||||
{
|
||||
GateRef offset = IntPtr(JSFunction::ECMA_MODULE_OFFSET);
|
||||
Store(VariableType::JS_POINTER(), glue, function, offset, value);
|
||||
}
|
||||
|
||||
void InterpreterStubBuilder::SetFrameState(GateRef glue, GateRef sp, GateRef function, GateRef acc,
|
||||
GateRef env, GateRef pc, GateRef prev, GateRef type)
|
||||
{
|
||||
|
@ -3531,7 +3531,6 @@ DECLARE_ASM_HANDLER(HandleDefineclasswithbufferImm8Id16Id16Imm16V8)
|
||||
}
|
||||
Bind(&isNotException);
|
||||
SetLexicalEnvToFunction(glue, res, lexicalEnv);
|
||||
SetModuleToFunction(glue, res, module);
|
||||
CallRuntime(glue, RTSTUB_ID(SetClassConstructorLength), { res, Int16ToTaggedInt(length) });
|
||||
callback.ProfileDefineClass(res);
|
||||
varAcc = res;
|
||||
@ -3566,7 +3565,6 @@ DECLARE_ASM_HANDLER(HandleDefineclasswithbufferImm16Id16Id16Imm16V8)
|
||||
}
|
||||
Bind(&isNotException);
|
||||
SetLexicalEnvToFunction(glue, res, lexicalEnv);
|
||||
SetModuleToFunction(glue, res, module);
|
||||
CallRuntime(glue, RTSTUB_ID(SetClassConstructorLength), { res, Int16ToTaggedInt(length) });
|
||||
callback.ProfileDefineClass(res);
|
||||
varAcc = res;
|
||||
@ -3603,7 +3601,6 @@ DECLARE_ASM_HANDLER(HandleDeprecatedDefineclasswithbufferPrefId16Imm16Imm16V8V8)
|
||||
}
|
||||
Bind(&isNotException);
|
||||
SetLexicalEnvToFunction(glue, res, lexicalEnv);
|
||||
SetModuleToFunction(glue, res, module);
|
||||
CallRuntime(glue, RTSTUB_ID(SetClassConstructorLength), { res, Int16ToTaggedInt(length) });
|
||||
varAcc = res;
|
||||
DISPATCH_WITH_ACC(DEPRECATED_DEFINECLASSWITHBUFFER_PREF_ID16_IMM16_IMM16_V8_V8);
|
||||
@ -4192,7 +4189,7 @@ DECLARE_ASM_HANDLER(HandleDefinefuncImm8Id16Imm8)
|
||||
GateRef methodId = ReadInst16_1(pc);
|
||||
GateRef length = ReadInst8_3(pc);
|
||||
DEFVARIABLE(result, VariableType::JS_POINTER(),
|
||||
GetMethodFromConstPool(glue, constpool, ZExtInt16ToInt32(methodId)));
|
||||
GetMethodFromConstPool(glue, constpool, GetModule(sp), ZExtInt16ToInt32(methodId)));
|
||||
result = CallRuntime(glue, RTSTUB_ID(DefineFunc), { *result });
|
||||
Label notException(env);
|
||||
CHECK_EXCEPTION_WITH_JUMP(*result, ¬Exception);
|
||||
@ -4205,7 +4202,6 @@ DECLARE_ASM_HANDLER(HandleDefinefuncImm8Id16Imm8)
|
||||
GateRef envHandle = GetEnvFromFrame(frame);
|
||||
SetLexicalEnvToFunction(glue, *result, envHandle);
|
||||
GateRef currentFunc = GetFunctionFromFrame(frame);
|
||||
SetModuleToFunction(glue, *result, GetModuleFromFunction(currentFunc));
|
||||
SetHomeObjectToFunction(glue, *result, GetHomeObjectFromFunction(currentFunc));
|
||||
varAcc = *result;
|
||||
DISPATCH_WITH_ACC(DEFINEFUNC_IMM8_ID16_IMM8);
|
||||
@ -4219,7 +4215,7 @@ DECLARE_ASM_HANDLER(HandleDefinefuncImm16Id16Imm8)
|
||||
GateRef methodId = ReadInst16_2(pc);
|
||||
GateRef length = ReadInst8_4(pc);
|
||||
DEFVARIABLE(result, VariableType::JS_POINTER(),
|
||||
GetMethodFromConstPool(glue, constpool, ZExtInt16ToInt32(methodId)));
|
||||
GetMethodFromConstPool(glue, constpool, GetModule(sp), ZExtInt16ToInt32(methodId)));
|
||||
result = CallRuntime(glue, RTSTUB_ID(DefineFunc), { *result });
|
||||
Label notException(env);
|
||||
CHECK_EXCEPTION_WITH_JUMP(*result, ¬Exception);
|
||||
@ -4232,7 +4228,6 @@ DECLARE_ASM_HANDLER(HandleDefinefuncImm16Id16Imm8)
|
||||
GateRef envHandle = GetEnvFromFrame(frame);
|
||||
SetLexicalEnvToFunction(glue, *result, envHandle);
|
||||
GateRef currentFunc = GetFunctionFromFrame(frame);
|
||||
SetModuleToFunction(glue, *result, GetModuleFromFunction(currentFunc));
|
||||
SetHomeObjectToFunction(glue, *result, GetHomeObjectFromFunction(currentFunc));
|
||||
varAcc = *result;
|
||||
DISPATCH_WITH_ACC(DEFINEFUNC_IMM16_ID16_IMM8);
|
||||
@ -4246,7 +4241,7 @@ DECLARE_ASM_HANDLER(HandleDefinemethodImm8Id16Imm8)
|
||||
GateRef methodId = ReadInst16_1(pc);
|
||||
GateRef length = ReadInst8_3(pc);
|
||||
DEFVARIABLE(result, VariableType::JS_POINTER(),
|
||||
GetMethodFromConstPool(glue, constpool, ZExtInt16ToInt32(methodId)));
|
||||
GetMethodFromConstPool(glue, constpool, GetModule(sp), ZExtInt16ToInt32(methodId)));
|
||||
result = CallRuntime(glue, RTSTUB_ID(DefineMethod), { *result, acc });
|
||||
Label notException(env);
|
||||
CHECK_EXCEPTION_WITH_JUMP(*result, ¬Exception);
|
||||
@ -4257,8 +4252,6 @@ DECLARE_ASM_HANDLER(HandleDefinemethodImm8Id16Imm8)
|
||||
Int32(JSFunction::LENGTH_INLINE_PROPERTY_INDEX), VariableType::INT64());
|
||||
GateRef lexEnv = GetEnvFromFrame(GetFrame(sp));
|
||||
SetLexicalEnvToFunction(glue, *result, lexEnv);
|
||||
GateRef currentFunc = GetFunctionFromFrame(GetFrame(sp));
|
||||
SetModuleToFunction(glue, *result, GetModuleFromFunction(currentFunc));
|
||||
varAcc = *result;
|
||||
DISPATCH_WITH_ACC(DEFINEMETHOD_IMM8_ID16_IMM8);
|
||||
}
|
||||
@ -4271,7 +4264,7 @@ DECLARE_ASM_HANDLER(HandleDefinemethodImm16Id16Imm8)
|
||||
GateRef methodId = ReadInst16_2(pc);
|
||||
GateRef length = ReadInst8_4(pc);
|
||||
DEFVARIABLE(result, VariableType::JS_POINTER(),
|
||||
GetMethodFromConstPool(glue, constpool, ZExtInt16ToInt32(methodId)));
|
||||
GetMethodFromConstPool(glue, constpool, GetModule(sp), ZExtInt16ToInt32(methodId)));
|
||||
result = CallRuntime(glue, RTSTUB_ID(DefineMethod), { *result, acc });
|
||||
Label notException(env);
|
||||
CHECK_EXCEPTION_WITH_JUMP(*result, ¬Exception);
|
||||
@ -4282,8 +4275,6 @@ DECLARE_ASM_HANDLER(HandleDefinemethodImm16Id16Imm8)
|
||||
Int32(JSFunction::LENGTH_INLINE_PROPERTY_INDEX), VariableType::INT64());
|
||||
GateRef lexEnv = GetEnvFromFrame(GetFrame(sp));
|
||||
SetLexicalEnvToFunction(glue, *result, lexEnv);
|
||||
GateRef currentFunc = GetFunctionFromFrame(GetFrame(sp));
|
||||
SetModuleToFunction(glue, *result, GetModuleFromFunction(currentFunc));
|
||||
varAcc = *result;
|
||||
DISPATCH_WITH_ACC(DEFINEMETHOD_IMM16_ID16_IMM8);
|
||||
}
|
||||
|
@ -98,6 +98,7 @@ public:
|
||||
inline GateRef GetEnvFromFrame(GateRef frame);
|
||||
inline GateRef GetEnvFromFunction(GateRef frame);
|
||||
inline GateRef GetConstpoolFromMethod(GateRef function);
|
||||
inline GateRef GetModule(GateRef sp);
|
||||
inline GateRef GetProfileTypeInfoFromMethod(GateRef function);
|
||||
inline GateRef GetModuleFromFunction(GateRef function);
|
||||
inline GateRef GetHomeObjectFromFunction(GateRef function);
|
||||
@ -113,7 +114,6 @@ public:
|
||||
inline void SetAccToFrame(GateRef glue, GateRef frame, GateRef value);
|
||||
inline void SetEnvToFrame(GateRef glue, GateRef frame, GateRef value);
|
||||
inline void SetHomeObjectToFunction(GateRef glue, GateRef function, GateRef value);
|
||||
inline void SetModuleToFunction(GateRef glue, GateRef function, GateRef value);
|
||||
inline void SetFrameState(GateRef glue, GateRef sp, GateRef function, GateRef acc,
|
||||
GateRef env, GateRef pc, GateRef prev, GateRef type);
|
||||
|
||||
|
@ -2454,7 +2454,6 @@ void SlowPathLowering::LowerDefineClassWithBuffer(GateRef gate)
|
||||
builder_.Bind(&isNotException);
|
||||
{
|
||||
builder_.SetLexicalEnvToFunction(glue_, result, lexicalEnv);
|
||||
builder_.SetModuleToFunction(glue_, result, module);
|
||||
LowerCallRuntime(gate, RTSTUB_ID(SetClassConstructorLength),
|
||||
{ result, builder_.ToTaggedInt(length) }, true);
|
||||
successControl.SetState(builder_.GetState());
|
||||
@ -2487,7 +2486,6 @@ void SlowPathLowering::LowerDefineFunc(GateRef gate)
|
||||
builder_.Int32(JSFunction::LENGTH_INLINE_PROPERTY_INDEX), VariableType::INT64());
|
||||
GateRef env = acc_.GetValueIn(gate, 2); // 2: Get current env
|
||||
builder_.SetLexicalEnvToFunction(glue_, result, env);
|
||||
builder_.SetModuleToFunction(glue_, result, builder_.GetModuleFromFunction(jsFunc));
|
||||
builder_.SetHomeObjectToFunction(glue_, result, builder_.GetHomeObjectFromFunction(jsFunc));
|
||||
builder_.Jump(&successExit);
|
||||
}
|
||||
@ -2765,7 +2763,6 @@ void SlowPathLowering::LowerDefineMethod(GateRef gate)
|
||||
builder_.Int32(JSFunction::LENGTH_INLINE_PROPERTY_INDEX), VariableType::INT64());
|
||||
GateRef env = acc_.GetValueIn(gate, 2); // 2: Get current env
|
||||
builder_.SetLexicalEnvToFunction(glue_, result, env);
|
||||
builder_.SetModuleToFunction(glue_, result, builder_.GetModuleFromFunction(jsFunc));
|
||||
builder_.Jump(&successExit);
|
||||
}
|
||||
CREATE_DOUBLE_EXIT(successExit, exceptionExit)
|
||||
|
@ -5085,9 +5085,8 @@ GateRef StubBuilder::GetStringFromConstPool(GateRef glue, GateRef constpool, Gat
|
||||
return env_->GetBuilder()->GetObjectFromConstPool(glue, hirGate, constpool, module, index, ConstPoolType::STRING);
|
||||
}
|
||||
|
||||
GateRef StubBuilder::GetMethodFromConstPool(GateRef glue, GateRef constpool, GateRef index)
|
||||
GateRef StubBuilder::GetMethodFromConstPool(GateRef glue, GateRef constpool, GateRef module, GateRef index)
|
||||
{
|
||||
GateRef module = Circuit::NullGate();
|
||||
GateRef hirGate = Circuit::NullGate();
|
||||
return env_->GetBuilder()->GetObjectFromConstPool(glue, hirGate, constpool, module, index, ConstPoolType::METHOD);
|
||||
}
|
||||
|
@ -583,7 +583,7 @@ public:
|
||||
inline GateRef GetObjectFromConstPool(GateRef constpool, GateRef index);
|
||||
GateRef GetConstPoolFromFunction(GateRef jsFunc);
|
||||
GateRef GetStringFromConstPool(GateRef glue, GateRef constpool, GateRef index);
|
||||
GateRef GetMethodFromConstPool(GateRef glue, GateRef constpool, GateRef index);
|
||||
GateRef GetMethodFromConstPool(GateRef glue, GateRef constpool, GateRef index, GateRef module);
|
||||
GateRef GetArrayLiteralFromConstPool(GateRef glue, GateRef constpool, GateRef index, GateRef module);
|
||||
GateRef GetObjectLiteralFromConstPool(GateRef glue, GateRef constpool, GateRef index, GateRef module);
|
||||
void SetExtensibleToBitfield(GateRef glue, GateRef obj, bool isExtensible);
|
||||
|
@ -381,8 +381,7 @@ JSTaggedValue DebuggerApi::GetCurrentModule(const EcmaVM *ecmaVm)
|
||||
if (method->IsNativeWithCallField()) {
|
||||
continue;
|
||||
}
|
||||
JSTaggedValue func = frameHandler.GetFunction();
|
||||
JSTaggedValue module = JSFunction::Cast(func.GetTaggedObject())->GetModule();
|
||||
JSTaggedValue module = method->GetModule();
|
||||
if (module.IsUndefined()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ void CrashCallback(char *buf __attribute__((unused)), size_t len __attribute__((
|
||||
std::string faultInfo;
|
||||
if (method != nullptr) {
|
||||
std::string methodName = method->GetMethodName();
|
||||
std::string recordName = method->GetRecordName().c_str();
|
||||
std::string recordName = method->GetRecordNameStr().c_str();
|
||||
faultInfo = "Method Name:" + methodName + " Record Name:" + recordName;
|
||||
} else {
|
||||
faultInfo = "method is nullptr!";
|
||||
|
@ -52,7 +52,7 @@ void FunctionCallTimer::StopCount(Method *method)
|
||||
CString FunctionCallTimer::GetFullName(Method *method)
|
||||
{
|
||||
CString funcName(method->GetMethodName());
|
||||
CString recordName = method->GetRecordName();
|
||||
CString recordName = method->GetRecordNameStr();
|
||||
CString fullName = funcName + "@" + recordName;
|
||||
return fullName;
|
||||
}
|
||||
|
@ -1569,9 +1569,6 @@ void JSFunction::Dump(std::ostream &os) const
|
||||
os << " - FunctionExtraInfo: ";
|
||||
GetFunctionExtraInfo().Dump(os);
|
||||
os << "\n";
|
||||
os << " - Module: ";
|
||||
GetModule().Dump(os);
|
||||
os << "\n";
|
||||
os << " - Method: ";
|
||||
GetMethod().Dump(os);
|
||||
os << "\n";
|
||||
@ -3676,6 +3673,9 @@ void Method::Dump(std::ostream &os) const
|
||||
os << " - ProfileTypeInfo: ";
|
||||
GetProfileTypeInfo().Dump(os);
|
||||
os << "\n";
|
||||
os << " - Module: ";
|
||||
GetModule().Dump(os);
|
||||
os << "\n";
|
||||
os << " - FunctionKind: " << static_cast<int>(GetFunctionKind());
|
||||
os << "\n";
|
||||
os << " - CodeEntryOrLiteral: " << std::hex << GetCodeEntryOrLiteral() << "\n";
|
||||
@ -4467,6 +4467,7 @@ void Method::DumpForSnapshot(std::vector<Reference> &vec) const
|
||||
{
|
||||
vec.emplace_back(CString("ConstantPool"), GetConstantPool());
|
||||
vec.emplace_back(CString("ProfileTypeInfo"), GetProfileTypeInfo());
|
||||
vec.emplace_back(CString("Module"), GetModule());
|
||||
}
|
||||
|
||||
void Program::DumpForSnapshot(std::vector<Reference> &vec) const
|
||||
|
@ -256,6 +256,7 @@ Expected<JSTaggedValue, bool> EcmaContext::InvokeEcmaEntrypoint(const JSPandaFil
|
||||
jsPandaFile->GetJSPandaFileDesc(), entryPoint);
|
||||
|
||||
JSHandle<JSFunction> func(thread_, program->GetMainFunction());
|
||||
JSHandle<Method> method(thread_, func->GetMethod());
|
||||
JSHandle<JSTaggedValue> global = GlobalEnv::Cast(globalEnv_.GetTaggedObject())->GetJSGlobalObject();
|
||||
JSHandle<JSTaggedValue> undefined = thread_->GlobalConstants()->GetHandledUndefined();
|
||||
CString entry = entryPoint.data();
|
||||
@ -273,12 +274,12 @@ Expected<JSTaggedValue, bool> EcmaContext::InvokeEcmaEntrypoint(const JSPandaFil
|
||||
moduleName = entry;
|
||||
}
|
||||
JSHandle<SourceTextModule> module = moduleManager_->HostGetImportedModule(moduleName);
|
||||
func->SetModule(thread_, module);
|
||||
method->SetModule(thread_, module);
|
||||
} else {
|
||||
// if it is Cjs at present, the module slot of the function is not used. We borrow it to store the recordName,
|
||||
// which can avoid the problem of larger memory caused by the new slot
|
||||
JSHandle<EcmaString> recordName = factory_->NewFromUtf8(entry);
|
||||
func->SetModule(thread_, recordName);
|
||||
method->SetModule(thread_, recordName);
|
||||
}
|
||||
vm_->CheckStartCpuProfiler();
|
||||
|
||||
|
@ -140,7 +140,7 @@ using CommonStubCSigns = kungfu::CommonStubCSigns;
|
||||
#define SET_ACC(val) (acc = val) // NOLINT(cppcoreguidelines-macro-usage)
|
||||
|
||||
#define GET_METHOD_FROM_CACHE(index) \
|
||||
ConstantPool::GetMethodFromCache(thread, constpool, index)
|
||||
ConstantPool::GetMethodFromCache(thread, constpool, module, index)
|
||||
|
||||
#define GET_STR_FROM_CACHE(index) \
|
||||
ConstantPool::GetStringFromCache(thread, constpool, index)
|
||||
@ -972,8 +972,7 @@ JSTaggedValue EcmaInterpreter::GetCurrentEntryPoint(JSThread *thread)
|
||||
if (method->IsNativeWithCallField()) {
|
||||
continue;
|
||||
}
|
||||
JSTaggedValue func = frameHandler.GetFunction();
|
||||
JSHandle<JSTaggedValue> module(thread, JSFunction::Cast(func.GetTaggedObject())->GetModule());
|
||||
JSHandle<JSTaggedValue> module(thread, method->GetModule());
|
||||
|
||||
if (module->IsSourceTextModule()) {
|
||||
recordName.Update(SourceTextModule::Cast(module->GetTaggedObject())->GetEcmaModuleRecordName());
|
||||
@ -3753,6 +3752,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
<< " imm:" << imm;
|
||||
SAVE_ACC();
|
||||
auto constpool = GetConstantPool(sp);
|
||||
auto module = GetEcmaModule(sp);
|
||||
JSObject *result = JSObject::Cast(GET_METHOD_FROM_CACHE(imm).GetTaggedObject());
|
||||
RESTORE_ACC();
|
||||
JSTaggedValue env = GET_ACC();
|
||||
@ -4535,6 +4535,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
LOG_INST() << "intrinsics::createarraywithbuffer"
|
||||
<< " imm:" << imm;
|
||||
auto constpool = GetConstantPool(sp);
|
||||
auto module = GetEcmaModule(sp);
|
||||
JSArray *result = JSArray::Cast(GET_METHOD_FROM_CACHE(imm).GetTaggedObject());
|
||||
SAVE_PC();
|
||||
JSTaggedValue res = SlowRuntimeStub::CreateArrayWithBuffer(thread, factory, result);
|
||||
@ -4575,6 +4576,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
LOG_INST() << "intrinsics::createobjectwithbuffer"
|
||||
<< " imm:" << imm;
|
||||
auto constpool = GetConstantPool(sp);
|
||||
auto module = GetEcmaModule(sp);
|
||||
JSObject *result = JSObject::Cast(GET_METHOD_FROM_CACHE(imm).GetTaggedObject());
|
||||
|
||||
SAVE_PC();
|
||||
@ -4841,6 +4843,8 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
uint16_t length = READ_INST_8_3();
|
||||
LOG_INST() << "intrinsics::definefunc length: " << length;
|
||||
auto constpool = GetConstantPool(sp);
|
||||
|
||||
auto module = GetEcmaModule(sp);
|
||||
Method *method = Method::Cast(GET_METHOD_FROM_CACHE(methodId).GetTaggedObject());
|
||||
ASSERT(method != nullptr);
|
||||
|
||||
@ -4853,7 +4857,6 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
jsFunc->SetLexicalEnv(thread, envHandle);
|
||||
|
||||
JSFunction *currentFunc = JSFunction::Cast((GET_FRAME(sp)->function).GetTaggedObject());
|
||||
jsFunc->SetModule(thread, currentFunc->GetModule());
|
||||
jsFunc->SetHomeObject(thread, currentFunc->GetHomeObject());
|
||||
SET_ACC(JSTaggedValue(jsFunc));
|
||||
|
||||
@ -4865,6 +4868,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
LOG_INST() << "intrinsics::definefunc length: " << length;
|
||||
|
||||
auto constpool = GetConstantPool(sp);
|
||||
auto module = GetEcmaModule(sp);
|
||||
Method *method = Method::Cast(GET_METHOD_FROM_CACHE(methodId).GetTaggedObject());
|
||||
ASSERT(method != nullptr);
|
||||
|
||||
@ -4877,7 +4881,6 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
jsFunc->SetLexicalEnv(thread, envHandle);
|
||||
|
||||
JSFunction *currentFunc = JSFunction::Cast((GET_FRAME(sp)->function).GetTaggedObject());
|
||||
jsFunc->SetModule(thread, currentFunc->GetModule());
|
||||
jsFunc->SetHomeObject(thread, currentFunc->GetHomeObject());
|
||||
SET_ACC(JSTaggedValue(jsFunc));
|
||||
|
||||
@ -4889,6 +4892,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
LOG_INST() << "intrinsics::definemethod length: " << length;
|
||||
SAVE_ACC();
|
||||
auto constpool = GetConstantPool(sp);
|
||||
auto module = GetEcmaModule(sp);
|
||||
Method *method = Method::Cast(GET_METHOD_FROM_CACHE(methodId).GetTaggedObject());
|
||||
ASSERT(method != nullptr);
|
||||
RESTORE_ACC();
|
||||
@ -4904,8 +4908,6 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
JSTaggedValue taggedCurEnv = state->env;
|
||||
result->SetLexicalEnv(thread, taggedCurEnv);
|
||||
|
||||
JSFunction *currentFunc = JSFunction::Cast((GET_FRAME(sp)->function).GetTaggedObject());
|
||||
result->SetModule(thread, currentFunc->GetModule());
|
||||
SET_ACC(JSTaggedValue(result));
|
||||
|
||||
DISPATCH(DEFINEMETHOD_IMM8_ID16_IMM8);
|
||||
@ -4916,6 +4918,7 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
LOG_INST() << "intrinsics::definemethod length: " << length;
|
||||
SAVE_ACC();
|
||||
auto constpool = GetConstantPool(sp);
|
||||
auto module = GetEcmaModule(sp);
|
||||
Method *method = Method::Cast(GET_METHOD_FROM_CACHE(methodId).GetTaggedObject());
|
||||
ASSERT(method != nullptr);
|
||||
RESTORE_ACC();
|
||||
@ -4931,8 +4934,6 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
JSTaggedValue taggedCurEnv = state->env;
|
||||
result->SetLexicalEnv(thread, taggedCurEnv);
|
||||
|
||||
JSFunction *currentFunc = JSFunction::Cast((GET_FRAME(sp)->function).GetTaggedObject());
|
||||
result->SetModule(thread, currentFunc->GetModule());
|
||||
SET_ACC(JSTaggedValue(result));
|
||||
|
||||
DISPATCH(DEFINEMETHOD_IMM16_ID16_IMM8);
|
||||
@ -4958,7 +4959,6 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
JSFunction *cls = JSFunction::Cast(res.GetTaggedObject());
|
||||
|
||||
cls->SetLexicalEnv(thread, state->env);
|
||||
cls->SetModule(thread, GetEcmaModule(sp));
|
||||
|
||||
SlowRuntimeStub::SetClassConstructorLength(thread, res, JSTaggedValue(length));
|
||||
|
||||
@ -4987,8 +4987,6 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
|
||||
cls->SetLexicalEnv(thread, state->env);
|
||||
|
||||
cls->SetModule(thread, GetEcmaModule(sp));
|
||||
|
||||
SlowRuntimeStub::SetClassConstructorLength(thread, res, JSTaggedValue(length));
|
||||
|
||||
SET_ACC(res);
|
||||
@ -5016,7 +5014,6 @@ NO_UB_SANITIZE void EcmaInterpreter::RunInternal(JSThread *thread, const uint8_t
|
||||
|
||||
lexenv = GET_VREG_VALUE(v0); // slow runtime may gc
|
||||
cls->SetLexicalEnv(thread, lexenv);
|
||||
cls->SetModule(thread, GetEcmaModule(sp));
|
||||
|
||||
SlowRuntimeStub::SetClassConstructorLength(thread, res, JSTaggedValue(length));
|
||||
|
||||
@ -7382,7 +7379,7 @@ JSTaggedValue EcmaInterpreter::GetEcmaModule(JSTaggedType *sp)
|
||||
{
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
JSFunction *currentFunc = JSFunction::Cast((GET_FRAME(sp)->function).GetTaggedObject());
|
||||
return currentFunc->GetModule();
|
||||
return currentFunc->GetCallTarget()->GetModule();
|
||||
}
|
||||
|
||||
JSTaggedValue EcmaInterpreter::GetConstantPool(JSTaggedType *sp)
|
||||
|
@ -3971,7 +3971,8 @@ void InterpreterAssembly::HandleDeprecatedCreateobjecthavingmethodPrefImm16(
|
||||
<< " imm:" << imm;
|
||||
SAVE_ACC();
|
||||
constpool = GetConstantPool(sp);
|
||||
JSObject *result = JSObject::Cast(ConstantPool::GetMethodFromCache(thread, constpool, imm).GetTaggedObject());
|
||||
JSObject *result =
|
||||
JSObject::Cast(ConstantPool::GetMethodFromCache(thread, constpool, GetModule(sp), imm).GetTaggedObject());
|
||||
RESTORE_ACC();
|
||||
JSTaggedValue env = GET_ACC();
|
||||
|
||||
@ -4528,11 +4529,9 @@ void InterpreterAssembly::HandleDeprecatedDefineclasswithbufferPrefId16Imm16Imm1
|
||||
JSTaggedValue proto = GET_VREG_VALUE(v1);
|
||||
|
||||
SAVE_PC();
|
||||
JSFunction *currentFunc =
|
||||
JSFunction::Cast(((reinterpret_cast<InterpretedFrame *>(sp) - 1)->function).GetTaggedObject());
|
||||
JSTaggedValue res =
|
||||
SlowRuntimeStub::CreateClassWithBuffer(thread, proto, lexenv, GetConstantPool(sp),
|
||||
methodId, methodId + 1, currentFunc->GetModule());
|
||||
methodId, methodId + 1, GetModule(sp));
|
||||
|
||||
INTERPRETER_RETURN_IF_ABRUPT(res);
|
||||
ASSERT(res.IsClassConstructor());
|
||||
@ -4540,7 +4539,6 @@ void InterpreterAssembly::HandleDeprecatedDefineclasswithbufferPrefId16Imm16Imm1
|
||||
|
||||
lexenv = GET_VREG_VALUE(v0); // slow runtime may gc
|
||||
cls->SetLexicalEnv(thread, lexenv);
|
||||
cls->SetModule(thread, currentFunc->GetModule());
|
||||
|
||||
SlowRuntimeStub::SetClassConstructorLength(thread, res, JSTaggedValue(length));
|
||||
|
||||
@ -4769,7 +4767,8 @@ void InterpreterAssembly::HandleDeprecatedCreateobjectwithbufferPrefImm16(
|
||||
LOG_INST() << "intrinsics::createobjectwithbuffer"
|
||||
<< " imm:" << imm;
|
||||
constpool = GetConstantPool(sp);
|
||||
JSObject *result = JSObject::Cast(ConstantPool::GetMethodFromCache(thread, constpool, imm).GetTaggedObject());
|
||||
JSObject *result =
|
||||
JSObject::Cast(ConstantPool::GetMethodFromCache(thread, constpool, GetModule(sp), imm).GetTaggedObject());
|
||||
|
||||
SAVE_PC();
|
||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||
@ -4788,7 +4787,8 @@ void InterpreterAssembly::HandleDeprecatedCreatearraywithbufferPrefImm16(
|
||||
LOG_INST() << "intrinsics::createarraywithbuffer"
|
||||
<< " imm:" << imm;
|
||||
constpool = GetConstantPool(sp);
|
||||
JSArray *result = JSArray::Cast(ConstantPool::GetMethodFromCache(thread, constpool, imm).GetTaggedObject());
|
||||
JSArray *result =
|
||||
JSArray::Cast(ConstantPool::GetMethodFromCache(thread, constpool, GetModule(sp), imm).GetTaggedObject());
|
||||
SAVE_PC();
|
||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||
ObjectFactory *factory = ecmaVm->GetFactory();
|
||||
@ -5893,11 +5893,9 @@ void InterpreterAssembly::HandleDefineclasswithbufferImm16Id16Id16Imm16V8(
|
||||
JSTaggedValue proto = GET_VREG_VALUE(v0);
|
||||
|
||||
SAVE_PC();
|
||||
JSFunction *currentFunc =
|
||||
JSFunction::Cast(((reinterpret_cast<InterpretedFrame *>(sp) - 1)->function).GetTaggedObject());
|
||||
JSTaggedValue res =
|
||||
SlowRuntimeStub::CreateClassWithBuffer(thread, proto, state->env, GetConstantPool(sp),
|
||||
methodId, literaId, currentFunc->GetModule());
|
||||
methodId, literaId, GetModule(sp));
|
||||
|
||||
INTERPRETER_RETURN_IF_ABRUPT(res);
|
||||
ASSERT(res.IsClassConstructor());
|
||||
@ -5905,8 +5903,6 @@ void InterpreterAssembly::HandleDefineclasswithbufferImm16Id16Id16Imm16V8(
|
||||
|
||||
cls->SetLexicalEnv(thread, state->env);
|
||||
|
||||
cls->SetModule(thread, currentFunc->GetModule());
|
||||
|
||||
SlowRuntimeStub::SetClassConstructorLength(thread, res, JSTaggedValue(length));
|
||||
|
||||
SET_ACC(res);
|
||||
@ -5928,18 +5924,15 @@ void InterpreterAssembly::HandleDefineclasswithbufferImm8Id16Id16Imm16V8(
|
||||
|
||||
SAVE_PC();
|
||||
InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1);
|
||||
JSFunction *currentFunc =
|
||||
JSFunction::Cast(((reinterpret_cast<InterpretedFrame *>(sp) - 1)->function).GetTaggedObject());
|
||||
JSTaggedValue res =
|
||||
SlowRuntimeStub::CreateClassWithBuffer(thread, proto, state->env, GetConstantPool(sp),
|
||||
methodId, literaId, currentFunc->GetModule());
|
||||
methodId, literaId, GetModule(sp));
|
||||
|
||||
INTERPRETER_RETURN_IF_ABRUPT(res);
|
||||
ASSERT(res.IsClassConstructor());
|
||||
JSFunction *cls = JSFunction::Cast(res.GetTaggedObject());
|
||||
|
||||
cls->SetLexicalEnv(thread, state->env);
|
||||
cls->SetModule(thread, currentFunc->GetModule());
|
||||
|
||||
SlowRuntimeStub::SetClassConstructorLength(thread, res, JSTaggedValue(length));
|
||||
|
||||
@ -6508,7 +6501,8 @@ void InterpreterAssembly::HandleDefinemethodImm16Id16Imm8(
|
||||
LOG_INST() << "intrinsics::definemethod length: " << length;
|
||||
SAVE_ACC();
|
||||
constpool = GetConstantPool(sp);
|
||||
Method *method = Method::Cast(ConstantPool::GetMethodFromCache(thread, constpool, methodId).GetTaggedObject());
|
||||
Method *method =
|
||||
Method::Cast(ConstantPool::GetMethodFromCache(thread, constpool, GetModule(sp), methodId).GetTaggedObject());
|
||||
ASSERT(method != nullptr);
|
||||
RESTORE_ACC();
|
||||
|
||||
@ -6523,9 +6517,6 @@ void InterpreterAssembly::HandleDefinemethodImm16Id16Imm8(
|
||||
JSTaggedValue taggedCurEnv = state->env;
|
||||
result->SetLexicalEnv(thread, taggedCurEnv);
|
||||
|
||||
JSFunction *currentFunc =
|
||||
JSFunction::Cast(((reinterpret_cast<InterpretedFrame *>(sp) - 1)->function).GetTaggedObject());
|
||||
result->SetModule(thread, currentFunc->GetModule());
|
||||
SET_ACC(JSTaggedValue(result));
|
||||
|
||||
DISPATCH(DEFINEMETHOD_IMM16_ID16_IMM8);
|
||||
@ -6623,7 +6614,8 @@ void InterpreterAssembly::HandleDefinemethodImm8Id16Imm8(
|
||||
LOG_INST() << "intrinsics::definemethod length: " << length;
|
||||
SAVE_ACC();
|
||||
constpool = GetConstantPool(sp);
|
||||
Method *method = Method::Cast(ConstantPool::GetMethodFromCache(thread, constpool, methodId).GetTaggedObject());
|
||||
Method *method =
|
||||
Method::Cast(ConstantPool::GetMethodFromCache(thread, constpool, GetModule(sp), methodId).GetTaggedObject());
|
||||
ASSERT(method != nullptr);
|
||||
RESTORE_ACC();
|
||||
|
||||
@ -6638,9 +6630,6 @@ void InterpreterAssembly::HandleDefinemethodImm8Id16Imm8(
|
||||
JSTaggedValue taggedCurEnv = state->env;
|
||||
result->SetLexicalEnv(thread, taggedCurEnv);
|
||||
|
||||
JSFunction *currentFunc =
|
||||
JSFunction::Cast(((reinterpret_cast<InterpretedFrame *>(sp) - 1)->function).GetTaggedObject());
|
||||
result->SetModule(thread, currentFunc->GetModule());
|
||||
SET_ACC(JSTaggedValue(result));
|
||||
|
||||
DISPATCH(DEFINEMETHOD_IMM8_ID16_IMM8);
|
||||
@ -6655,7 +6644,8 @@ void InterpreterAssembly::HandleDefinefuncImm16Id16Imm8(
|
||||
LOG_INST() << "intrinsics::definefunc length: " << length;
|
||||
|
||||
constpool = GetConstantPool(sp);
|
||||
Method *method = Method::Cast(ConstantPool::GetMethodFromCache(thread, constpool, methodId).GetTaggedObject());
|
||||
Method *method =
|
||||
Method::Cast(ConstantPool::GetMethodFromCache(thread, constpool, GetModule(sp), methodId).GetTaggedObject());
|
||||
ASSERT(method != nullptr);
|
||||
|
||||
auto res = SlowRuntimeStub::DefineFunc(thread, method);
|
||||
@ -6668,7 +6658,6 @@ void InterpreterAssembly::HandleDefinefuncImm16Id16Imm8(
|
||||
|
||||
JSFunction *currentFunc =
|
||||
JSFunction::Cast(((reinterpret_cast<InterpretedFrame *>(sp) - 1)->function).GetTaggedObject());
|
||||
jsFunc->SetModule(thread, currentFunc->GetModule());
|
||||
jsFunc->SetHomeObject(thread, currentFunc->GetHomeObject());
|
||||
SET_ACC(JSTaggedValue(jsFunc));
|
||||
|
||||
@ -6683,7 +6672,8 @@ void InterpreterAssembly::HandleDefinefuncImm8Id16Imm8(
|
||||
uint16_t length = READ_INST_8_3();
|
||||
LOG_INST() << "intrinsics::definefunc length: " << length;
|
||||
constpool = GetConstantPool(sp);
|
||||
Method *method = Method::Cast(ConstantPool::GetMethodFromCache(thread, constpool, methodId).GetTaggedObject());
|
||||
Method *method =
|
||||
Method::Cast(ConstantPool::GetMethodFromCache(thread, constpool, GetModule(sp), methodId).GetTaggedObject());
|
||||
ASSERT(method != nullptr);
|
||||
|
||||
auto res = SlowRuntimeStub::DefineFunc(thread, method);
|
||||
@ -6696,7 +6686,6 @@ void InterpreterAssembly::HandleDefinefuncImm8Id16Imm8(
|
||||
|
||||
JSFunction *currentFunc =
|
||||
JSFunction::Cast(((reinterpret_cast<AsmInterpretedFrame *>(sp) - 1)->function).GetTaggedObject());
|
||||
jsFunc->SetModule(thread, currentFunc->GetModule());
|
||||
jsFunc->SetHomeObject(thread, currentFunc->GetHomeObject());
|
||||
SET_ACC(JSTaggedValue(jsFunc));
|
||||
|
||||
@ -7355,11 +7344,9 @@ void InterpreterAssembly::HandleCreateobjectwithbufferImm16Id16(
|
||||
LOG_INST() << "intrinsics::createobjectwithbuffer"
|
||||
<< " imm:" << imm;
|
||||
constpool = GetConstantPool(sp);
|
||||
JSFunction *currentFunc =
|
||||
JSFunction::Cast(((reinterpret_cast<InterpretedFrame *>(sp) - 1)->function).GetTaggedObject());
|
||||
JSObject *result = JSObject::Cast(
|
||||
ConstantPool::GetLiteralFromCache<ConstPoolType::OBJECT_LITERAL>(
|
||||
thread, constpool, imm, currentFunc->GetModule()).GetTaggedObject());
|
||||
thread, constpool, imm, GetModule(sp)).GetTaggedObject());
|
||||
SAVE_PC();
|
||||
InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1);
|
||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||
@ -7378,11 +7365,9 @@ void InterpreterAssembly::HandleCreateobjectwithbufferImm8Id16(
|
||||
LOG_INST() << "intrinsics::createobjectwithbuffer"
|
||||
<< " imm:" << imm;
|
||||
constpool = GetConstantPool(sp);
|
||||
JSFunction *currentFunc =
|
||||
JSFunction::Cast(((reinterpret_cast<InterpretedFrame *>(sp) - 1)->function).GetTaggedObject());
|
||||
JSObject *result = JSObject::Cast(
|
||||
ConstantPool::GetLiteralFromCache<ConstPoolType::OBJECT_LITERAL>(
|
||||
thread, constpool, imm, currentFunc->GetModule()).GetTaggedObject());
|
||||
thread, constpool, imm, GetModule(sp)).GetTaggedObject());
|
||||
SAVE_PC();
|
||||
InterpretedFrame *state = (reinterpret_cast<InterpretedFrame *>(sp) - 1);
|
||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||
@ -7417,11 +7402,9 @@ void InterpreterAssembly::HandleCreatearraywithbufferImm8Id16(
|
||||
LOG_INST() << "intrinsics::createarraywithbuffer"
|
||||
<< " imm:" << imm;
|
||||
constpool = GetConstantPool(sp);
|
||||
JSFunction *currentFunc =
|
||||
JSFunction::Cast(((reinterpret_cast<InterpretedFrame *>(sp) - 1)->function).GetTaggedObject());
|
||||
JSArray *result = JSArray::Cast(
|
||||
ConstantPool::GetLiteralFromCache<ConstPoolType::ARRAY_LITERAL>(
|
||||
thread, constpool, imm, currentFunc->GetModule()).GetTaggedObject());
|
||||
thread, constpool, imm, GetModule(sp)).GetTaggedObject());
|
||||
SAVE_PC();
|
||||
EcmaVM *ecmaVm = thread->GetEcmaVM();
|
||||
ObjectFactory *factory = ecmaVm->GetFactory();
|
||||
@ -7566,6 +7549,14 @@ JSTaggedValue InterpreterAssembly::GetConstantPool(JSTaggedType *sp)
|
||||
return method->GetConstantPool();
|
||||
}
|
||||
|
||||
JSTaggedValue InterpreterAssembly::GetModule(JSTaggedType *sp)
|
||||
{
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
AsmInterpretedFrame *state = reinterpret_cast<AsmInterpretedFrame *>(sp) - 1;
|
||||
Method *method = JSFunction::Cast(state->function.GetTaggedObject())->GetCallTarget();
|
||||
return method->GetModule();
|
||||
}
|
||||
|
||||
JSTaggedValue InterpreterAssembly::GetProfileTypeInfo(JSTaggedType *sp)
|
||||
{
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
|
@ -49,6 +49,7 @@ public:
|
||||
static JSTaggedValue GetNewTarget(JSTaggedType *sp);
|
||||
static JSTaggedValue GetThis(JSTaggedType *sp);
|
||||
static JSTaggedValue GetConstantPool(JSTaggedType *sp);
|
||||
static JSTaggedValue GetModule(JSTaggedType *sp);
|
||||
static JSTaggedValue GetProfileTypeInfo(JSTaggedType *sp);
|
||||
static uint32_t GetNumArgs(JSTaggedType *sp, uint32_t restIdx, uint32_t &startIdx);
|
||||
static JSTaggedType *GetAsmInterpreterFramePointer(AsmInterpretedFrame *state);
|
||||
|
@ -37,7 +37,6 @@ void JSFunction::InitializeJSFunction(JSThread *thread, const JSHandle<JSFunctio
|
||||
func->SetProtoOrHClass(thread, JSTaggedValue::Hole(), SKIP_BARRIER);
|
||||
func->SetHomeObject(thread, JSTaggedValue::Undefined(), SKIP_BARRIER);
|
||||
func->SetLexicalEnv(thread, JSTaggedValue::Undefined(), SKIP_BARRIER);
|
||||
func->SetModule(thread, JSTaggedValue::Undefined(), SKIP_BARRIER);
|
||||
func->SetMethod(thread, JSTaggedValue::Undefined(), SKIP_BARRIER);
|
||||
|
||||
auto globalConst = thread->GlobalConstants();
|
||||
@ -805,22 +804,4 @@ JSTaggedValue JSFunction::GetNativeFunctionExtraInfo() const
|
||||
}
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
|
||||
JSTaggedValue JSFunction::GetRecordName() const
|
||||
{
|
||||
JSTaggedValue module = GetModule();
|
||||
if (module.IsSourceTextModule()) {
|
||||
JSTaggedValue recordName = SourceTextModule::Cast(module.GetTaggedObject())->GetEcmaModuleRecordName();
|
||||
if (!recordName.IsString()) {
|
||||
LOG_INTERPRETER(DEBUG) << "module record name is undefined";
|
||||
return JSTaggedValue::Hole();
|
||||
}
|
||||
return recordName;
|
||||
}
|
||||
if (module.IsString()) {
|
||||
return module;
|
||||
}
|
||||
LOG_INTERPRETER(DEBUG) << "record name is undefined";
|
||||
return JSTaggedValue::Hole();
|
||||
}
|
||||
} // namespace panda::ecmascript
|
||||
|
@ -58,6 +58,12 @@ public:
|
||||
return Method::ConstCast(method.GetTaggedObject())->GetFunctionKind();
|
||||
}
|
||||
|
||||
JSTaggedValue GetModule() const
|
||||
{
|
||||
JSTaggedValue method = GetMethod();
|
||||
return Method::ConstCast(method.GetTaggedObject())->GetModule();
|
||||
}
|
||||
|
||||
static constexpr size_t METHOD_OFFSET = JSObject::SIZE;
|
||||
ACCESSORS(Method, METHOD_OFFSET, LAST_OFFSET)
|
||||
DEFINE_ALIGN_SIZE(LAST_OFFSET);
|
||||
@ -227,8 +233,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, ECMA_MODULE_OFFSET)
|
||||
ACCESSORS(Module, ECMA_MODULE_OFFSET, LAST_OFFSET)
|
||||
ACCESSORS(HomeObject, HOME_OBJECT_OFFSET, LAST_OFFSET)
|
||||
DEFINE_ALIGN_SIZE(LAST_OFFSET);
|
||||
|
||||
DECL_VISIT_OBJECT_FOR_JS_OBJECT(JSFunctionBase, PROTO_OR_DYNCLASS_OFFSET, SIZE)
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "ecmascript/compiler/aot_file/aot_file_manager.h"
|
||||
#include "ecmascript/ecma_string.h"
|
||||
#include "ecmascript/global_env.h"
|
||||
#include "ecmascript/js_tagged_value.h"
|
||||
#include "ecmascript/js_thread.h"
|
||||
#include "ecmascript/module/js_module_manager.h"
|
||||
#include "ecmascript/patch/quick_fix_manager.h"
|
||||
@ -222,10 +223,6 @@ JSHandle<JSFunction> LiteralDataExtractor::DefineMethodInLiteral(JSThread *threa
|
||||
ASSERT(methodLiteral != nullptr);
|
||||
methodLiteral->SetFunctionKind(kind);
|
||||
bool canFastCall = false;
|
||||
JSHandle<Method> method = factory->NewMethod(
|
||||
jsPandaFile, methodLiteral, constpool, entryIndex, isLoadedAOT, &canFastCall);
|
||||
JSHandle<JSFunction> jsFunc = factory->NewJSFunction(method, kind, isLoadedAOT, canFastCall);
|
||||
jsFunc->SetPropertyInlinedProps(thread, JSFunction::LENGTH_INLINE_PROPERTY_INDEX, JSTaggedValue(length));
|
||||
|
||||
CString moduleName = jsPandaFile->GetJSPandaFileDesc();
|
||||
CString entry = JSPandaFile::ENTRY_FUNCTION_NAME;
|
||||
@ -238,11 +235,16 @@ JSHandle<JSFunction> LiteralDataExtractor::DefineMethodInLiteral(JSThread *threa
|
||||
if (!hasRecord) {
|
||||
LOG_ECMA(FATAL) << "cannot find record '" + entry + "', please check the request path.";
|
||||
}
|
||||
JSHandle<SourceTextModule> module(thread, JSTaggedValue::Undefined());
|
||||
if (jsPandaFile->IsModule(recordInfo)) {
|
||||
JSHandle<SourceTextModule> module = thread->GetCurrentEcmaContext()->GetModuleManager()->HostGetImportedModule(
|
||||
moduleName);
|
||||
jsFunc->SetModule(thread, module.GetTaggedValue());
|
||||
module = thread->GetCurrentEcmaContext()->GetModuleManager()->HostGetImportedModule(moduleName);
|
||||
}
|
||||
|
||||
JSHandle<Method> method = factory->NewMethod(jsPandaFile, methodLiteral, constpool,
|
||||
JSHandle<JSTaggedValue>(thread, module.GetTaggedValue()), entryIndex, isLoadedAOT, &canFastCall);
|
||||
JSHandle<JSFunction> jsFunc = factory->NewJSFunction(method, kind, isLoadedAOT, canFastCall);
|
||||
jsFunc->SetPropertyInlinedProps(thread, JSFunction::LENGTH_INLINE_PROPERTY_INDEX, JSTaggedValue(length));
|
||||
|
||||
return jsFunc;
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,8 @@ public:
|
||||
return Get(index);
|
||||
}
|
||||
|
||||
static JSTaggedValue GetMethodFromCache(JSThread *thread, JSTaggedValue constpool, uint32_t index)
|
||||
static JSTaggedValue GetMethodFromCache(
|
||||
JSThread *thread, JSTaggedValue constpool, JSTaggedValue module, uint32_t index)
|
||||
{
|
||||
const ConstantPool *taggedPool = ConstantPool::Cast(constpool.GetTaggedObject());
|
||||
auto val = taggedPool->GetObjectFromCache(index);
|
||||
@ -219,13 +220,14 @@ public:
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
ASSERT(jsPandaFile->IsNewVersion());
|
||||
JSHandle<ConstantPool> constpoolHandle(thread, constpool);
|
||||
JSHandle<JSTaggedValue> moduleHandle(thread, module);
|
||||
EcmaVM *vm = thread->GetEcmaVM();
|
||||
|
||||
EntityId id = constpoolHandle->GetEntityId(index);
|
||||
MethodLiteral *methodLiteral = jsPandaFile->FindMethodLiteral(id.GetOffset());
|
||||
ASSERT(methodLiteral != nullptr);
|
||||
ObjectFactory *factory = vm->GetFactory();
|
||||
JSHandle<Method> method = factory->NewMethod(jsPandaFile, methodLiteral, constpoolHandle,
|
||||
JSHandle<Method> method = factory->NewMethod(jsPandaFile, methodLiteral, constpoolHandle, moduleHandle,
|
||||
entryIndex, isLoadedAOT && hasEntryIndex);
|
||||
constpoolHandle->SetObjectToCache(thread, index, method.GetTaggedValue());
|
||||
return method.GetTaggedValue();
|
||||
|
@ -36,7 +36,7 @@ const char *Method::GetMethodName(const JSPandaFile *file) const
|
||||
return MethodLiteral::GetMethodName(file, GetMethodId());
|
||||
}
|
||||
|
||||
const CString Method::GetRecordName() const
|
||||
const CString Method::GetRecordNameStr() const
|
||||
{
|
||||
const JSPandaFile *jsPandaFile = GetJSPandaFile();
|
||||
return MethodLiteral::GetRecordName(jsPandaFile, GetMethodId());
|
||||
@ -103,4 +103,22 @@ JSHandle<Method> Method::Create(JSThread *thread, const JSPandaFile *jsPandaFile
|
||||
method->SetConstantPool(thread, newConstpool);
|
||||
return method;
|
||||
}
|
||||
|
||||
const JSTaggedValue Method::GetRecordName() const
|
||||
{
|
||||
JSTaggedValue module = GetModule();
|
||||
if (module.IsSourceTextModule()) {
|
||||
JSTaggedValue recordName = SourceTextModule::Cast(module.GetTaggedObject())->GetEcmaModuleRecordName();
|
||||
if (!recordName.IsString()) {
|
||||
LOG_INTERPRETER(DEBUG) << "module record name is undefined";
|
||||
return JSTaggedValue::Hole();
|
||||
}
|
||||
return recordName;
|
||||
}
|
||||
if (module.IsString()) {
|
||||
return module;
|
||||
}
|
||||
LOG_INTERPRETER(DEBUG) << "record name is undefined";
|
||||
return JSTaggedValue::Hole();
|
||||
}
|
||||
} // namespace panda::ecmascript
|
||||
|
@ -413,10 +413,12 @@ public:
|
||||
const char *PUBLIC_API GetMethodName() const;
|
||||
const char *PUBLIC_API GetMethodName(const JSPandaFile *file) const;
|
||||
std::string PUBLIC_API ParseFunctionName() const;
|
||||
const CString GetRecordName() const;
|
||||
const CString GetRecordNameStr() const;
|
||||
|
||||
uint32_t FindCatchBlock(uint32_t pc) const;
|
||||
|
||||
const JSTaggedValue GetRecordName() const;
|
||||
|
||||
/* callfield */
|
||||
static constexpr size_t VREGS_ARGS_NUM_BITS = 28; // 28: maximum 268,435,455
|
||||
static constexpr uint64_t AOT_FASTCALL_BITS = 0x5; // 0x5LU: aot and fastcall bit field
|
||||
@ -444,7 +446,8 @@ public:
|
||||
|
||||
static constexpr size_t CONSTANT_POOL_OFFSET = TaggedObjectSize();
|
||||
ACCESSORS(ConstantPool, CONSTANT_POOL_OFFSET, PROFILE_TYPE_INFO_OFFSET)
|
||||
ACCESSORS(ProfileTypeInfo, PROFILE_TYPE_INFO_OFFSET, CALL_FIELD_OFFSET)
|
||||
ACCESSORS(ProfileTypeInfo, PROFILE_TYPE_INFO_OFFSET, ECMA_MODULE_OFFSET)
|
||||
ACCESSORS(Module, ECMA_MODULE_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(
|
||||
|
@ -46,8 +46,8 @@ ModuleManager::ModuleManager(EcmaVM *vm) : vm_(vm)
|
||||
JSTaggedValue ModuleManager::GetCurrentModule()
|
||||
{
|
||||
FrameHandler frameHandler(vm_->GetJSThread());
|
||||
JSTaggedValue currentFunc = frameHandler.GetFunction();
|
||||
return JSFunction::Cast(currentFunc.GetTaggedObject())->GetModule();
|
||||
Method *currentMethod = frameHandler.GetMethod();
|
||||
return currentMethod->GetModule();
|
||||
}
|
||||
|
||||
JSTaggedValue ModuleManager::GetModuleValueInner(int32_t index)
|
||||
|
@ -1850,8 +1850,7 @@ Local<StringRef> FunctionRef::GetSourceCode(const EcmaVM *vm, int lineNumber)
|
||||
DebugInfoExtractor *debugExtractor = JSPandaFileManager::GetInstance()->GetJSPtExtractor(jsPandaFile);
|
||||
ecmascript::CString entry = JSPandaFile::ENTRY_FUNCTION_NAME;
|
||||
if (!jsPandaFile->IsBundlePack()) {
|
||||
JSFunction *function = JSFunction::Cast(func.GetTaggedValue().GetTaggedObject());
|
||||
JSTaggedValue recordName = function->GetRecordName();
|
||||
JSTaggedValue recordName = method->GetRecordName();
|
||||
ASSERT(!recordName.IsHole());
|
||||
entry = ConvertToString(recordName);
|
||||
}
|
||||
@ -3611,7 +3610,7 @@ bool JSNApi::InitForConcurrentFunction(EcmaVM *vm, Local<JSValueRef> function, v
|
||||
return false;
|
||||
}
|
||||
ecmascript::CString moduleName = jsPandaFile->GetJSPandaFileDesc();
|
||||
ecmascript::CString recordName = method->GetRecordName();
|
||||
ecmascript::CString recordName = method->GetRecordNameStr();
|
||||
|
||||
// for debugger, to notify the script loaded and parsed which the concurrent function is in
|
||||
auto *notificationMgr = vm->GetJsDebuggerManager()->GetNotificationManager();
|
||||
@ -3642,7 +3641,7 @@ bool JSNApi::InitForConcurrentFunction(EcmaVM *vm, Local<JSValueRef> function, v
|
||||
JSHandle<ecmascript::SourceTextModule> module = JSHandle<ecmascript::SourceTextModule>::Cast(moduleRecord);
|
||||
module->SetStatus(ecmascript::ModuleStatus::INSTANTIATED);
|
||||
ecmascript::SourceTextModule::EvaluateForConcurrent(thread, module);
|
||||
transFunc->SetModule(thread, module);
|
||||
method->SetModule(thread, module);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -585,7 +585,6 @@ JSHandle<JSFunction> ObjectFactory::CloneJSFuction(JSHandle<JSFunction> func)
|
||||
|
||||
JSTaggedValue length = func->GetPropertyInlinedProps(JSFunction::LENGTH_INLINE_PROPERTY_INDEX);
|
||||
cloneFunc->SetPropertyInlinedProps(thread_, JSFunction::LENGTH_INLINE_PROPERTY_INDEX, length);
|
||||
cloneFunc->SetModule(thread_, func->GetModule());
|
||||
return cloneFunc;
|
||||
}
|
||||
|
||||
@ -1616,11 +1615,13 @@ JSHandle<Method> ObjectFactory::NewMethod(const MethodLiteral *methodLiteral, Me
|
||||
method->SetCodeEntryOrLiteral(reinterpret_cast<uintptr_t>(methodLiteral));
|
||||
method->SetConstantPool(thread_, JSTaggedValue::Undefined());
|
||||
method->SetProfileTypeInfo(thread_, JSTaggedValue::Undefined());
|
||||
method->SetModule(thread_, JSTaggedValue::Undefined());
|
||||
return method;
|
||||
}
|
||||
|
||||
JSHandle<Method> ObjectFactory::NewMethod(const JSPandaFile *jsPandaFile, MethodLiteral *methodLiteral,
|
||||
JSHandle<ConstantPool> constpool, uint32_t entryIndex, bool needSetAotFlag, bool *canFastCall)
|
||||
JSHandle<ConstantPool> constpool, JSHandle<JSTaggedValue> module,
|
||||
uint32_t entryIndex, bool needSetAotFlag, bool *canFastCall)
|
||||
{
|
||||
JSHandle<Method> method;
|
||||
if (jsPandaFile->IsNewVersion()) {
|
||||
@ -1629,6 +1630,7 @@ JSHandle<Method> ObjectFactory::NewMethod(const JSPandaFile *jsPandaFile, Method
|
||||
method = NewMethod(methodLiteral);
|
||||
method->SetConstantPool(thread_, constpool);
|
||||
}
|
||||
method->SetModule(thread_, module);
|
||||
if (needSetAotFlag) {
|
||||
thread_->GetCurrentEcmaContext()->GetAOTFileManager()->
|
||||
SetAOTFuncEntry(jsPandaFile, *method, entryIndex, canFastCall);
|
||||
|
@ -483,7 +483,8 @@ public:
|
||||
JSHandle<Method> NewMethod(const MethodLiteral *methodLiteral, MemSpaceType spaceType = OLD_SPACE);
|
||||
|
||||
JSHandle<Method> NewMethod(const JSPandaFile *jsPandaFile, MethodLiteral *methodLiteral,
|
||||
JSHandle<ConstantPool> constpool, uint32_t entryIndex, bool needSetAotFlag, bool *canFastCall = nullptr);
|
||||
JSHandle<ConstantPool> constpool, JSHandle<JSTaggedValue> module,
|
||||
uint32_t entryIndex, bool needSetAotFlag, bool *canFastCall = nullptr);
|
||||
|
||||
// used for creating jsobject by constructor
|
||||
JSHandle<JSObject> NewJSObjectByConstructor(const JSHandle<JSFunction> &constructor,
|
||||
|
@ -113,7 +113,7 @@ bool PatchLoader::ExecutePatchMain(JSThread *thread, const JSPandaFile *patchFil
|
||||
JSHandle<JSTaggedValue> module =
|
||||
thread->GetCurrentEcmaContext()->GetModuleManager()->HostResolveImportedModuleWithMerge(
|
||||
patchFile->GetJSPandaFileDesc(), recordName);
|
||||
func->SetModule(thread, module);
|
||||
Method::Cast(func->GetMethod())->SetModule(thread, module);
|
||||
EcmaRuntimeCallInfo *info =
|
||||
EcmaInterpreter::NewRuntimeCallInfo(thread, JSHandle<JSTaggedValue>(func), undefined, undefined, 0);
|
||||
EcmaInterpreter::Execute(info);
|
||||
@ -183,7 +183,7 @@ PatchErrorCode PatchLoader::UnloadPatchInternal(JSThread *thread, const CString
|
||||
baseFile.get(), baseMethodLiteral->GetMethodId());
|
||||
ReplaceMethod(thread, patchMethod, baseMethodLiteral, baseConstpoolValue);
|
||||
LOG_ECMA(INFO) << "Replace base method: "
|
||||
<< patchMethod->GetRecordName()
|
||||
<< patchMethod->GetRecordNameStr()
|
||||
<< ":" << patchMethod->GetMethodName();
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ void PGOProfiler::ProfileCall(JSTaggedType callTarget, SampleMode mode, int32_t
|
||||
return;
|
||||
}
|
||||
auto calleeMethod = Method::Cast(JSFunction::Cast(calleeFunc)->GetMethod());
|
||||
JSTaggedValue calleeRecordNameValue = JSFunction::Cast(calleeFunc)->GetRecordName();
|
||||
JSTaggedValue calleeRecordNameValue = calleeMethod->GetRecordName();
|
||||
if (calleeRecordNameValue.IsHole()) {
|
||||
return;
|
||||
}
|
||||
@ -194,15 +194,16 @@ void PGOProfiler::HandlePGOPreDump()
|
||||
continue;
|
||||
}
|
||||
JSFunction *func = JSFunction::Cast(funcValue.GetTaggedObject());
|
||||
JSTaggedValue recordNameValue = func->GetRecordName();
|
||||
JSTaggedValue methodValue = func->GetMethod();
|
||||
if (!methodValue.IsMethod()) {
|
||||
continue;
|
||||
}
|
||||
JSTaggedValue recordNameValue = Method::Cast(methodValue)->GetRecordName();
|
||||
if (!recordNameValue.IsString()) {
|
||||
continue;
|
||||
}
|
||||
CString recordName = ConvertToString(recordNameValue);
|
||||
JSTaggedValue methodValue = func->GetMethod();
|
||||
if (methodValue.IsMethod()) {
|
||||
ProfileByteCode(recordName, methodValue);
|
||||
}
|
||||
ProfileByteCode(recordName, methodValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,17 +216,19 @@ void PGOProfiler::HandlePGODump()
|
||||
JSTaggedValue current = PopFromProfileQueue();
|
||||
while (current.IsJSFunction()) {
|
||||
JSFunction *func = JSFunction::Cast(current.GetTaggedObject());
|
||||
JSTaggedValue recordNameValue = func->GetRecordName();
|
||||
JSTaggedValue methodValue = func->GetMethod();
|
||||
if (!methodValue.IsMethod()) {
|
||||
current = PopFromProfileQueue();
|
||||
continue;
|
||||
}
|
||||
JSTaggedValue recordNameValue = Method::Cast(methodValue)->GetRecordName();
|
||||
if (!recordNameValue.IsString()) {
|
||||
current = PopFromProfileQueue();
|
||||
continue;
|
||||
}
|
||||
CString recordName = ConvertToString(recordNameValue);
|
||||
JSTaggedValue methodValue = func->GetMethod();
|
||||
if (methodValue.IsMethod()) {
|
||||
ProfileByteCode(recordName, methodValue);
|
||||
methodCount_++;
|
||||
}
|
||||
ProfileByteCode(recordName, methodValue);
|
||||
methodCount_++;
|
||||
current = PopFromProfileQueue();
|
||||
}
|
||||
if (state_ == State::PAUSE) {
|
||||
|
@ -141,7 +141,7 @@ HWTEST_F_L0(PGOProfilerTest, Sample)
|
||||
method->SetConstantPool(vm_->GetJSThread(), constPool.GetTaggedValue());
|
||||
JSHandle<JSFunction> func = vm_->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method);
|
||||
JSHandle<JSTaggedValue> recordName(vm_->GetFactory()->NewFromStdString("test"));
|
||||
func->SetModule(vm_->GetJSThread(), recordName);
|
||||
method->SetModule(vm_->GetJSThread(), recordName);
|
||||
vm_->GetPGOProfiler()->SetSaveTimestamp(std::chrono::system_clock::now());
|
||||
vm_->GetPGOProfiler()->ProfileCall(func.GetTaggedType());
|
||||
JSNApi::DestroyJSVM(vm_);
|
||||
@ -196,9 +196,9 @@ HWTEST_F_L0(PGOProfilerTest, Sample1)
|
||||
JSHandle<JSFunction> func1 = vm_->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method1);
|
||||
JSHandle<JSFunction> func2 = vm_->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method2);
|
||||
JSHandle<JSTaggedValue> recordName(vm_->GetFactory()->NewFromStdString("test"));
|
||||
func->SetModule(vm_->GetJSThread(), recordName);
|
||||
func1->SetModule(vm_->GetJSThread(), recordName);
|
||||
func2->SetModule(vm_->GetJSThread(), recordName);
|
||||
method->SetModule(vm_->GetJSThread(), recordName);
|
||||
method1->SetModule(vm_->GetJSThread(), recordName);
|
||||
method2->SetModule(vm_->GetJSThread(), recordName);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
vm_->GetPGOProfiler()->ProfileCall(func.GetTaggedType());
|
||||
}
|
||||
@ -257,11 +257,11 @@ HWTEST_F_L0(PGOProfilerTest, Sample2)
|
||||
method->SetConstantPool(vm_->GetJSThread(), constPool.GetTaggedValue());
|
||||
method1->SetConstantPool(vm_->GetJSThread(), constPool.GetTaggedValue());
|
||||
JSHandle<JSFunction> func = vm_->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method);
|
||||
JSHandle<JSTaggedValue> recordName(vm_->GetFactory()->NewFromStdString("test"));
|
||||
func->SetModule(vm_->GetJSThread(), recordName);
|
||||
JSHandle<JSFunction> func1 = vm_->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method1);
|
||||
JSHandle<JSTaggedValue> recordName(vm_->GetFactory()->NewFromStdString("test"));
|
||||
method->SetModule(vm_->GetJSThread(), recordName);
|
||||
JSHandle<JSTaggedValue> recordName1(vm_->GetFactory()->NewFromStdString("test1"));
|
||||
func1->SetModule(vm_->GetJSThread(), recordName1);
|
||||
method1->SetModule(vm_->GetJSThread(), recordName1);
|
||||
vm_->GetPGOProfiler()->ProfileCall(func.GetTaggedType());
|
||||
for (int i = 0; i < 5; i++) {
|
||||
vm_->GetPGOProfiler()->ProfileCall(func1.GetTaggedType());
|
||||
@ -317,7 +317,7 @@ HWTEST_F_L0(PGOProfilerTest, DisEnableSample)
|
||||
method->SetConstantPool(vm_->GetJSThread(), constPool.GetTaggedValue());
|
||||
JSHandle<JSFunction> func = vm_->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method);
|
||||
JSHandle<JSTaggedValue> recordName(vm_->GetFactory()->NewFromStdString("test"));
|
||||
func->SetModule(vm_->GetJSThread(), recordName);
|
||||
method->SetModule(vm_->GetJSThread(), recordName);
|
||||
vm_->GetPGOProfiler()->ProfileCall(func.GetTaggedType());
|
||||
JSNApi::DestroyJSVM(vm_);
|
||||
|
||||
@ -374,7 +374,7 @@ HWTEST_F_L0(PGOProfilerTest, PGOProfilerManagerSample)
|
||||
MethodLiteral *methodLiteral = new MethodLiteral(EntityId(61));
|
||||
JSHandle<Method> method = vm_->GetFactory()->NewMethod(methodLiteral);
|
||||
JSHandle<JSFunction> func = vm_->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method);
|
||||
func->SetModule(vm_->GetJSThread(), JSTaggedValue::Hole());
|
||||
method->SetModule(vm_->GetJSThread(), JSTaggedValue::Hole());
|
||||
vm_->GetPGOProfiler()->ProfileCall(func.GetTaggedType());
|
||||
JSNApi::DestroyJSVM(vm_);
|
||||
|
||||
@ -420,7 +420,7 @@ HWTEST_F_L0(PGOProfilerTest, PGOProfilerDoubleVM)
|
||||
method->SetConstantPool(vm2->GetJSThread(), constPool2.GetTaggedValue());
|
||||
JSHandle<JSFunction> func = vm2->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method);
|
||||
JSHandle<JSTaggedValue> recordName(vm_->GetFactory()->NewFromStdString("test"));
|
||||
func->SetModule(vm2->GetJSThread(), recordName);
|
||||
method->SetModule(vm2->GetJSThread(), recordName);
|
||||
vm2->GetPGOProfiler()->ProfileCall(func.GetTaggedType());
|
||||
|
||||
JSHandle<Method> method1 = vm_->GetFactory()->NewMethod(methodLiterals[0]);
|
||||
@ -430,8 +430,8 @@ HWTEST_F_L0(PGOProfilerTest, PGOProfilerDoubleVM)
|
||||
JSHandle<JSFunction> func1 = vm_->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method1);
|
||||
JSHandle<JSFunction> func2 = vm_->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method2);
|
||||
JSHandle<JSTaggedValue> recordName1(vm_->GetFactory()->NewFromStdString("test"));
|
||||
func1->SetModule(vm_->GetJSThread(), recordName);
|
||||
func2->SetModule(vm_->GetJSThread(), recordName);
|
||||
method1->SetModule(vm_->GetJSThread(), recordName);
|
||||
method2->SetModule(vm_->GetJSThread(), recordName);
|
||||
vm_->GetPGOProfiler()->ProfileCall(func1.GetTaggedType());
|
||||
vm_->GetPGOProfiler()->ProfileCall(func2.GetTaggedType());
|
||||
|
||||
@ -482,7 +482,7 @@ HWTEST_F_L0(PGOProfilerTest, PGOProfilerDecoderNoHotMethod)
|
||||
method->SetConstantPool(vm_->GetJSThread(), constPool.GetTaggedValue());
|
||||
JSHandle<JSFunction> func = vm_->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method);
|
||||
JSHandle<JSTaggedValue> recordName(vm_->GetFactory()->NewFromStdString("test"));
|
||||
func->SetModule(vm_->GetJSThread(), recordName);
|
||||
method->SetModule(vm_->GetJSThread(), recordName);
|
||||
vm_->GetPGOProfiler()->ProfileCall(func.GetTaggedType());
|
||||
JSNApi::DestroyJSVM(vm_);
|
||||
|
||||
@ -527,7 +527,7 @@ HWTEST_F_L0(PGOProfilerTest, PGOProfilerPostTask)
|
||||
JSHandle<Method> method = vm_->GetFactory()->NewMethod(methodLiterals[i]);
|
||||
method->SetConstantPool(vm_->GetJSThread(), constPool.GetTaggedValue());
|
||||
JSHandle<JSFunction> func = vm_->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method);
|
||||
func->SetModule(vm_->GetJSThread(), recordName);
|
||||
method->SetModule(vm_->GetJSThread(), recordName);
|
||||
vm_->GetPGOProfiler()->ProfileCall(func.GetTaggedType());
|
||||
if (i % 3 == 0) {
|
||||
vm_->GetPGOProfiler()->ProfileCall(func.GetTaggedType());
|
||||
@ -653,7 +653,7 @@ HWTEST_F_L0(PGOProfilerTest, FailResetProfilerInWorker)
|
||||
method->SetConstantPool(vm_->GetJSThread(), constPool.GetTaggedValue());
|
||||
JSHandle<JSFunction> func = vm_->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method);
|
||||
JSHandle<JSTaggedValue> recordName(vm_->GetFactory()->NewFromStdString("test"));
|
||||
func->SetModule(vm_->GetJSThread(), recordName);
|
||||
method->SetModule(vm_->GetJSThread(), recordName);
|
||||
vm_->GetPGOProfiler()->ProfileCall(func.GetTaggedType());
|
||||
JSNApi::DestroyJSVM(vm_);
|
||||
|
||||
@ -992,7 +992,7 @@ HWTEST_F_L0(PGOProfilerTest, FileConsistencyCheck)
|
||||
method->SetConstantPool(vm_->GetJSThread(), constPool.GetTaggedValue());
|
||||
JSHandle<JSFunction> func = vm_->GetFactory()->NewJSFunction(vm_->GetGlobalEnv(), method);
|
||||
JSHandle<JSTaggedValue> recordName(vm_->GetFactory()->NewFromStdString("test"));
|
||||
func->SetModule(vm_->GetJSThread(), recordName);
|
||||
method->SetModule(vm_->GetJSThread(), recordName);
|
||||
vm_->GetPGOProfiler()->SetSaveTimestamp(std::chrono::system_clock::now());
|
||||
vm_->GetPGOProfiler()->ProfileCall(func.GetTaggedType());
|
||||
JSNApi::DestroyJSVM(vm_);
|
||||
|
@ -754,8 +754,8 @@ JSTaggedValue RuntimeStubs::RuntimeResolveClass(JSThread *thread, const JSHandle
|
||||
ASSERT(ctor.GetTaggedValue().IsClassConstructor());
|
||||
|
||||
FrameHandler frameHandler(thread);
|
||||
JSTaggedValue currentFunc = frameHandler.GetFunction();
|
||||
JSHandle<JSTaggedValue> ecmaModule(thread, JSFunction::Cast(currentFunc.GetTaggedObject())->GetModule());
|
||||
Method *currentMethod = frameHandler.GetMethod();
|
||||
JSHandle<JSTaggedValue> ecmaModule(thread, currentMethod->GetModule());
|
||||
|
||||
RuntimeSetClassInheritanceRelationship(thread, JSHandle<JSTaggedValue>(ctor), base);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
@ -768,7 +768,7 @@ JSTaggedValue RuntimeStubs::RuntimeResolveClass(JSThread *thread, const JSHandle
|
||||
if (LIKELY(value.IsJSFunction())) {
|
||||
JSFunction *func = JSFunction::Cast(value.GetTaggedObject());
|
||||
func->SetLexicalEnv(thread, lexenv.GetTaggedValue());
|
||||
func->SetModule(thread, ecmaModule);
|
||||
Method::Cast(func->GetMethod())->SetModule(thread, ecmaModule);
|
||||
}
|
||||
}
|
||||
|
||||
@ -824,7 +824,8 @@ JSTaggedValue RuntimeStubs::RuntimeCreateClassWithBuffer(JSThread *thread,
|
||||
CString entry = ModuleManager::GetRecordName(module.GetTaggedValue());
|
||||
|
||||
// For class constructor.
|
||||
auto methodObj = ConstantPool::GetMethodFromCache(thread, constpool.GetTaggedValue(), methodId);
|
||||
auto methodObj = ConstantPool::GetMethodFromCache(
|
||||
thread, constpool.GetTaggedValue(), module.GetTaggedValue(), methodId);
|
||||
JSHandle<JSTaggedValue> method(thread, methodObj);
|
||||
JSHandle<ConstantPool> constpoolHandle = JSHandle<ConstantPool>::Cast(constpool);
|
||||
JSHandle<JSFunction> cls;
|
||||
@ -1388,8 +1389,7 @@ JSTaggedValue RuntimeStubs::RuntimeDynamicImport(JSThread *thread, const JSHandl
|
||||
if (jsPandaFile->IsBundlePack()) {
|
||||
dirPath.Update(factory->NewFromUtf8(currentfilename).GetTaggedValue());
|
||||
} else {
|
||||
JSFunction *function = JSFunction::Cast(func.GetTaggedValue().GetTaggedObject());
|
||||
recordName.Update(function->GetRecordName());
|
||||
recordName.Update(method->GetRecordName());
|
||||
dirPath.Update(factory->NewFromUtf8(currentfilename).GetTaggedValue());
|
||||
}
|
||||
|
||||
|
@ -820,8 +820,9 @@ DEF_RUNTIME_STUBS(GetMethodFromCache)
|
||||
RUNTIME_STUBS_HEADER(GetMethodFromCache);
|
||||
JSHandle<JSTaggedValue> constpool = GetHArg<JSTaggedValue>(argv, argc, 0); // 0: means the zeroth parameter
|
||||
JSTaggedValue index = GetArg(argv, argc, 1); // 1: means the first parameter
|
||||
JSHandle<JSTaggedValue> module = GetHArg<JSTaggedValue>(argv, argc, 2); // 2: means the second parameter
|
||||
return ConstantPool::GetMethodFromCache(
|
||||
thread, constpool.GetTaggedValue(), index.GetInt()).GetRawData();
|
||||
thread, constpool.GetTaggedValue(), module.GetTaggedValue(), index.GetInt()).GetRawData();
|
||||
}
|
||||
|
||||
DEF_RUNTIME_STUBS(GetStringFromCache)
|
||||
@ -2445,8 +2446,8 @@ DEF_RUNTIME_STUBS(AotInlineTrace)
|
||||
JSFunction *inlineJSFunc = JSFunction::Cast(inlineFunc);
|
||||
Method *callerMethod = Method::Cast(JSFunction::Cast(callerJSFunc)->GetMethod());
|
||||
Method *inlineMethod = Method::Cast(JSFunction::Cast(inlineJSFunc)->GetMethod());
|
||||
auto callerRecordName = callerMethod->GetRecordName();
|
||||
auto inlineRecordNanme = inlineMethod->GetRecordName();
|
||||
auto callerRecordName = callerMethod->GetRecordNameStr();
|
||||
auto inlineRecordNanme = inlineMethod->GetRecordNameStr();
|
||||
const std::string callerFuncName(callerMethod->GetMethodName());
|
||||
const std::string inlineFuncNanme(inlineMethod->GetMethodName());
|
||||
std::string callerFullName = callerFuncName + "@" + std::string(callerRecordName);
|
||||
|
@ -434,9 +434,9 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump)
|
||||
}
|
||||
case JSType::METHOD: {
|
||||
#ifdef PANDA_TARGET_64
|
||||
CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 7U);
|
||||
CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 8U);
|
||||
#else
|
||||
CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 6U);
|
||||
CHECK_DUMP_FIELDS(TaggedObject::TaggedObjectSize(), Method::SIZE, 7U);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
@ -445,7 +445,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump)
|
||||
break;
|
||||
}
|
||||
case JSType::JS_FUNCTION: {
|
||||
CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSFunction::SIZE, 4U);
|
||||
CHECK_DUMP_FIELDS(JSFunctionBase::SIZE, JSFunction::SIZE, 3U);
|
||||
JSHandle<JSTaggedValue> jsFunc = globalEnv->GetFunctionFunction();
|
||||
DUMP_FOR_HANDLE(jsFunc)
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user