mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 16:13:49 +00:00
Fix the way to get current hap's record format
------------------------------ issue : https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I6LD9H?from=project-issue Signed-off-by: DaiHN <daihuina1@huawei.com> Change-Id: I7d31218e31d22393b03addadb2366e0069833027
This commit is contained in:
parent
e8e5082e47
commit
9a0f0ea1f5
@ -250,12 +250,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static CString ParsePrefixBundle(JSThread *thread, const JSPandaFile *jsPandaFile,
|
||||
[[maybe_unused]] CString &baseFileName, CString moduleRequestName)
|
||||
static CString ParsePrefixBundle(JSThread *thread, [[maybe_unused]] CString &baseFileName,
|
||||
CString moduleRequestName)
|
||||
{
|
||||
EcmaVM *vm = thread->GetEcmaVM();
|
||||
moduleRequestName = moduleRequestName.substr(PREFIX_BUNDLE_LEN);
|
||||
CString entryPoint = moduleRequestName;
|
||||
if (jsPandaFile->IsNewRecord()) {
|
||||
if (vm->IsRecordWithBundleName()) {
|
||||
CVector<CString> vec;
|
||||
SplitString(moduleRequestName, vec, 0, SEGMENTS_LIMIT_TWO);
|
||||
if (vec.size() < SEGMENTS_LIMIT_TWO) {
|
||||
@ -266,7 +267,6 @@ public:
|
||||
CString moduleName = vec[1];
|
||||
CropNamespaceIfAbsent(moduleName);
|
||||
|
||||
EcmaVM *vm = thread->GetEcmaVM();
|
||||
#if !defined(PANDA_TARGET_WINDOWS) && !defined(PANDA_TARGET_MACOS)
|
||||
if (bundleName != vm->GetBundleName()) {
|
||||
baseFileName =
|
||||
@ -494,7 +494,7 @@ public:
|
||||
{
|
||||
CString entryPoint;
|
||||
if (StringStartWith(requestName, PREFIX_BUNDLE, PREFIX_BUNDLE_LEN)) {
|
||||
entryPoint = ParsePrefixBundle(thread, jsPandaFile, baseFileName, requestName);
|
||||
entryPoint = ParsePrefixBundle(thread, baseFileName, requestName);
|
||||
} else if (StringStartWith(requestName, PREFIX_MODULE, PREFIX_MODULE_LEN)) {
|
||||
entryPoint = ParsePreixModule(baseFileName, recordName, requestName);
|
||||
} else if (StringStartWith(requestName, PREFIX_PACKAGE, PREFIX_PACKAGE_LEN)) {
|
||||
|
@ -443,6 +443,16 @@ public:
|
||||
return options_.IsWorker();
|
||||
}
|
||||
|
||||
bool IsRecordWithBundleName() const
|
||||
{
|
||||
return options_.IsRecordWithBundleName();
|
||||
}
|
||||
|
||||
void SetRecordWithBundleNameTag(bool isNewRecord)
|
||||
{
|
||||
options_.SetRecordWithBundleNameTag(isNewRecord);
|
||||
}
|
||||
|
||||
bool IsBundlePack() const
|
||||
{
|
||||
return isBundlePack_;
|
||||
|
@ -539,6 +539,16 @@ public:
|
||||
return isWorker_;
|
||||
}
|
||||
|
||||
void SetRecordWithBundleNameTag(bool isNewRecord)
|
||||
{
|
||||
isRecordWithBundleName_ = isNewRecord;
|
||||
}
|
||||
|
||||
bool IsRecordWithBundleName() const
|
||||
{
|
||||
return isRecordWithBundleName_;
|
||||
}
|
||||
|
||||
bool EnableIC() const
|
||||
{
|
||||
return enableIC_;
|
||||
@ -940,6 +950,7 @@ private:
|
||||
uint8_t deoptThreshold_ {10};
|
||||
bool optCodeProfiler_ {false};
|
||||
bool startGlobalLeakCheck_ {false};
|
||||
bool isRecordWithBundleName_ {false};
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
|
||||
|
@ -59,20 +59,20 @@ void JSPandaFile::CheckIsBundlePack()
|
||||
|
||||
void JSPandaFile::CheckIsNewRecord(EcmaVM *vm)
|
||||
{
|
||||
CString bundleName = vm->GetBundleName();
|
||||
|
||||
if (vm->IsRecordWithBundleName()) {
|
||||
return;
|
||||
}
|
||||
for (auto info : jsRecordInfo_) {
|
||||
if (info.first.find(PACKAGE_PATH_SEGMENT) != CString::npos ||
|
||||
info.first.find(NPM_PATH_SEGMENT) != CString::npos) {
|
||||
continue;
|
||||
}
|
||||
CString recordName = info.first;
|
||||
CString bundleName = vm->GetBundleName();
|
||||
size_t bundleNameLen = bundleName.length();
|
||||
// Confirm whether the current record is new or old by judging whether the recordName has a bundleName
|
||||
if (recordName.length() > bundleNameLen && (recordName.compare(0, bundleNameLen, bundleName) == 0)) {
|
||||
isNewRecord_ = true;
|
||||
} else {
|
||||
isNewRecord_ = false;
|
||||
vm->SetRecordWithBundleNameTag(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -245,11 +245,6 @@ public:
|
||||
return isBundlePack_;
|
||||
}
|
||||
|
||||
bool IsNewRecord() const
|
||||
{
|
||||
return isNewRecord_;
|
||||
}
|
||||
|
||||
bool IsLoadedAOT() const
|
||||
{
|
||||
return (anFileInfoIndex_ != INVALID_INDEX);
|
||||
@ -369,7 +364,6 @@ private:
|
||||
|
||||
// marge abc
|
||||
bool isBundlePack_ {true}; // isBundlePack means app compile mode is JSBundle
|
||||
bool isNewRecord_ {true};
|
||||
CUnorderedMap<CString, JSRecordInfo> jsRecordInfo_;
|
||||
};
|
||||
} // namespace ecmascript
|
||||
|
@ -68,7 +68,7 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::ExecuteFromFile(JSThread *thr
|
||||
THROW_REFERENCE_ERROR_AND_RETURN(thread, msg.c_str(), Unexpected(false));
|
||||
}
|
||||
// If it is an old record, delete the bundleName and moduleName
|
||||
if (!excuteFromJob && !jsPandaFile->IsNewRecord()) {
|
||||
if (!excuteFromJob && !vm->IsRecordWithBundleName()) {
|
||||
PathHelper::CroppingRecord(entry);
|
||||
}
|
||||
bool isModule = jsPandaFile->IsModule(thread, entry.c_str());
|
||||
@ -152,7 +152,7 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::ExecuteModuleBuffer(
|
||||
}
|
||||
ASSERT(jsPandaFile->IsModule(thread, entry.c_str()));
|
||||
bool isBundle = jsPandaFile->IsBundlePack();
|
||||
if (!jsPandaFile->IsNewRecord()) {
|
||||
if (!vm->IsRecordWithBundleName()) {
|
||||
PathHelper::CroppingRecord(entry);
|
||||
}
|
||||
ASSERT(jsPandaFile->IsModule(thread, entry.c_str()));
|
||||
|
@ -289,6 +289,7 @@ HWTEST_F_L0(EcmaModuleTest, ConcatFileNameWithMerge1)
|
||||
return
|
||||
}
|
||||
)";
|
||||
thread->GetEcmaVM()->SetRecordWithBundleNameTag(true);
|
||||
JSPandaFileManager *pfManager = JSPandaFileManager::GetInstance();
|
||||
Parser parser;
|
||||
auto res = parser.Parse(data);
|
||||
|
@ -680,7 +680,7 @@ Local<ObjectRef> JSNApi::GetExportObject(EcmaVM *vm, const std::string &file, co
|
||||
JSHandle<JSTaggedValue> exportObj(thread, JSTaggedValue::Null());
|
||||
return JSNApiHelper::ToLocal<ObjectRef>(exportObj);
|
||||
}
|
||||
if (!jsPandaFile->IsNewRecord()) {
|
||||
if (!vm->IsRecordWithBundleName()) {
|
||||
PathHelper::CroppingRecord(entry);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user