mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-06 23:54:03 +00:00
Framework abc hclass and object aotliteral update
Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IA62QL Signed-off-by: wu_zhang_da <wuzhangda@huawei.com> Change-Id: Id362b57457a71445d3731343340703b2567de88e
This commit is contained in:
parent
53b83f4e88
commit
aea97656af
@ -480,7 +480,7 @@ void AOTFileManager::ParseDeserializedData(const CString &snapshotFileName, JSTa
|
||||
cpMap.insert({constantPoolID, cp});
|
||||
// the arkui framework abc file constpool was patched here
|
||||
if (frameworkHelper.IsFrameworkAbcFile(fileNameStr)) {
|
||||
thread->GetCurrentEcmaContext()->UpdateAOTConstpool(fileNameStr, cp, constantPoolID);
|
||||
thread->GetCurrentEcmaContext()->UpdateConstpoolWhenDeserialAI(fileNameStr, cp, constantPoolID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ void EcmaContext::SetUnsharedConstpool(int32_t constpoolIndex, JSTaggedValue uns
|
||||
unsharedConstpools_[constpoolIndex] = unsharedConstpool;
|
||||
}
|
||||
|
||||
void EcmaContext::UpdateAOTConstpool(const std::string& fileName, JSTaggedValue constpool, int32_t index)
|
||||
void EcmaContext::UpdateConstpoolWhenDeserialAI(const std::string& fileName, JSTaggedValue constpool, int32_t index)
|
||||
{
|
||||
auto pf = JSPandaFileManager::GetInstance()->FindJSPandaFile(fileName.c_str());
|
||||
if (pf == nullptr) {
|
||||
@ -611,19 +611,10 @@ void EcmaContext::UpdateAOTConstpool(const std::string& fileName, JSTaggedValue
|
||||
return;
|
||||
}
|
||||
JSTaggedValue unsharedConstpool = FindOrCreateUnsharedConstpool(sharedConstpool);
|
||||
ConstantPool *taggedUnsharedConstpoolpool = ConstantPool::Cast(unsharedConstpool.GetTaggedObject());
|
||||
ConstantPool *taggedSharedConstpoolpool = ConstantPool::Cast(sharedConstpool.GetTaggedObject());
|
||||
const ConstantPool *taggedConstpoolpool = ConstantPool::Cast(constpool.GetTaggedObject());
|
||||
uint32_t constpoolLen = taggedConstpoolpool->GetCacheLength();
|
||||
for (uint32_t i = 0; i < constpoolLen; i++) {
|
||||
auto val = taggedConstpoolpool->GetObjectFromCache(i);
|
||||
if (ConstantPool::IsAotMethodLiteralInfo(val)) {
|
||||
JSHandle<AOTLiteralInfo> valHandle(thread_, val);
|
||||
JSHandle<AOTLiteralInfo> methodLiteral = ConstantPool::CopySharedMethodAOTLiteralInfo(vm_, valHandle);
|
||||
taggedSharedConstpoolpool->SetObjectToCache(thread_, i, methodLiteral.GetTaggedValue());
|
||||
taggedUnsharedConstpoolpool->SetObjectToCache(thread_, i, val);
|
||||
}
|
||||
}
|
||||
ConstantPool *unsharedCP = ConstantPool::Cast(unsharedConstpool.GetTaggedObject());
|
||||
ConstantPool *sharedCP = ConstantPool::Cast(sharedConstpool.GetTaggedObject());
|
||||
const ConstantPool *aiCP = ConstantPool::Cast(constpool.GetTaggedObject());
|
||||
ConstantPool::UpdateConstpoolWhenDeserialAI(vm_, aiCP, sharedCP, unsharedCP);
|
||||
}
|
||||
|
||||
JSTaggedValue EcmaContext::FindCachedConstpoolAndLoadAiIfNeeded(const JSPandaFile *jsPandaFile, int32_t index)
|
||||
|
@ -258,7 +258,7 @@ public:
|
||||
JSHandle<ConstantPool> constpool,
|
||||
int32_t index);
|
||||
|
||||
void UpdateAOTConstpool(const std::string& fileName, JSTaggedValue constpool, int32_t index = 0);
|
||||
void UpdateConstpoolWhenDeserialAI(const std::string& fileName, JSTaggedValue constpool, int32_t index = 0);
|
||||
|
||||
bool HasCachedConstpool(const JSPandaFile *jsPandaFile) const;
|
||||
|
||||
|
@ -36,4 +36,30 @@ JSTaggedValue ConstantPool::GetMethodFromCache(JSTaggedValue constpool, uint32_t
|
||||
|
||||
return val.IsHole() ? JSTaggedValue::Undefined() : val;
|
||||
}
|
||||
|
||||
bool ConstantPool::IsAotMethodLiteralInfo(JSTaggedValue literalInfo)
|
||||
{
|
||||
return literalInfo.IsAOTLiteralInfo() && (AOTLiteralInfo::Cast(literalInfo.GetTaggedObject())->
|
||||
GetLiteralType() == AOTLiteralInfo::METHOD_LITERAL_TYPE);
|
||||
}
|
||||
|
||||
void ConstantPool::UpdateConstpoolWhenDeserialAI(EcmaVM *vm, const ConstantPool *aiCP,
|
||||
ConstantPool *sharedCP, ConstantPool *unsharedCP)
|
||||
{
|
||||
uint32_t constpoolLen = aiCP->GetCacheLength();
|
||||
for (uint32_t i = 0; i < constpoolLen; i++) {
|
||||
JSThread *thread = vm->GetJSThread();
|
||||
auto val = aiCP->GetObjectFromCache(i);
|
||||
if (IsAotMethodLiteralInfo(val)) {
|
||||
JSHandle<AOTLiteralInfo> valHandle(thread, val);
|
||||
JSHandle<AOTLiteralInfo> methodLiteral = CopySharedMethodAOTLiteralInfo(vm, valHandle);
|
||||
sharedCP->SetObjectToCache(thread, i, methodLiteral.GetTaggedValue());
|
||||
}
|
||||
// update method, class and object aotliteralinfo
|
||||
if (val.IsAOTLiteralInfo()) {
|
||||
unsharedCP->SetObjectToCache(thread, i, val);
|
||||
}
|
||||
}
|
||||
unsharedCP->InitConstantPoolTail(aiCP);
|
||||
}
|
||||
}
|
||||
|
@ -51,32 +51,32 @@ public:
|
||||
DECL_DUMP()
|
||||
};
|
||||
|
||||
/* ConstantPool
|
||||
* +--------------------------------+----
|
||||
* | ReviseData | ^
|
||||
* | ... | |
|
||||
* | string(EcmaString) | |
|
||||
* | method(Method) |cacheLength
|
||||
* | array literal(JSArray) | |
|
||||
* | object literal(JSObject) | |
|
||||
* | class literal(ClassLiteral) | v
|
||||
* +--------------------------------+----
|
||||
* | AOTSymbolInfo |TaggedArray
|
||||
* +--------------------------------+----
|
||||
* | unshared constpool index |int32_t
|
||||
* +--------------------------------+----
|
||||
* | shared constpool id |int32_t
|
||||
* +--------------------------------+----
|
||||
* | AOTHClassInfo |TaggedArray
|
||||
* +--------------------------------+----
|
||||
* | AOTArrayInfo |TaggedArray
|
||||
* +--------------------------------+----
|
||||
* | constIndexInfo |TaggedArray
|
||||
* +--------------------------------+----
|
||||
* | IndexHeader |
|
||||
* +--------------------------------+
|
||||
* | JSPandaFile |
|
||||
* +--------------------------------+
|
||||
/* ConstantPool(TaggedArray)
|
||||
* +--------------------------------+----------------------------------
|
||||
* | ... | ^ ^ ^ index 0
|
||||
* | Method | | | |
|
||||
* | String | | | |
|
||||
* | Array Literal | ConstpoolLength | |
|
||||
* | Class Literal | | | |
|
||||
* | Object Literal | | | |
|
||||
* | ... | v | |
|
||||
* +--------------------------------+--------------- | |
|
||||
* | AOTSymbolInfo |TaggedArray | |
|
||||
* +--------------------------------+--------------- | |
|
||||
* | unshared constpool index |int32_t CacheLength |
|
||||
* +--------------------------------+--------------- | Length
|
||||
* | shared constpool id |int32_t | |
|
||||
* +--------------------------------+--------------- | |
|
||||
* | AOTHClassInfo |TaggedArray | |
|
||||
* +--------------------------------+--------------- | |
|
||||
* | AOTArrayInfo |TaggedArray | |
|
||||
* +--------------------------------+--------------- | |
|
||||
* | constIndexInfo |TaggedArray v |
|
||||
* +--------------------------------+-------------------------- |
|
||||
* | IndexHeader | |
|
||||
* +--------------------------------+ |
|
||||
* | JSPandaFile | v index: Length-1
|
||||
* +--------------------------------+-----------------------------------
|
||||
*/
|
||||
class ConstantPool : public TaggedArray {
|
||||
public:
|
||||
@ -182,12 +182,6 @@ public:
|
||||
return constpool;
|
||||
}
|
||||
|
||||
static bool IsAotMethodLiteralInfo(JSTaggedValue literalInfo)
|
||||
{
|
||||
return literalInfo.IsAOTLiteralInfo() && (AOTLiteralInfo::Cast(literalInfo.GetTaggedObject())->
|
||||
GetLiteralType() == AOTLiteralInfo::METHOD_LITERAL_TYPE);
|
||||
}
|
||||
|
||||
static bool IsAotSymbolInfoExist(JSHandle<TaggedArray> symbolInfo, JSTaggedValue symbol)
|
||||
{
|
||||
return symbolInfo->GetLength() > 0 && !symbol.IsHole();
|
||||
@ -197,7 +191,7 @@ public:
|
||||
EcmaVM *vm, JSHandle<ConstantPool> constpool, int32_t cpId = 0)
|
||||
{
|
||||
JSHandle<ConstantPool> sconstpool(vm->GetJSThread(), JSTaggedValue::Hole());
|
||||
uint32_t capacity = constpool->GetConstpoolSize();
|
||||
uint32_t capacity = constpool->GetConstpoolLength();
|
||||
if (sconstpool.GetTaggedValue().IsHole()) {
|
||||
ObjectFactory *factory = vm->GetFactory();
|
||||
sconstpool = factory->NewSConstantPool(capacity);
|
||||
@ -334,7 +328,7 @@ public:
|
||||
return GetLength() - RESERVED_POOL_LENGTH;
|
||||
}
|
||||
|
||||
inline uint32_t GetConstpoolSize() const
|
||||
inline uint32_t GetConstpoolLength() const
|
||||
{
|
||||
return GetLength() - RESERVED_POOL_LENGTH - EXTEND_DATA_NUM;
|
||||
}
|
||||
@ -349,17 +343,30 @@ public:
|
||||
return Barriers::GetValue<JSPandaFile *>(GetData(), GetJSPandaFileOffset());
|
||||
}
|
||||
|
||||
inline void InitConstantPoolTail(const ConstantPool *constPool)
|
||||
{
|
||||
SetAotArrayInfo(constPool->GetAotArrayInfo());
|
||||
SetAotHClassInfo(constPool->GetAotHClassInfo());
|
||||
SetConstantIndexInfo(constPool->GetConstantIndexInfo());
|
||||
SetAotSymbolInfo(constPool->GetAotSymbolInfo());
|
||||
}
|
||||
|
||||
inline void SetConstantIndexInfo(JSTaggedValue info)
|
||||
{
|
||||
Barriers::SetPrimitive(GetData(), GetConstantIndexInfoOffset(), info.GetRawData());
|
||||
}
|
||||
|
||||
inline JSTaggedValue GetConstantIndexInfo() const
|
||||
{
|
||||
return JSTaggedValue(Barriers::GetValue<JSTaggedType>(GetData(), GetConstantIndexInfoOffset()));
|
||||
}
|
||||
|
||||
inline void SetAotArrayInfo(JSTaggedValue info)
|
||||
{
|
||||
Barriers::SetPrimitive(GetData(), GetAotArrayInfoOffset(), info.GetRawData());
|
||||
}
|
||||
|
||||
inline JSTaggedValue GetAotArrayInfo()
|
||||
inline JSTaggedValue GetAotArrayInfo() const
|
||||
{
|
||||
return JSTaggedValue(Barriers::GetValue<JSTaggedType>(GetData(), GetAotArrayInfoOffset()));
|
||||
}
|
||||
@ -401,6 +408,11 @@ public:
|
||||
Barriers::SetPrimitive(GetData(), GetAotHClassInfoOffset(), info.GetRawData());
|
||||
}
|
||||
|
||||
inline JSTaggedValue GetAotHClassInfo() const
|
||||
{
|
||||
return JSTaggedValue(Barriers::GetValue<JSTaggedType>(GetData(), GetAotHClassInfoOffset()));
|
||||
}
|
||||
|
||||
inline void SetAotHClassInfoWithBarrier(JSThread *thread, JSTaggedValue info)
|
||||
{
|
||||
Set(thread, (GetLength() - AOT_HCLASS_INFO_INDEX), info);
|
||||
@ -487,6 +499,11 @@ 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 bool PUBLIC_API IsAotMethodLiteralInfo(JSTaggedValue literalInfo);
|
||||
|
||||
static JSTaggedValue GetClassLiteralFromCache(JSThread *thread, JSHandle<ConstantPool> constpool,
|
||||
uint32_t literal, CString entry, JSHandle<JSTaggedValue> sendableEnv = JSHandle<JSTaggedValue>(),
|
||||
ClassKind kind = ClassKind::NON_SENDABLE)
|
||||
|
Loading…
Reference in New Issue
Block a user