!4049 Fix loading aot files

Merge pull request !4049 from xiongluo/fix_load_aot
This commit is contained in:
openharmony_ci 2023-05-14 05:16:49 +00:00 committed by Gitee
commit 3a1b205193
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 22 additions and 32 deletions

View File

@ -65,22 +65,12 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::ExecuteFromFile(JSThread *thr
std::shared_ptr<JSPandaFile> jsPandaFile =
JSPandaFileManager::GetInstance()->LoadJSPandaFile(thread, name, entry, needUpdate);
if (vm->GetJSOptions().GetEnableAsmInterpreter() && vm->GetJSOptions().WasAOTOutputFileSet()) {
auto aotFM = thread->GetEcmaVM()->GetAOTFileManager();
AnFileDataManager::GetInstance()->SetEnable(true);
std::string aotFilename = vm->GetJSOptions().GetAOTOutputFile();
vm->LoadAOTFiles(aotFilename);
if (aotFM->IsLoad(jsPandaFile.get())) {
uint32_t index = aotFM->GetAnFileIndex(jsPandaFile.get());
jsPandaFile->SetAOTFileInfoIndex(index);
}
}
if (jsPandaFile == nullptr) {
CString msg = "Load file with filename '" + name + "' failed, recordName '" + entry + "'";
THROW_REFERENCE_ERROR_AND_RETURN(thread, msg.c_str(), Unexpected(false));
}
LoadAOTFilesForFile(vm, jsPandaFile.get());
CString realEntry = entry;
// If it is an old record, delete the bundleName and moduleName
if (!jsPandaFile->IsBundlePack() && !excuteFromJob && !vm->GetBundleName().empty()) {
@ -131,16 +121,8 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::ExecuteFromBuffer(JSThread *t
THROW_REFERENCE_ERROR_AND_RETURN(thread, msg.c_str(), Unexpected(false));
}
auto vm = thread->GetEcmaVM();
if (vm->GetJSOptions().GetEnableAsmInterpreter() && vm->GetJSOptions().WasAOTOutputFileSet()) {
auto aotFM = thread->GetEcmaVM()->GetAOTFileManager();
AnFileDataManager::GetInstance()->SetEnable(true);
std::string aotFilename = vm->GetJSOptions().GetAOTOutputFile();
vm->LoadAOTFiles(aotFilename);
if (aotFM->IsLoad(jsPandaFile.get())) {
uint32_t index = aotFM->GetAnFileIndex(jsPandaFile.get());
jsPandaFile->SetAOTFileInfoIndex(index);
}
}
LoadAOTFilesForFile(vm, jsPandaFile.get());
CString entry = entryPoint.data();
bool isModule = jsPandaFile->IsModule(thread, entry);
if (isModule) {
@ -173,16 +155,7 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::ExecuteModuleBuffer(
CString msg = "Load file with filename '" + name + "' failed, recordName '" + entry + "'";
THROW_REFERENCE_ERROR_AND_RETURN(thread, msg.c_str(), Unexpected(false));
}
if (vm->GetJSOptions().GetEnableAsmInterpreter() && vm->GetJSOptions().WasAOTOutputFileSet()) {
auto aotFM = thread->GetEcmaVM()->GetAOTFileManager();
AnFileDataManager::GetInstance()->SetEnable(true);
std::string aotFilename = vm->GetJSOptions().GetAOTOutputFile();
vm->LoadAOTFiles(aotFilename);
if (aotFM->IsLoad(jsPandaFile.get())) {
uint32_t index = aotFM->GetAnFileIndex(jsPandaFile.get());
jsPandaFile->SetAOTFileInfoIndex(index);
}
}
LoadAOTFilesForFile(vm, jsPandaFile.get());
bool isBundle = jsPandaFile->IsBundlePack();
CString realEntry = entry;
@ -238,4 +211,20 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::Execute(JSThread *thread, con
}
return result;
}
void JSPandaFileExecutor::LoadAOTFilesForFile(EcmaVM *vm, JSPandaFile *jsPandaFile)
{
if (vm->GetJSOptions().GetEnableAsmInterpreter()) {
auto aotFM = vm->GetAOTFileManager();
if (vm->GetJSOptions().WasAOTOutputFileSet()) {
AnFileDataManager::GetInstance()->SetEnable(true);
std::string aotFilename = vm->GetJSOptions().GetAOTOutputFile();
vm->LoadAOTFiles(aotFilename);
}
if (aotFM->IsLoad(jsPandaFile)) {
uint32_t index = aotFM->GetAnFileIndex(jsPandaFile);
jsPandaFile->SetAOTFileInfoIndex(index);
}
}
}
} // namespace panda::ecmascript

View File

@ -36,6 +36,7 @@ public:
const CString &entry, const void *buffer, size_t size);
static Expected<JSTaggedValue, bool> Execute(JSThread *thread, const JSPandaFile *jsPandaFile,
std::string_view entryPoint, bool excuteFromJob = false);
static void LoadAOTFilesForFile(EcmaVM *vm, JSPandaFile *jsPandaFile);
};
} // namespace panda::ecmascript
#endif // ECMASCRIPT_JSPANDAFILE_JS_PANDAFILE_EXECUTOR_H