diff --git a/ecmascript/compiler/aot_file/aot_file_manager.cpp b/ecmascript/compiler/aot_file/aot_file_manager.cpp index 16f827741a..3330b139b6 100644 --- a/ecmascript/compiler/aot_file/aot_file_manager.cpp +++ b/ecmascript/compiler/aot_file/aot_file_manager.cpp @@ -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 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); } } } diff --git a/ecmascript/ecma_context.cpp b/ecmascript/ecma_context.cpp index 6f37f95a20..136da76d7b 100644 --- a/ecmascript/ecma_context.cpp +++ b/ecmascript/ecma_context.cpp @@ -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 aiCP, int32_t index) { auto pf = JSPandaFileManager::GetInstance()->FindJSPandaFile(fileName.c_str()); if (pf == nullptr) { return; } JSTaggedValue sharedConstpool = FindConstpool(pf.get(), index); + JSHandle sharedCPHandle = JSHandle(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 unsharedCP = JSHandle(thread_, unsharedConstpool); + JSHandle sharedCP = JSHandle(thread_, sharedCPHandle.GetTaggedValue()); ConstantPool::UpdateConstpoolWhenDeserialAI(vm_, aiCP, sharedCP, unsharedCP); } diff --git a/ecmascript/ecma_context.h b/ecmascript/ecma_context.h index c88191cc77..ca4e347138 100644 --- a/ecmascript/ecma_context.h +++ b/ecmascript/ecma_context.h @@ -259,7 +259,9 @@ public: JSHandle constpool, int32_t index); - void UpdateConstpoolWhenDeserialAI(const std::string& fileName, JSTaggedValue constpool, int32_t index = 0); + void UpdateConstpoolWhenDeserialAI(const std::string& fileName, + JSHandle aiCP, + int32_t index = 0); bool HasCachedConstpool(const JSPandaFile *jsPandaFile) const; diff --git a/ecmascript/jspandafile/program_object.cpp b/ecmascript/jspandafile/program_object.cpp index b9dda4ef92..655b0d1910 100644 --- a/ecmascript/jspandafile/program_object.cpp +++ b/ecmascript/jspandafile/program_object.cpp @@ -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 aiCP, + JSHandle sharedCP, JSHandle unsharedCP) { uint32_t constpoolLen = aiCP->GetCacheLength(); auto aiCPLength = aiCP->GetLength(); + JSMutableHandle 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 valHandle(thread, val); - JSHandle methodLiteral = CopySharedMethodAOTLiteralInfo(vm, valHandle); + JSTaggedValue val = aiCP->GetObjectFromCache(i); + valHandle.Update(val); + if (IsAotMethodLiteralInfo(valHandle.GetTaggedValue())) { + JSHandle value(thread, val); + JSHandle 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); diff --git a/ecmascript/jspandafile/program_object.h b/ecmascript/jspandafile/program_object.h index 8aeace602d..a2a615c983 100644 --- a/ecmascript/jspandafile/program_object.h +++ b/ecmascript/jspandafile/program_object.h @@ -357,7 +357,7 @@ public: return Barriers::GetValue(GetData(), GetJSPandaFileOffset()); } - inline void InitConstantPoolTail(const JSThread *thread, const ConstantPool *constPool) + inline void InitConstantPoolTail(const JSThread *thread, JSHandle 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 aiCP, + JSHandle sharedCP, JSHandle unsharedCP); static bool PUBLIC_API IsAotMethodLiteralInfo(JSTaggedValue literalInfo);