mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-30 13:40:51 +00:00
!7947 Revert "fix Aot Binding"
Merge pull request !7947 from hzzhouzebin/revertFixAotBinding
This commit is contained in:
commit
ff7c022d77
@ -38,7 +38,6 @@
|
||||
#include "ecmascript/jspandafile/constpool_value.h"
|
||||
#include "ecmascript/jspandafile/js_pandafile.h"
|
||||
#include "ecmascript/jspandafile/program_object.h"
|
||||
#include "ecmascript/log.h"
|
||||
#include "ecmascript/log_wrapper.h"
|
||||
#include "ecmascript/mem/region.h"
|
||||
#include "ecmascript/message_string.h"
|
||||
@ -204,10 +203,10 @@ std::list<CString> AOTFileManager::GetPandaFiles(uint32_t aotFileInfoIndex)
|
||||
return abcFilesList;
|
||||
}
|
||||
|
||||
void AOTFileManager::BindPreloadedPandaFilesInAotFile(const std::string &moduleName)
|
||||
void AOTFileManager::BindPandaFilesInAotFile(const std::string &aotFileBaseName, const std::string &moduleName)
|
||||
{
|
||||
AnFileDataManager *anFileDataManager = AnFileDataManager::GetInstance();
|
||||
uint32_t aotFileInfoIndex = anFileDataManager->SafeGetFileInfoIndex(moduleName + FILE_EXTENSION_AN);
|
||||
uint32_t aotFileInfoIndex = anFileDataManager->SafeGetFileInfoIndex(aotFileBaseName + FILE_EXTENSION_AN);
|
||||
if (aotFileInfoIndex == INVALID_INDEX) {
|
||||
return;
|
||||
}
|
||||
@ -220,50 +219,10 @@ void AOTFileManager::BindPreloadedPandaFilesInAotFile(const std::string &moduleN
|
||||
}
|
||||
if (!abcFile->IsLoadedAOT()) {
|
||||
abcFile->SetAOTFileInfoIndex(aotFileInfoIndex);
|
||||
LOG_ECMA(INFO) << "Bind file: " << abcNormalizedName << ", aotFileInfoIndex: " << aotFileInfoIndex
|
||||
<< " in module: " << moduleName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool AOTFileManager::HasPandaFile(uint32_t aotFileInfoIndex, const CString &abcNormalizedName) const
|
||||
{
|
||||
auto aiDatumIter = aiDatum_.find(aotFileInfoIndex);
|
||||
if (aiDatumIter == aiDatum_.end()) {
|
||||
return false;
|
||||
}
|
||||
auto pandaCPIter = aiDatumIter->second.find(abcNormalizedName);
|
||||
return pandaCPIter != aiDatumIter->second.end();
|
||||
}
|
||||
|
||||
void AOTFileManager::BindPandaFileInAotFile(const std::string &aotFileBaseName, JSPandaFile *jsPandaFile) const
|
||||
{
|
||||
if (jsPandaFile->IsLoadedAOT()) {
|
||||
// already loaded.
|
||||
return;
|
||||
}
|
||||
|
||||
AnFileDataManager *anFileDataManager = AnFileDataManager::GetInstance();
|
||||
if (!anFileDataManager->IsEnable()) {
|
||||
return;
|
||||
}
|
||||
uint32_t aotFileInfoIndex = anFileDataManager->SafeGetFileInfoIndex(aotFileBaseName + FILE_EXTENSION_AN);
|
||||
if (aotFileInfoIndex == INVALID_INDEX) {
|
||||
LOG_ECMA(WARN) << "Bind panda file to AOT failed. AOT file not found for " << aotFileBaseName;
|
||||
return;
|
||||
}
|
||||
CString abcNormalizedName(jsPandaFile->GetNormalizedFileDesc());
|
||||
if (!HasPandaFile(aotFileInfoIndex, abcNormalizedName)) {
|
||||
// not existed in an file.
|
||||
LOG_ECMA(WARN) << "Bind panda file to AOT failed. " << abcNormalizedName << " not found for "
|
||||
<< aotFileBaseName;
|
||||
return;
|
||||
}
|
||||
jsPandaFile->SetAOTFileInfoIndex(aotFileInfoIndex);
|
||||
LOG_ECMA(INFO) << "Bind file: " << abcNormalizedName << ", aotFileInfoIndex: " << aotFileInfoIndex
|
||||
<< " in aotFileBaseName: " << aotFileBaseName;
|
||||
}
|
||||
|
||||
uint32_t AOTFileManager::GetAnFileIndex(const JSPandaFile *jsPandaFile) const
|
||||
{
|
||||
AnFileDataManager *anFileDataManager = AnFileDataManager::GetInstance();
|
||||
|
@ -209,9 +209,7 @@ public:
|
||||
uint32_t GetFileIndex(uint32_t anFileInfoIndex, CString abcNormalizedName) const;
|
||||
std::list<CString> GetPandaFiles(uint32_t aotFileInfoIndex);
|
||||
uint32_t GetAnFileIndex(const JSPandaFile *jsPandaFile) const;
|
||||
void BindPreloadedPandaFilesInAotFile(const std::string &moduleName);
|
||||
bool HasPandaFile(uint32_t aotFileInfoIndex, const CString &abcNormalizedName) const;
|
||||
void BindPandaFileInAotFile(const std::string &aotFileBaseName, JSPandaFile *jsPandaFile) const;
|
||||
void BindPandaFilesInAotFile(const std::string &aotFileBaseName, const std::string &moduleName);
|
||||
void SetAOTMainFuncEntry(JSHandle<JSFunction> mainFunc, const JSPandaFile *jsPandaFile,
|
||||
std::string_view entryPoint);
|
||||
void SetAOTFuncEntry(const JSPandaFile *jsPandaFile, JSFunction *function,
|
||||
|
@ -22,7 +22,7 @@ namespace panda::ecmascript::kungfu {
|
||||
std::string IRModule::GetFuncName(const MethodLiteral *methodLiteral,
|
||||
const JSPandaFile *jsPandaFile)
|
||||
{
|
||||
std::string fileName(jsPandaFile->GetJSPandaFileDesc());
|
||||
std::string fileName = jsPandaFile->GetFileName();
|
||||
std::string name = MethodLiteral::GetMethodName(jsPandaFile, methodLiteral->GetMethodId());
|
||||
auto methodId = methodLiteral->GetMethodId();
|
||||
DebugInfoExtractor *debugExtractor =
|
||||
|
@ -39,7 +39,7 @@ bool JitPassManager::Compile(JSHandle<ProfileTypeInfo> &profileTypeInfo,
|
||||
const uint8_t *pcStart = compilationEnv_->GetMethodPcStart();
|
||||
const panda_file::File::Header *header = jsPandaFile->GetPandaFile()->GetHeader();
|
||||
ApEntityId abcId = compilationEnv_->GetMethodAbcId();
|
||||
std::string fileName(jsPandaFile->GetJSPandaFileDesc());
|
||||
std::string fileName = jsPandaFile->GetFileName();
|
||||
|
||||
collector_ = new BytecodeInfoCollector(compilationEnv_, const_cast<JSPandaFile*>(jsPandaFile),
|
||||
profilerDecoder_);
|
||||
|
@ -162,7 +162,7 @@ void TSInlineLowering::TryInline(InlineTypeInfoAccessor &info, ChunkQueue<Inline
|
||||
auto jsPandaFile = ctx_->GetJSPandaFile();
|
||||
const std::string methodName(
|
||||
MethodLiteral::GetMethodName(jsPandaFile, inlinedMethod->GetMethodId()));
|
||||
std::string fileName(jsPandaFile->GetJSPandaFileDesc());
|
||||
std::string fileName = jsPandaFile->GetFileName();
|
||||
const std::string recordName(MethodLiteral::GetRecordName(jsPandaFile, inlinedMethod->GetMethodId()));
|
||||
std::string fullName = methodName + "@" + recordName + "@" + fileName;
|
||||
LOG_COMPILER(INFO) << "";
|
||||
@ -214,7 +214,7 @@ void TSInlineLowering::InlineCall(MethodInfo &methodInfo, MethodPcInfo &methodPC
|
||||
CString recordName = MethodLiteral::GetRecordName(jsPandaFile, method->GetMethodId());
|
||||
bool hasTyps = jsPandaFile->HasTSTypes(recordName);
|
||||
const std::string methodName(MethodLiteral::GetMethodName(jsPandaFile, method->GetMethodId()));
|
||||
std::string fileName(jsPandaFile->GetJSPandaFileDesc());
|
||||
std::string fileName = jsPandaFile->GetFileName();
|
||||
std::string fullName = methodName + "@" + std::string(recordName) + "@" + fileName;
|
||||
|
||||
circuit_->InitRoot();
|
||||
|
@ -162,7 +162,7 @@ const JSPandaFile* FrameHandler::GetJSPandaFile() const
|
||||
std::string FrameHandler::GetFileName() const
|
||||
{
|
||||
auto pandaFile = GetJSPandaFile();
|
||||
return pandaFile->GetJSPandaFileDesc().c_str();
|
||||
return pandaFile->GetFileName();
|
||||
}
|
||||
|
||||
uint32_t FrameHandler::GetAbcId() const
|
||||
|
@ -118,6 +118,11 @@ public:
|
||||
return pf_;
|
||||
}
|
||||
|
||||
std::string GetFileName() const
|
||||
{
|
||||
return pf_->GetFilename();
|
||||
}
|
||||
|
||||
const char *GetMethodName(EntityId methodId);
|
||||
const char *GetCpuProfilerMethodName(EntityId methodId);
|
||||
CString GetRecordName(EntityId methodId);
|
||||
|
@ -109,12 +109,14 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::ExecuteFromFile(JSThread *thr
|
||||
}
|
||||
JSHandle<SourceTextModule> module = JSHandle<SourceTextModule>::Cast(moduleRecord);
|
||||
module->SetStatus(ModuleStatus::INSTANTIATED);
|
||||
BindPandaFilesForAot(vm, jsPandaFile.get());
|
||||
SourceTextModule::Evaluate(thread, module, nullptr, 0, executeFromJob);
|
||||
if (thread->HasPendingException()) {
|
||||
return Unexpected(false);
|
||||
}
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
BindPandaFilesForAot(vm, jsPandaFile.get());
|
||||
return JSPandaFileExecutor::Execute(thread, jsPandaFile.get(), entry.c_str(), executeFromJob);
|
||||
}
|
||||
|
||||
@ -169,6 +171,7 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::ExecuteFromBuffer(JSThread *t
|
||||
#endif
|
||||
}
|
||||
auto vm = thread->GetEcmaVM();
|
||||
BindPandaFilesForAot(vm, jsPandaFile.get());
|
||||
|
||||
CString entry = entryPoint.data();
|
||||
if (vm->IsNormalizedOhmUrlPack()) {
|
||||
@ -218,6 +221,7 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::ExecuteModuleBuffer(
|
||||
LOG_FULL(FATAL) << "Load current file's panda file failed. Current file is " << name;
|
||||
#endif
|
||||
}
|
||||
BindPandaFilesForAot(vm, jsPandaFile.get());
|
||||
|
||||
bool isBundle = jsPandaFile->IsBundlePack();
|
||||
|
||||
@ -299,24 +303,8 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::Execute(JSThread *thread, con
|
||||
return result;
|
||||
}
|
||||
|
||||
void JSPandaFileExecutor::BindPreloadedPandaFilesToAOT(EcmaVM *vm, const std::string &moduleName)
|
||||
void JSPandaFileExecutor::BindPandaFilesForAot(EcmaVM *vm, [[maybe_unused]] JSPandaFile *jsPandaFile)
|
||||
{
|
||||
ASSERT(vm->GetJSThread()->IsMainThread());
|
||||
if (!vm->GetJSOptions().GetEnableAsmInterpreter()) {
|
||||
return;
|
||||
}
|
||||
// run not via command line
|
||||
if (vm->GetJSOptions().WasAOTOutputFileSet()) {
|
||||
return;
|
||||
}
|
||||
ASSERT(!moduleName.empty());
|
||||
// bind pandafiles loaded in appspawn
|
||||
vm->GetAOTFileManager()->BindPreloadedPandaFilesInAotFile(moduleName);
|
||||
}
|
||||
|
||||
void JSPandaFileExecutor::BindPandaFileToAot(JSPandaFile *jsPandaFile)
|
||||
{
|
||||
EcmaVM *vm = Runtime::GetInstance()->GetMainThread()->GetEcmaVM();
|
||||
if (vm->GetJSOptions().GetEnableAsmInterpreter()) {
|
||||
std::string aotFileBaseName(vm->GetModuleName());
|
||||
auto *aotFM = vm->GetAOTFileManager();
|
||||
@ -324,7 +312,7 @@ void JSPandaFileExecutor::BindPandaFileToAot(JSPandaFile *jsPandaFile)
|
||||
std::string aotFilename = vm->GetJSOptions().GetAOTOutputFile();
|
||||
aotFileBaseName = JSFilePath::GetBaseName(aotFilename);
|
||||
}
|
||||
aotFM->BindPandaFileInAotFile(aotFileBaseName, jsPandaFile);
|
||||
aotFM->BindPandaFilesInAotFile(aotFileBaseName, aotFileBaseName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,6 +334,7 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::ExecuteFromBufferSecure(JSThr
|
||||
#endif
|
||||
}
|
||||
auto vm = thread->GetEcmaVM();
|
||||
BindPandaFilesForAot(vm, jsPandaFile.get());
|
||||
|
||||
CString entry = entryPoint.data();
|
||||
if (vm->IsNormalizedOhmUrlPack()) {
|
||||
@ -420,6 +409,7 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::ExecuteModuleBufferSecure(JST
|
||||
LOG_FULL(FATAL) << "Load current file's panda file failed. Current file is " << name;
|
||||
#endif
|
||||
}
|
||||
BindPandaFilesForAot(vm, jsPandaFile.get());
|
||||
|
||||
// realEntry is used to record the original record, which is easy to throw when there are exceptions
|
||||
const CString realEntry = entry;
|
||||
@ -515,6 +505,7 @@ Expected<JSTaggedValue, bool> JSPandaFileExecutor::LazyExecuteModule(
|
||||
SourceTextModule::Instantiate(thread, moduleRecord);
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, Unexpected(false));
|
||||
JSHandle<SourceTextModule> module = JSHandle<SourceTextModule>::Cast(moduleRecord);
|
||||
BindPandaFilesForAot(thread->GetEcmaVM(), jsPandaFile.get());
|
||||
SourceTextModule::Evaluate(thread, module, nullptr, 0);
|
||||
return JSTaggedValue::Undefined();
|
||||
}
|
||||
|
@ -53,8 +53,7 @@ public:
|
||||
bool executeFromJob = false);
|
||||
static Expected<JSTaggedValue, bool> Execute(JSThread *thread, const JSPandaFile *jsPandaFile,
|
||||
std::string_view entryPoint, bool executeFromJob = false);
|
||||
static void BindPreloadedPandaFilesToAOT(EcmaVM *vm, const std::string &moduleName);
|
||||
static void BindPandaFileToAot(JSPandaFile *jsPandaFile);
|
||||
static void BindPandaFilesForAot(EcmaVM *vm, JSPandaFile *jsPandaFile);
|
||||
static Expected<JSTaggedValue, bool> ExecuteSpecialModule(JSThread *thread, const CString &recordName,
|
||||
const CString &filename, const JSPandaFile *jsPandaFile,
|
||||
const JSRecordInfo &recordInfo);
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "ecmascript/compiler/aot_file/aot_file_manager.h"
|
||||
#include "ecmascript/js_file_path.h"
|
||||
#include "ecmascript/jspandafile/js_pandafile.h"
|
||||
#include "ecmascript/jspandafile/js_pandafile_executor.h"
|
||||
#include "ecmascript/jspandafile/program_object.h"
|
||||
#include "ecmascript/module/module_path_helper.h"
|
||||
#include "ecmascript/module/module_message_helper.h"
|
||||
@ -338,7 +337,6 @@ void JSPandaFileManager::AddJSPandaFile(const std::shared_ptr<JSPandaFile> &jsPa
|
||||
}
|
||||
|
||||
loadedJSPandaFiles_[filename] = std::move(jsPandaFile);
|
||||
JSPandaFileExecutor::BindPandaFileToAot(jsPandaFile.get());
|
||||
LOG_ECMA(DEBUG) << "add file: " << filename;
|
||||
}
|
||||
|
||||
|
@ -4444,10 +4444,7 @@ void JSNApi::LoadAotFile(EcmaVM *vm, const std::string &moduleName)
|
||||
|
||||
std::string aotFileName;
|
||||
LoadAotFileInternal(vm, moduleName, aotFileName);
|
||||
if (!thread->GetCurrentEcmaContext()->LoadAOTFiles(aotFileName)) {
|
||||
return;
|
||||
}
|
||||
ecmascript::JSPandaFileExecutor::BindPreloadedPandaFilesToAOT(vm, moduleName);
|
||||
thread->GetCurrentEcmaContext()->LoadAOTFiles(aotFileName);
|
||||
}
|
||||
|
||||
#if defined(ANDROID_PLATFORM)
|
||||
|
Loading…
Reference in New Issue
Block a user