HotReload bugfix for new instruction

Signed-off-by: g00416891 <guobingbing3@huawei.com>
Change-Id: I497432e52b6e6e668786c2b9ed2dfb1cd7cf827f
This commit is contained in:
g00416891 2022-11-14 19:28:35 +08:00
parent 213f854757
commit c600d89082
2 changed files with 7 additions and 14 deletions

View File

@ -120,6 +120,7 @@ public:
if (info != jsRecordInfo_.end()) {
return info->second.mainMethodIndex;
}
LOG_ECMA(ERROR) << "can not get main method index: " << recordName;
return 0;
}

View File

@ -118,20 +118,9 @@ CVector<JSHandle<Program>> QuickFixLoader::ParseAllConstpoolWithMerge(JSThread *
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
JSHandle<JSHClass> hclass = JSHandle<JSHClass>::Cast(vm->GetGlobalEnv()->GetFunctionClassWithProto());
const CString &filename = jsPandaFile->GetJSPandaFileDesc();
#if defined(PANDA_TARGET_LINUX) || defined(OHOS_UNIT_TEST)
CString entry = JSPandaFile::ParseRecordName(filename);
#else
CString entry = JSPandaFile::ParseOhmUrl(filename);
#endif
uint32_t mainMethodIndex = jsPandaFile->GetMainMethodIndex(entry);
ASSERT(mainMethodIndex != 0);
JSHandle<ConstantPool> constpool;
bool isNewVersion = jsPandaFile->IsNewVersion();
if (isNewVersion) {
constpool = vm->FindOrCreateConstPool(jsPandaFile, panda_file::File::EntityId(mainMethodIndex));
} else {
if (!isNewVersion) {
auto constpoolVals = vm->FindConstpools(jsPandaFile);
if (!constpoolVals.has_value()) {
constpool = PandaFileTranslator::ParseConstPool(vm, jsPandaFile);
@ -149,13 +138,16 @@ CVector<JSHandle<Program>> QuickFixLoader::ParseAllConstpoolWithMerge(JSThread *
const CString &recordName = item.first;
LOG_ECMA(DEBUG) << "Parse constpool: " << fileName << ":" << recordName;
vm->GetModuleManager()->HostResolveImportedModuleWithMerge(fileName, recordName);
uint32_t mainMethodIndex = jsPandaFile->GetMainMethodIndex(recordName);
if (!isNewVersion) {
PandaFileTranslator::ParseFuncAndLiteralConstPool(vm, jsPandaFile, recordName, constpool);
} else {
constpool = vm->FindOrCreateConstPool(jsPandaFile, panda_file::File::EntityId(mainMethodIndex));
}
// Generate Program for every record.
uint32_t recordIndex = jsPandaFile->GetMainMethodIndex(recordName);
auto methodLiteral = jsPandaFile->FindMethodLiteral(recordIndex);
auto methodLiteral = jsPandaFile->FindMethodLiteral(mainMethodIndex);
JSHandle<Program> program = factory->NewProgram();
if (methodLiteral == nullptr) {
program->SetMainFunction(thread, JSTaggedValue::Undefined());