Reason:1.fix cocos deopt bug 2.enable class static high ir

Description:Reason:1.fix cocos deopt bug 2.enable class static high ir
Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I7MR80?from=project-issue

Signed-off-by: wupengyong <wupengyong@huawei.com>
Change-Id: I3e17e0df38d623ed705d380fc99fdfd7f42ad0e7
This commit is contained in:
wupengyong 2023-07-22 14:58:49 +08:00
parent 047df4b829
commit 7cd0e3dd23
19 changed files with 129 additions and 175 deletions

View File

@ -160,7 +160,6 @@ int Main(const int argc, const char **argv)
bool isEnableLaterElimination = runtimeOptions.IsEnableLaterElimination();
bool isEnableValueNumbering = runtimeOptions.IsEnableValueNumbering();
bool isEnableOptInlining = runtimeOptions.IsEnableOptInlining();
bool isEnableOptStaticMethod = runtimeOptions.IsEnableOptStaticMethod();
bool isEnableTypeInfer = isEnableTypeLowering ||
vm->GetJSThread()->GetCurrentEcmaContext()->GetTSManager()->AssertTypes();
bool isEnableOptPGOType = runtimeOptions.IsEnableOptPGOType();
@ -169,8 +168,7 @@ int Main(const int argc, const char **argv)
PassOptions passOptions(isEnableTypeLowering, isEnableEarlyElimination, isEnableLaterElimination,
isEnableValueNumbering, isEnableTypeInfer, isEnableOptInlining,
isEnableOptStaticMethod, isEnableOptPGOType,
isEnableOptTrackField, isEnableOptLoopPeeling);
isEnableOptPGOType, isEnableOptTrackField, isEnableOptLoopPeeling);
uint32_t hotnessThreshold = runtimeOptions.GetPGOHotnessThreshold();
AOTInitialize(vm);

View File

@ -68,9 +68,6 @@ bool ObjectAccessHelper::ComputeForClassOrObject(ObjectAccessInfo &info)
GateType type = info.Type();
int hclassIndex = -1;
if (tsManager_->IsClassTypeKind(type)) {
if (!enableOptStaticMethod_) {
return false;
}
hclassIndex = tsManager_->GetConstructorHClassIndexByClassGateType(type);
} else if (tsManager_->IsObjectTypeKind(type)) {
hclassIndex = tsManager_->GetHClassIndexByObjectType(type);

View File

@ -64,15 +64,14 @@ public:
};
explicit ObjectAccessHelper(TSManager *tsManager, AccessMode mode, GateRef receiver, GateType type,
JSTaggedValue key, GateRef value, bool enableOptStaticMethod)
JSTaggedValue key, GateRef value)
: tsManager_(tsManager),
thread_(tsManager_->GetThread()),
mode_(mode),
receiver_(receiver),
type_(type),
key_(key),
value_(value),
enableOptStaticMethod_(enableOptStaticMethod) {}
value_(value) {}
~ObjectAccessHelper() = default;
@ -110,7 +109,6 @@ private:
GateType type_ {GateType::AnyType()};
JSTaggedValue key_ {JSTaggedValue::Hole()};
GateRef value_ {Circuit::NullGate()};
bool enableOptStaticMethod_ {false};
};
} // panda::ecmascript::kungfu
#endif // ECMASCRIPT_COMPILER_OBJECT_ACCESS_HELPER_H

View File

@ -291,7 +291,7 @@ public:
bool enableLog = data->GetLog()->EnableMethodCIRLog();
bool enableTypeLog = data->GetLog()->GetEnableMethodLog() && data->GetLog()->OutputType();
TSHCRLowering lowering(data->GetCircuit(), data->GetPassContext(),
enableLog, enableTypeLog, passOptions->EnableOptStaticMethod(), data->GetMethodName());
enableLog, enableTypeLog, data->GetMethodName());
bool success = lowering.RunTSHCRLowering();
if (!success) {
data->MarkAsTypeAbort();
@ -388,12 +388,10 @@ class SlowPathLoweringPass {
public:
bool Run(PassData* data)
{
PassOptions *passOptions = data->GetPassOptions();
TimeScope timescope("SlowPathLoweringPass", data->GetMethodName(), data->GetMethodOffset(), data->GetLog());
bool enableLog = data->GetLog()->EnableMethodCIRLog();
SlowPathLowering lowering(data->GetCircuit(), data->GetCompilerConfig(), data->GetTSManager(),
data->GetMethodLiteral(), enableLog,
passOptions->EnableOptStaticMethod(), data->GetMethodName());
data->GetMethodLiteral(), enableLog, data->GetMethodName());
lowering.CallRuntimeLowering();
return true;
}

View File

@ -156,8 +156,7 @@ void PassManager::ProcessConstantPool(BytecodeInfoCollector *collector)
{
LOG_COMPILER(INFO) << collector->GetBytecodeInfo().GetSkippedMethodSize()
<< " methods have been skipped";
vm_->GetJSThread()->GetCurrentEcmaContext()->GetTSManager()->ProcessSnapshotConstantPool(collector,
passOptions_->EnableOptStaticMethod());
vm_->GetJSThread()->GetCurrentEcmaContext()->GetTSManager()->ProcessSnapshotConstantPool(collector);
}
bool PassManager::IsReleasedPandaFile(const JSPandaFile *jsPandaFile) const

View File

@ -128,14 +128,13 @@ class PassOptions {
public:
PassOptions(bool enableTypeLowering, bool enableEarlyElimination, bool enableLaterElimination,
bool enableValueNumbering, bool enableTypeInfer, bool enableOptInlining,
bool enableOptStaticMethod, bool enableOptPGOType, bool enableOptTrackField, bool enableOptLoopPeeling)
bool enableOptPGOType, bool enableOptTrackField, bool enableOptLoopPeeling)
: enableTypeLowering_(enableTypeLowering),
enableEarlyElimination_(enableEarlyElimination),
enableLaterElimination_(enableLaterElimination),
enableValueNumbering_(enableValueNumbering),
enableTypeInfer_(enableTypeInfer),
enableOptInlining_(enableOptInlining),
enableOptStaticMethod_(enableOptStaticMethod),
enableOptPGOType_(enableOptPGOType),
enableOptTrackField_(enableOptTrackField),
enableOptLoopPeeling_(enableOptLoopPeeling)
@ -149,7 +148,6 @@ public:
V(ValueNumbering, false) \
V(TypeInfer, false) \
V(OptInlining, false) \
V(OptStaticMethod, false) \
V(OptNoGCCall, false) \
V(OptPGOType, false) \
V(NoCheck, false) \

View File

@ -112,12 +112,11 @@ class SlowPathLowering {
public:
SlowPathLowering(Circuit *circuit, CompilationConfig *cmpCfg,
TSManager *tsManager, const MethodLiteral *methodLiteral,
bool enableLog, bool enableOptStaticMethod, const std::string& name)
bool enableLog, const std::string& name)
: tsManager_(tsManager), methodLiteral_(methodLiteral),
circuit_(circuit), acc_(circuit),
argAcc_(circuit), builder_(circuit, cmpCfg),
enableLog_(enableLog), enableOptStaticMethod_(enableOptStaticMethod),
methodName_(name), glue_(acc_.GetGlueFromArgList())
enableLog_(enableLog), methodName_(name), glue_(acc_.GetGlueFromArgList())
{
traceBc_ = cmpCfg->IsTraceBC();
profiling_ = cmpCfg->IsProfiling();
@ -131,11 +130,6 @@ public:
return enableLog_;
}
bool EnableOptStaticMethod() const
{
return enableOptStaticMethod_;
}
bool IsTraceBC() const
{
return traceBc_;
@ -319,7 +313,6 @@ private:
ArgumentAccessor argAcc_;
CircuitBuilder builder_;
bool enableLog_ {false};
bool enableOptStaticMethod_ {false};
bool traceBc_ {false};
bool profiling_ {false};
bool stressDeopt_ {false};

View File

@ -590,7 +590,7 @@ void TSHCRLowering::LowerNamedAccess(GateRef gate, GateRef receiver, AccessMode
return;
}
ObjectAccessHelper accessHelper(tsManager_, accessMode, receiver, receiverType, key, value, enableOptStaticMethod_);
ObjectAccessHelper accessHelper(tsManager_, accessMode, receiver, receiverType, key, value);
ChunkVector<ObjectAccessInfo> infos(circuit_->chunk());
bool continuation = accessHelper.Compute(infos);
if (!continuation) {

View File

@ -28,7 +28,7 @@ class TSHCRLowering {
public:
TSHCRLowering(Circuit *circuit, PassContext *ctx,
bool enableLog, bool enableTypeLog,
bool enableOptStaticMethod, const std::string& name)
const std::string& name)
: circuit_(circuit),
acc_(circuit),
builder_(circuit, ctx->GetCompilerConfig()),
@ -36,7 +36,6 @@ public:
tsManager_(ctx->GetTSManager()),
enableLog_(enableLog),
enableTypeLog_(enableTypeLog),
enableOptStaticMethod_(enableOptStaticMethod),
profiling_(ctx->GetCompilerConfig()->IsProfiling()),
verifyVTable_(ctx->GetCompilerConfig()->IsVerifyVTbale()),
traceBc_(ctx->GetCompilerConfig()->IsTraceBC()),
@ -62,11 +61,6 @@ private:
return enableTypeLog_;
}
bool EnableOptStaticMethod() const
{
return enableOptStaticMethod_;
}
bool IsProfiling() const
{
return profiling_;
@ -190,7 +184,6 @@ private:
TSManager *tsManager_ {nullptr};
bool enableLog_ {false};
bool enableTypeLog_ {false};
bool enableOptStaticMethod_ {false};
bool profiling_ {false};
bool verifyVTable_ {false};
bool traceBc_ {false};

View File

@ -75,6 +75,12 @@ public:
firstFrame_ = top_;
}
void ReviseValueByIndex(JSTaggedType value, size_t index)
{
ASSERT(index < static_cast<size_t>(start_ - top_));
*(top_ + index) = value;
}
private:
JSThread *thread_ {nullptr};
JSTaggedType *start_ {nullptr};
@ -379,6 +385,29 @@ bool Deoptimizier::CollectVirtualRegisters(Method* method, FrameWriter *frameWri
frameWriter->PushValue(value.GetRawData());
virtualIndex--;
}
// revise correct a0 - aN virtual regs , for example: ldobjbyname key; sta a2; update value to a2
// +--------------------------+ ^
// | aN | |
// +--------------------------+ |
// | ... | |
// +--------------------------+ |
// | a2(this) | |
// +--------------------------+ revise correct vreg
// | a1(newtarget) | |
// +--------------------------+ |
// | a0(func) | |
// |--------------------------| v
// | v0 - vN |
// sp --> |--------------------------|
int32_t vregsAndArgsNum = declaredNumArgs + callFieldNumVregs +
static_cast<int32_t>(method->GetNumRevervedArgs());
for (int32_t i = callFieldNumVregs; i < vregsAndArgsNum; i++) {
JSTaggedValue value = JSTaggedValue::Undefined();
if (HasDeoptValue(curDepth, i)) {
value = GetDeoptValue(curDepth, i);
frameWriter->ReviseValueByIndex(value.GetRawData(), i);
}
}
return true;
}

View File

@ -81,7 +81,6 @@ const std::string PUBLIC_API HELP_OPTION_MSG =
"--compiler-opt-later-elimination: Enable LaterElimination for aot compiler. Default: 'true'\n"
"--compiler-opt-value-numbering: Enable ValueNumbering for aot compiler. Default: 'true'\n"
"--compiler-opt-inlining: Enable inlining function for aot compiler: Default: 'true'\n"
"--compiler-opt-static-method: Enable static method optimize for aot compiler: Default: 'false'\n"
"--compiler-opt-pgotype: Enable pgo type for aot compiler: Default: 'true'\n"
"--compiler-opt-track-field: Enable track field for aot compiler: Default: 'false'\n"
"--entry-point: Full name of entrypoint function. Default: '_GLOBAL::func_main_0'\n"
@ -179,7 +178,6 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv)
{"compiler-opt-later-elimination", required_argument, nullptr, OPTION_COMPILER_OPT_LATER_ELIMINATION},
{"compiler-opt-value-numbering", required_argument, nullptr, OPTION_COMPILER_OPT_VALUE_NUMBERING},
{"compiler-opt-inlining", required_argument, nullptr, OPTION_COMPILER_OPT_INLINING},
{"compiler-opt-static-method", required_argument, nullptr, OPTION_COMPILER_OPT_STATIC_METHOD},
{"compiler-opt-pgotype", required_argument, nullptr, OPTION_COMPILER_OPT_PGOTYPE},
{"compiler-opt-track-field", required_argument, nullptr, OPTION_COMPILER_OPT_TRACK_FIELD},
{"entry-point", required_argument, nullptr, OPTION_ENTRY_POINT},
@ -650,14 +648,6 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv)
return false;
}
break;
case OPTION_COMPILER_OPT_STATIC_METHOD:
ret = ParseBoolParam(&argBool);
if (ret) {
SetEnableOptStaticMethod(argBool);
} else {
return false;
}
break;
case OPTION_COMPILER_OPT_PGOTYPE:
ret = ParseBoolParam(&argBool);
if (ret) {

View File

@ -118,7 +118,6 @@ enum CommandValues {
OPTION_COMPILER_OPT_LATER_ELIMINATION,
OPTION_COMPILER_OPT_VALUE_NUMBERING,
OPTION_COMPILER_OPT_INLINING,
OPTION_COMPILER_OPT_STATIC_METHOD,
OPTION_COMPILER_OPT_PGOTYPE,
OPTION_COMPILER_OPT_TRACK_FIELD,
OPTION_COMPILER_OPT_GLOBAL_TYPEINFER,
@ -946,16 +945,6 @@ public:
return enableOptInlining_;
}
void SetEnableOptStaticMethod(bool value)
{
enableOptStaticMethod_ = value;
}
bool IsEnableOptStaticMethod() const
{
return enableOptStaticMethod_;
}
void SetEnableOptPGOType(bool value)
{
enableOptPGOType_ = value;
@ -1247,7 +1236,6 @@ private:
bool enableLaterElimination_ {true};
bool enableValueNumbering_ {true};
bool enableOptInlining_ {true};
bool enableOptStaticMethod_ {false};
bool enableOptPGOType_ {true};
bool enableGlobalTypeInfer_ {false};
bool enableOptTrackField_ {true};

View File

@ -415,93 +415,21 @@ JSHandle<JSFunction> ClassHelper::DefineClassFromExtractor(JSThread *thread, con
}
JSHandle<JSFunction> ClassHelper::DefineClassWithIHClass(JSThread *thread,
const JSHandle<JSTaggedValue> &base,
JSHandle<ClassInfoExtractor> &extractor,
const JSHandle<JSTaggedValue> &lexenv,
const JSHandle<JSHClass> &ihclass)
const JSHandle<JSHClass> &ihclass,
const JSHandle<JSHClass> &constructorHClass)
{
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
JSHandle<TaggedArray> staticKeys(thread, extractor->GetStaticKeys());
JSHandle<TaggedArray> staticProperties(thread, extractor->GetStaticProperties());
JSHandle<Method> method(thread, Method::Cast(extractor->GetConstructorMethod().GetTaggedObject()));
JSHandle<JSHClass> constructorHClass =
ClassInfoExtractor::CreateConstructorHClass(thread, base, staticKeys, staticProperties, method);
JSHandle<JSFunction> constructor =
ClassHelper::DefineClassWithConstructorHClass(thread, extractor, lexenv, ihclass, constructorHClass, method);
uint32_t staticLength = staticProperties->GetLength();
JSMutableHandle<JSTaggedValue> propValue(thread, JSTaggedValue::Undefined());
if (LIKELY(!constructorHClass->IsDictionaryMode())) {
for (uint32_t index = 0; index < staticLength; ++index) {
propValue.Update(staticProperties->Get(index));
if (propValue->IsJSFunction()) {
JSHandle<JSFunction> propFunc = factory->CloneJSFuction(JSHandle<JSFunction>::Cast(propValue));
propFunc->SetHomeObject(thread, constructor);
propFunc->SetLexicalEnv(thread, lexenv);
propValue.Update(propFunc);
}
JSHandle<JSObject>::Cast(constructor)->SetPropertyInlinedProps(thread, index, propValue.GetTaggedValue());
}
} else {
JSHandle<NameDictionary> dict = BuildDictionaryProperties(thread, JSHandle<JSObject>(constructor), staticKeys,
staticProperties, ClassPropertyType::STATIC, lexenv);
constructor->SetProperties(thread, dict);
}
return constructor;
}
JSHandle<JSFunction> ClassHelper::DefineClassWithIHClassAndConstructorHClass(JSThread *thread,
JSHandle<ClassInfoExtractor> &extractor, const JSHandle<JSTaggedValue> &lexenv,
const JSHandle<JSHClass> &ihclass, const JSHandle<JSHClass> &constructorHClass)
{
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
JSHandle<TaggedArray> staticKeys(thread, extractor->GetStaticKeys());
JSHandle<TaggedArray> staticProperties(thread, extractor->GetStaticProperties());
JSHandle<Method> method(thread, Method::Cast(extractor->GetConstructorMethod().GetTaggedObject()));
ClassInfoExtractor::CorrectConstructorHClass(thread, staticProperties, *constructorHClass);
JSHandle<JSFunction> constructor =
ClassHelper::DefineClassWithConstructorHClass(thread, extractor, lexenv, ihclass, constructorHClass, method);
// static
uint32_t staticLength = staticProperties->GetLength();
JSMutableHandle<JSTaggedValue> propValue(thread, JSTaggedValue::Undefined());
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
int correntIndex = 0;
if (LIKELY(!constructorHClass->IsDictionaryMode())) {
for (uint32_t index = 0; index < staticLength; ++index) {
propValue.Update(staticProperties->Get(index));
if (propValue->IsJSFunction()) {
JSHandle<JSFunction> propFunc = factory->CloneJSFuction(JSHandle<JSFunction>::Cast(propValue));
propFunc->SetHomeObject(thread, constructor);
propFunc->SetLexicalEnv(thread, lexenv);
propValue.Update(propFunc);
}
bool needCorrentIndex = index >= ClassInfoExtractor::STATIC_RESERVED_LENGTH;
if (needCorrentIndex) {
key.Update(staticKeys->Get(index));
correntIndex = JSHClass::FindPropertyEntry(thread, *constructorHClass, key.GetTaggedValue());
}
JSHandle<JSObject>::Cast(constructor)->SetPropertyInlinedProps(thread,
needCorrentIndex ? static_cast<uint32_t>(correntIndex) : index, propValue.GetTaggedValue());
}
} else {
JSHandle<NameDictionary> dict = BuildDictionaryProperties(thread, JSHandle<JSObject>(constructor), staticKeys,
staticProperties, ClassPropertyType::STATIC, lexenv);
constructor->SetProperties(thread, dict);
}
return constructor;
}
JSHandle<JSFunction> ClassHelper::DefineClassWithConstructorHClass(JSThread *thread,
JSHandle<ClassInfoExtractor> &extractor, const JSHandle<JSTaggedValue> &lexenv,
const JSHandle<JSHClass> &ihclass, const JSHandle<JSHClass> &constructorHClass,
const JSHandle<Method> &method)
{
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
ClassInfoExtractor::CorrectConstructorHClass(thread,
staticProperties, *constructorHClass);
JSHandle<TaggedArray> nonStaticKeys(thread, extractor->GetNonStaticKeys());
JSHandle<TaggedArray> nonStaticProperties(thread, extractor->GetNonStaticProperties());
JSHandle<JSObject> prototype(thread, ihclass->GetProto());
JSHandle<Method> method(thread, Method::Cast(extractor->GetConstructorMethod().GetTaggedObject()));
constructorHClass->SetIsOptimized(method->IsAotWithCallField());
constructorHClass->SetCanFastCall(method->IsFastCall());
JSHandle<JSFunction> constructor = factory->NewJSFunctionByHClass(method, constructorHClass,
@ -525,8 +453,7 @@ JSHandle<JSFunction> ClassHelper::DefineClassWithConstructorHClass(JSThread *thr
prototype->SetPropertyInlinedProps(thread, index, propValue.GetTaggedValue());
}
} else {
JSHandle<NameDictionary> dict = BuildDictionaryProperties(thread, prototype, nonStaticKeys,
nonStaticProperties,
JSHandle<NameDictionary> dict = BuildDictionaryProperties(thread, prototype, nonStaticKeys, nonStaticProperties,
ClassPropertyType::NON_STATIC, lexenv);
prototype->SetProperties(thread, dict);
}
@ -537,6 +464,33 @@ JSHandle<JSFunction> ClassHelper::DefineClassWithConstructorHClass(JSThread *thr
ClassHelper::HandleElementsProperties(thread, prototype, nonStaticElements);
}
// static
uint32_t staticLength = staticProperties->GetLength();
JSMutableHandle<JSTaggedValue> key(thread, JSTaggedValue::Undefined());
int correntIndex = 0;
if (LIKELY(!constructorHClass->IsDictionaryMode())) {
for (uint32_t index = 0; index < staticLength; ++index) {
propValue.Update(staticProperties->Get(index));
if (propValue->IsJSFunction()) {
JSHandle<JSFunction> propFunc = factory->CloneJSFuction(JSHandle<JSFunction>::Cast(propValue));
propFunc->SetHomeObject(thread, constructor);
propFunc->SetLexicalEnv(thread, lexenv);
propValue.Update(propFunc);
}
bool needCorrentIndex = index >= ClassInfoExtractor::STATIC_RESERVED_LENGTH;
if (needCorrentIndex) {
key.Update(staticKeys->Get(index));
correntIndex = JSHClass::FindPropertyEntry(thread, *constructorHClass, key.GetTaggedValue());
}
JSHandle<JSObject>::Cast(constructor)->SetPropertyInlinedProps(thread,
needCorrentIndex ? static_cast<uint32_t>(correntIndex) : index, propValue.GetTaggedValue());
}
} else {
JSHandle<NameDictionary> dict = BuildDictionaryProperties(thread, JSHandle<JSObject>(constructor), staticKeys,
staticProperties, ClassPropertyType::STATIC, lexenv);
constructor->SetProperties(thread, dict);
}
// static elements
if (UNLIKELY(extractor->GetStaticWithElements())) {
JSHandle<TaggedArray> staticElements(thread, extractor->GetStaticElements());

View File

@ -98,19 +98,10 @@ public:
const JSHandle<JSTaggedValue> &lexenv);
static JSHandle<JSFunction> DefineClassWithIHClass(JSThread *thread,
const JSHandle<JSTaggedValue> &base,
JSHandle<ClassInfoExtractor> &extractor,
const JSHandle<JSTaggedValue> &lexenv,
const JSHandle<JSHClass> &ihclass);
static JSHandle<JSFunction> DefineClassWithIHClassAndConstructorHClass(JSThread *thread,
JSHandle<ClassInfoExtractor> &extractor, const JSHandle<JSTaggedValue> &lexenv,
const JSHandle<JSHClass> &ihclass, const JSHandle<JSHClass> &constructorHClass);
static JSHandle<JSFunction> DefineClassWithConstructorHClass(JSThread *thread,
JSHandle<ClassInfoExtractor> &extractor, const JSHandle<JSTaggedValue> &lexenv,
const JSHandle<JSHClass> &ihclass, const JSHandle<JSHClass> &constructorHClass,
const JSHandle<Method> &method);
const JSHandle<JSHClass> &ihclass,
const JSHandle<JSHClass> &constructorHClass);
private:
static JSHandle<NameDictionary> BuildDictionaryProperties(JSThread *thread, const JSHandle<JSObject> &object,

View File

@ -838,17 +838,11 @@ JSTaggedValue RuntimeStubs::RuntimeCreateClassWithBuffer(JSThread *thread,
cls = ClassHelper::DefineClassFromExtractor(thread, base, extractor, lexenv);
} else {
classLiteral->SetIsAOTUsed(true);
if (chc->IsUndefined()) {
JSHandle<JSHClass> ihclass(ihc);
cls = ClassHelper::DefineClassWithIHClass(thread, base, extractor,
lexenv, ihclass);
} else {
JSHandle<JSHClass> ihclass(ihc);
JSHandle<JSHClass> chclass(chc);
cls = ClassHelper::DefineClassWithIHClassAndConstructorHClass(thread, extractor,
cls = ClassHelper::DefineClassWithIHClass(thread, extractor,
lexenv, ihclass, chclass);
}
}
RuntimeSetClassInheritanceRelationship(thread, JSHandle<JSTaggedValue>(cls), base);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);

View File

@ -1133,14 +1133,14 @@ JSHandle<ConstantPool> TSManager::GetSnapshotConstantPool(uint32_t cpListIndex)
return JSHandle<ConstantPool>(thread_, snapshotCPList->Get(cpListIndex));
}
void TSManager::ProcessSnapshotConstantPool(kungfu::BytecodeInfoCollector *bcInfoCollector, bool optStaticMethods)
void TSManager::ProcessSnapshotConstantPool(kungfu::BytecodeInfoCollector *bcInfoCollector)
{
const CMap<int32_t, JSTaggedValue> &oldCPValues = vm_->GetJSThread()->GetCurrentEcmaContext()->FindConstpools(
bcInfoCollector->GetJSPandaFile()).value();
std::map<int32_t, uint32_t> cpListIndexMap;
GenerateSnapshotConstantPoolList(cpListIndexMap, oldCPValues);
FillSnapshotConstantPoolList(cpListIndexMap, bcInfoCollector, optStaticMethods);
FillSnapshotConstantPoolList(cpListIndexMap, bcInfoCollector);
AddHClassToSnapshotConstantPoolList(cpListIndexMap, bcInfoCollector);
}
@ -1173,8 +1173,7 @@ void TSManager::GenerateSnapshotConstantPoolList(std::map<int32_t, uint32_t> &cp
}
}
void TSManager::TryGetIhcAndChc(GlobalTSTypeRef gt, JSHandle<JSTaggedValue> &ihc, JSHandle<JSTaggedValue> &chc,
bool optStaticMethods)
void TSManager::TryGetIhcAndChc(GlobalTSTypeRef gt, JSHandle<JSTaggedValue> &ihc, JSHandle<JSTaggedValue> &chc)
{
if (gt.IsDefault()) {
return;
@ -1185,15 +1184,14 @@ void TSManager::TryGetIhcAndChc(GlobalTSTypeRef gt, JSHandle<JSTaggedValue> &ihc
ihc = JSHandle<JSTaggedValue>(thread_, JSTaggedValue(ihcData.GetIHC()));
}
auto chcIt = gtConstructorhcMap_.find(gt);
if (chcIt != gtConstructorhcMap_.end() && optStaticMethods) {
if (chcIt != gtConstructorhcMap_.end()) {
IHClassData chcData = chcIt->second;
chc = JSHandle<JSTaggedValue>(thread_, JSTaggedValue(chcData.GetIHC()));
}
}
void TSManager::FillSnapshotConstantPoolList(const std::map<int32_t, uint32_t> &cpListIndexMap,
kungfu::BytecodeInfoCollector *bcInfoCollector,
bool optStaticMethods)
kungfu::BytecodeInfoCollector *bcInfoCollector)
{
const JSPandaFile *jsPandaFile = bcInfoCollector->GetJSPandaFile();
@ -1227,7 +1225,7 @@ void TSManager::FillSnapshotConstantPoolList(const std::map<int32_t, uint32_t> &
});
bcInfoCollector->IterateConstantPoolInfo(kungfu::ConstantPoolInfo::ItemType::CLASS_LITERAL,
[this, jsPandaFile, &cpListIndexMap, bcInfoCollector, optStaticMethods]
[this, jsPandaFile, &cpListIndexMap, bcInfoCollector]
(const kungfu::ConstantPoolInfo::ItemData &data) {
int32_t oldCPID = GetOldConstantPoolIDByMethodOffset(jsPandaFile, data.outerMethodOffset);
JSHandle<ConstantPool> oldCP(thread_,
@ -1243,7 +1241,7 @@ void TSManager::FillSnapshotConstantPoolList(const std::map<int32_t, uint32_t> &
JSHandle<JSTaggedValue> chc = thread_->GlobalConstants()->GetHandledUndefined();
TypeLocation loc(jsPandaFile, data.outerMethodOffset, data.bcIndex);
GlobalTSTypeRef gt = GetLiteralGT(loc);
TryGetIhcAndChc(gt, ihc, chc, optStaticMethods);
TryGetIhcAndChc(gt, ihc, chc);
CollectLiteralInfo(arrayHandle, data.index, newCP, bcInfoCollector, ihc, chc);
snapshotData_.AddIndexInfoToRecordInfo(SnapshotData::RecordType::LITERAL,
std::make_pair(cpListIndex, data.index));

View File

@ -688,8 +688,7 @@ public:
return snapshotData_.GetSnapshotCPList();
}
void PUBLIC_API ProcessSnapshotConstantPool(kungfu::BytecodeInfoCollector *bcInfoCollector,
bool optStaticMethods);
void PUBLIC_API ProcessSnapshotConstantPool(kungfu::BytecodeInfoCollector *bcInfoCollector);
void PUBLIC_API ResolveSnapshotConstantPool(const std::map<uint32_t, uint32_t> &methodToEntryIndexMap);
@ -851,12 +850,10 @@ private:
void GenerateSnapshotConstantPoolList(std::map<int32_t, uint32_t> &cpListIndexMap,
const CMap<int32_t, JSTaggedValue> &oldCPValues);
void TryGetIhcAndChc(GlobalTSTypeRef gt, JSHandle<JSTaggedValue> &ihc, JSHandle<JSTaggedValue> &chc,
bool optStaticMethods = false);
void TryGetIhcAndChc(GlobalTSTypeRef gt, JSHandle<JSTaggedValue> &ihc, JSHandle<JSTaggedValue> &chc);
void FillSnapshotConstantPoolList(const std::map<int32_t, uint32_t> &cpListIndexMap,
kungfu::BytecodeInfoCollector *bcInfoCollector,
bool optStaticMethods);
kungfu::BytecodeInfoCollector *bcInfoCollector);
void AddHClassToSnapshotConstantPoolList(const std::map<int32_t, uint32_t> &cpListIndexMap,
kungfu::BytecodeInfoCollector *bcInfoCollector);

View File

@ -287,3 +287,40 @@ function renderScene(){
renderScene();
let sh = new Shape();
sh.func1(1, 2);
class Node{
public map : string;
public nodeType : number;
public parentNode : Node;
public childNode : Node;
constructor(radius: number) {
this.map = "hh";
this.nodeType = 1;
this.parentNode = null;
this.childNode = null;
}
public lookup(names: string) : void {
var el = this;
while (el) {
var map = el.map;
if (map == names) {
print(map)
}
el = el.nodeType == 1 ? el.childNode : el.parentNode;
const tmp = Node.Constant;
print(el);
}
}
static Constant = 1;
static Curve = 2;
static TwoC = 3;
}
Object.defineProperty(Node, "property1", {
value: 32,
writable: false
});
let obj = new Node();
obj.lookup("hh");

View File

@ -26,3 +26,5 @@ func1
intersect
func1
2
hh
null