!7126 [JIT] 修复 jit pgo时的一些deopt问题

Merge pull request !7126 from zhouyong/deopt_issues
This commit is contained in:
openharmony_ci 2024-05-13 02:10:07 +00:00 committed by Gitee
commit e729610d81
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 17 additions and 32 deletions

View File

@ -136,7 +136,7 @@ void PGOTypeManager::GenHClassInfo()
ObjectFactory* factory = thread_->GetEcmaVM()->GetFactory();
JSHandle<TaggedArray> hclassInfo = factory->NewTaggedArray(count);
uint32_t pos = 0;
profileTyperToHClassIndex_.clear();
for (auto& root: hcData_) {
ProfileType rootType = root.first;
for (auto& child: root.second) {
@ -151,27 +151,6 @@ void PGOTypeManager::GenHClassInfo()
aotSnapshot_.StoreHClassInfo(hclassInfo);
}
void PGOTypeManager::GenJITHClassInfoLocal()
{
LockHolder lock(mutex_);
profileTyperToHClassIndex_.clear();
hclassInfoLocal_.clear();
uint32_t count = 0;
for (auto &data : hcData_) {
count += data.second.size();
}
uint32_t pos = 0;
for (auto &x : hcData_) {
ProfileType rootType = x.first;
for (auto &y : x.second) {
ProfileType childType = y.first;
JSTaggedType hclass = y.second;
ProfileTyper key = std::make_pair(rootType, childType);
profileTyperToHClassIndex_.emplace(key, pos++);
hclassInfoLocal_.emplace_back(JSTaggedValue(hclass));
}
}
}
JSHandle<TaggedArray> PGOTypeManager::GenJITHClassInfo()
{
@ -214,6 +193,8 @@ void PGOTypeManager::RecordHClass(ProfileType rootType, ProfileType childType, J
auto map = TransIdToHClass();
map.emplace(childType, hclass);
hcData_.emplace(rootType, map);
profileTyperToHClassIndex_.emplace(std::make_pair(rootType, childType), pos_++);
hclassInfoLocal_.emplace_back(JSTaggedValue(hclass));
return;
}
@ -225,9 +206,14 @@ void PGOTypeManager::RecordHClass(ProfileType rootType, ProfileType childType, J
return;
} else {
hclassMap[childType]= hclass;
auto index = GetHClassIndexByProfileType(std::pair(rootType, childType));
ASSERT(index >= 0);
hclassInfoLocal_[index] = JSTaggedValue(hclass);
return;
}
}
profileTyperToHClassIndex_.emplace(std::make_pair(rootType, childType), pos_++);
hclassInfoLocal_.emplace_back(JSTaggedValue(hclass));
hclassMap.emplace(childType, hclass);
}

View File

@ -110,7 +110,6 @@ public:
}
JSHandle<TaggedArray> GenJITHClassInfo();
void GenJITHClassInfoLocal();
// symbol
std::optional<uint64_t> PUBLIC_API GetSymbolIdByProfileType(ProfileTypeTuple type) const;
@ -166,6 +165,7 @@ private:
// so that subsequent passes (type_infer, ts_hcr_lowering) can obtain the correct constpool.
JSTaggedValue curCP_ {JSTaggedValue::Hole()};
int32_t curCPID_ {0};
int32_t pos_ {0};
};
} // panda::ecmascript::kungfu
#endif // ECMASCRIPT_COMPILER_PGO_TYPE_PGO_TYPE_MANAGER_H

View File

@ -254,7 +254,6 @@ void JITProfiler::ProfileBytecode(JSHandle<ProfileTypeInfo> &profileTypeInfo, En
}
bcIns = bcIns.GetNext();
}
ptManager_->GenJITHClassInfoLocal();
}
// PGOSampleType
@ -693,9 +692,10 @@ JSTaggedValue JITProfiler::TryFindKeyInPrototypeChain(TaggedObject *currObj, JSH
return JSTaggedValue::Undefined();
}
void JITProfiler::InsertProfileType(JSTaggedType root, JSTaggedType child, ProfileType rootType, ProfileType childType)
void JITProfiler::InsertProfileType(JSTaggedType root, JSTaggedType child, ProfileType rootType, ProfileType childType,
bool update)
{
ptManager_->RecordHClass(rootType, childType, child, true);
ptManager_->RecordHClass(rootType, childType, child, update);
LockHolder lock(mutex_);
auto iter = tracedProfiles_.find(root);
if (iter != tracedProfiles_.end()) {
@ -755,15 +755,13 @@ void JITProfiler::UpdateRootProfileType(JSHClass *oldHClass, JSHClass *newHClass
}
auto generator = iter->second;
auto rootProfileType = generator->GetProfileType(JSTaggedType(oldRootHClass));
if (rootProfileType.IsNone()) {
{
vm_->GetNativeAreaAllocator()->Delete(iter->second);
tracedProfiles_.erase(iter);
return;
}
tracedProfiles_.erase(iter);
InsertProfileType(JSTaggedType(newHClass), JSTaggedType(newHClass), rootProfileType, rootProfileType);
InsertProfileType(JSTaggedType(newHClass), JSTaggedType(newHClass), rootProfileType, rootProfileType, true);
}
void JITProfiler::AddObjectInfoWithMega(int32_t bcOffset)
{
auto megaType = ProfileType::CreateMegeType();

View File

@ -61,7 +61,8 @@ public:
{
return bcOffsetPGODefOpTypeMap_;
}
void InsertProfileType(JSTaggedType root, JSTaggedType child, ProfileType rootType, ProfileType childType);
void InsertProfileType(JSTaggedType root, JSTaggedType child, ProfileType rootType, ProfileType childType,
bool update = false);
void InitJITProfiler()
{
ptManager_ = vm_->GetJSThread()->GetCurrentEcmaContext()->GetPTManager();