mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-06 23:54:03 +00:00
ConstPool GC Bugfix
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IABRZ5 Signed-off-by: wu_zhang_da <wuzhangda@huawei.com> Change-Id: I732c8cb6daf41ebd9a6a7f4d8f1039a501c7b121
This commit is contained in:
parent
ace52a525f
commit
17352456c1
@ -520,14 +520,15 @@ void AOTFileManager::ParseDeserializedData(const CString &snapshotFileName, JSTa
|
||||
JSTaggedValue cp = cpList->Get(AOTSnapshotConstants::SNAPSHOT_CP_ARRAY_ITEM_SIZE - 1); // first constpool
|
||||
context->LoadProtoTransitionTable(cp);
|
||||
}
|
||||
JSMutableHandle<ConstantPool> cpHandle(thread, JSTaggedValue::Undefined());
|
||||
for (uint32_t pos = 0; pos < cpLen; pos += AOTSnapshotConstants::SNAPSHOT_CP_ARRAY_ITEM_SIZE) {
|
||||
int32_t constantPoolID = cpList->Get(pos).GetInt();
|
||||
JSTaggedValue cp = cpList->Get(pos + 1);
|
||||
context->ResetProtoTransitionTableOnConstpool(cp);
|
||||
cpMap.insert({constantPoolID, cp});
|
||||
cpHandle.Update(cpList->Get(pos + 1));
|
||||
context->ResetProtoTransitionTableOnConstpool(cpHandle.GetTaggedValue());
|
||||
cpMap.insert({constantPoolID, cpHandle.GetTaggedValue()});
|
||||
// the arkui framework abc file constpool was patched here
|
||||
if (frameworkHelper.IsFrameworkAbcFile(fileNameStr)) {
|
||||
context->UpdateConstpoolWhenDeserialAI(fileNameStr, cp, constantPoolID);
|
||||
context->UpdateConstpoolWhenDeserialAI(fileNameStr, cpHandle, constantPoolID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -618,20 +618,21 @@ void EcmaContext::SetUnsharedConstpool(int32_t constpoolIndex, JSTaggedValue uns
|
||||
unsharedConstpools_[constpoolIndex] = unsharedConstpool;
|
||||
}
|
||||
|
||||
void EcmaContext::UpdateConstpoolWhenDeserialAI(const std::string& fileName, JSTaggedValue constpool, int32_t index)
|
||||
void EcmaContext::UpdateConstpoolWhenDeserialAI(const std::string& fileName,
|
||||
JSHandle<ConstantPool> aiCP, int32_t index)
|
||||
{
|
||||
auto pf = JSPandaFileManager::GetInstance()->FindJSPandaFile(fileName.c_str());
|
||||
if (pf == nullptr) {
|
||||
return;
|
||||
}
|
||||
JSTaggedValue sharedConstpool = FindConstpool(pf.get(), index);
|
||||
JSHandle<ConstantPool> sharedCPHandle = JSHandle<ConstantPool>(thread_, sharedConstpool);
|
||||
if (sharedConstpool.IsHole()) {
|
||||
return;
|
||||
}
|
||||
JSTaggedValue unsharedConstpool = FindOrCreateUnsharedConstpool(sharedConstpool);
|
||||
ConstantPool *unsharedCP = ConstantPool::Cast(unsharedConstpool.GetTaggedObject());
|
||||
ConstantPool *sharedCP = ConstantPool::Cast(sharedConstpool.GetTaggedObject());
|
||||
const ConstantPool *aiCP = ConstantPool::Cast(constpool.GetTaggedObject());
|
||||
JSTaggedValue unsharedConstpool = FindOrCreateUnsharedConstpool(sharedCPHandle.GetTaggedValue());
|
||||
JSHandle<ConstantPool> unsharedCP = JSHandle<ConstantPool>(thread_, unsharedConstpool);
|
||||
JSHandle<ConstantPool> sharedCP = JSHandle<ConstantPool>(thread_, sharedCPHandle.GetTaggedValue());
|
||||
ConstantPool::UpdateConstpoolWhenDeserialAI(vm_, aiCP, sharedCP, unsharedCP);
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,9 @@ public:
|
||||
JSHandle<ConstantPool> constpool,
|
||||
int32_t index);
|
||||
|
||||
void UpdateConstpoolWhenDeserialAI(const std::string& fileName, JSTaggedValue constpool, int32_t index = 0);
|
||||
void UpdateConstpoolWhenDeserialAI(const std::string& fileName,
|
||||
JSHandle<ConstantPool> aiCP,
|
||||
int32_t index = 0);
|
||||
|
||||
bool HasCachedConstpool(const JSPandaFile *jsPandaFile) const;
|
||||
|
||||
|
@ -84,11 +84,12 @@ bool ConstantPool::IsAotMethodLiteralInfo(JSTaggedValue literalInfo)
|
||||
GetLiteralType() == AOTLiteralInfo::METHOD_LITERAL_TYPE);
|
||||
}
|
||||
|
||||
void ConstantPool::UpdateConstpoolWhenDeserialAI(EcmaVM *vm, const ConstantPool *aiCP,
|
||||
ConstantPool *sharedCP, ConstantPool *unsharedCP)
|
||||
void ConstantPool::UpdateConstpoolWhenDeserialAI(EcmaVM *vm, JSHandle<ConstantPool> aiCP,
|
||||
JSHandle<ConstantPool> sharedCP, JSHandle<ConstantPool> unsharedCP)
|
||||
{
|
||||
uint32_t constpoolLen = aiCP->GetCacheLength();
|
||||
auto aiCPLength = aiCP->GetLength();
|
||||
JSMutableHandle<JSTaggedValue> valHandle(vm->GetJSThread(), JSTaggedValue::Undefined());
|
||||
for (uint32_t i = 0; i < constpoolLen; i++) {
|
||||
// We need preserve unshared constantPool index and shared constantPool id instead of fetching from ai.
|
||||
// Because framework abc's ai does not contain those infos.
|
||||
@ -97,19 +98,20 @@ void ConstantPool::UpdateConstpoolWhenDeserialAI(EcmaVM *vm, const ConstantPool
|
||||
continue;
|
||||
}
|
||||
JSThread *thread = vm->GetJSThread();
|
||||
auto val = aiCP->GetObjectFromCache(i);
|
||||
if (IsAotMethodLiteralInfo(val)) {
|
||||
JSHandle<AOTLiteralInfo> valHandle(thread, val);
|
||||
JSHandle<AOTLiteralInfo> methodLiteral = CopySharedMethodAOTLiteralInfo(vm, valHandle);
|
||||
JSTaggedValue val = aiCP->GetObjectFromCache(i);
|
||||
valHandle.Update(val);
|
||||
if (IsAotMethodLiteralInfo(valHandle.GetTaggedValue())) {
|
||||
JSHandle<AOTLiteralInfo> value(thread, val);
|
||||
JSHandle<AOTLiteralInfo> methodLiteral = CopySharedMethodAOTLiteralInfo(vm, value);
|
||||
sharedCP->SetObjectToCache(thread, i, methodLiteral.GetTaggedValue());
|
||||
} else if (val.IsInt()) {
|
||||
} else if (valHandle->IsInt()) {
|
||||
// For MethodInfo which does not have ihc infos, we store codeEntry directly.
|
||||
sharedCP->SetObjectToCache(thread, i, val);
|
||||
unsharedCP->SetObjectToCache(thread, i, val);
|
||||
sharedCP->SetObjectToCache(thread, i, valHandle.GetTaggedValue());
|
||||
unsharedCP->SetObjectToCache(thread, i, valHandle.GetTaggedValue());
|
||||
}
|
||||
// update method, class and object aotliteralinfo
|
||||
if (val.IsAOTLiteralInfo()) {
|
||||
unsharedCP->SetObjectToCache(thread, i, val);
|
||||
if (valHandle->IsAOTLiteralInfo()) {
|
||||
unsharedCP->SetObjectToCache(thread, i, valHandle.GetTaggedValue());
|
||||
}
|
||||
}
|
||||
unsharedCP->InitConstantPoolTail(vm->GetJSThread(), aiCP);
|
||||
|
@ -357,7 +357,7 @@ public:
|
||||
return Barriers::GetValue<JSPandaFile *>(GetData(), GetJSPandaFileOffset());
|
||||
}
|
||||
|
||||
inline void InitConstantPoolTail(const JSThread *thread, const ConstantPool *constPool)
|
||||
inline void InitConstantPoolTail(const JSThread *thread, JSHandle<ConstantPool> constPool)
|
||||
{
|
||||
SetAotArrayInfo(thread, constPool->GetAotArrayInfo());
|
||||
SetAotHClassInfo(thread, constPool->GetAotHClassInfo());
|
||||
@ -525,8 +525,8 @@ public:
|
||||
|
||||
static JSTaggedValue PUBLIC_API GetMethodFromCache(JSTaggedValue constpool, uint32_t index);
|
||||
|
||||
static void PUBLIC_API UpdateConstpoolWhenDeserialAI(EcmaVM *vm, const ConstantPool *aiCP,
|
||||
ConstantPool *sharedCP, ConstantPool *unsharedCP);
|
||||
static void PUBLIC_API UpdateConstpoolWhenDeserialAI(EcmaVM *vm, JSHandle<ConstantPool> aiCP,
|
||||
JSHandle<ConstantPool> sharedCP, JSHandle<ConstantPool> unsharedCP);
|
||||
|
||||
static bool PUBLIC_API IsAotMethodLiteralInfo(JSTaggedValue literalInfo);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user