From 67866b9fa8590b1e131b56176948cde3f9d59088 Mon Sep 17 00:00:00 2001 From: lijincheng Date: Wed, 17 May 2023 19:06:45 +0800 Subject: [PATCH] Bugfix for empty entrypoint in aot ConcatFileName 1.When in the aot compilation phase, clear strong validation for empty entrypoint in ConcatFileName. It's permissible in compilation phase. Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I73Z3Z Signed-off-by: lijincheng --- ecmascript/base/path_helper.h | 2 +- ecmascript/module/js_module_manager.cpp | 5 ++++- ecmascript/ts_types/ts_type_parser.cpp | 7 ++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ecmascript/base/path_helper.h b/ecmascript/base/path_helper.h index e89614bd8d..777f4dad13 100644 --- a/ecmascript/base/path_helper.h +++ b/ecmascript/base/path_helper.h @@ -541,7 +541,7 @@ public: } else { entryPoint = ParseThirdPartyPackage(jsPandaFile, recordName, requestName); } - if (entryPoint.empty()) { + if (entryPoint.empty() && thread->GetEcmaVM()->EnableReportModuleResolvingFailure()) { LOG_ECMA(ERROR) << "Failed to resolve the requested entryPoint. baseFileName : '" << baseFileName << "'. RecordName : '" << recordName << "'. RequestName : '" << requestName << "'."; ObjectFactory *factory = thread->GetEcmaVM()->GetFactory(); diff --git a/ecmascript/module/js_module_manager.cpp b/ecmascript/module/js_module_manager.cpp index 83b75b9c1b..37555f80e1 100644 --- a/ecmascript/module/js_module_manager.cpp +++ b/ecmascript/module/js_module_manager.cpp @@ -321,9 +321,12 @@ bool ModuleManager::IsImportedModuleLoaded(JSTaggedValue referencing) bool ModuleManager::SkipDefaultBundleFile(const CString &moduleFileName) const { + // relative file path like "../../xxxx" can't be loaded rightly in aot compilation phase + const char relativeFilePath[] = ".."; // just to skip misunderstanding error log in LoadJSPandaFile when we ignore Module Resolving Failure. return !vm_->EnableReportModuleResolvingFailure() && - base::StringHelper::StringStartWith(moduleFileName, PathHelper::BUNDLE_INSTALL_PATH); + (base::StringHelper::StringStartWith(moduleFileName, PathHelper::BUNDLE_INSTALL_PATH) || + base::StringHelper::StringStartWith(moduleFileName, relativeFilePath)); } JSHandle ModuleManager::ResolveModuleInMergedABC(JSThread *thread, const JSPandaFile *jsPandaFile, diff --git a/ecmascript/ts_types/ts_type_parser.cpp b/ecmascript/ts_types/ts_type_parser.cpp index 0012788fd2..5879f3250c 100644 --- a/ecmascript/ts_types/ts_type_parser.cpp +++ b/ecmascript/ts_types/ts_type_parser.cpp @@ -150,9 +150,10 @@ GlobalTSTypeRef TSTypeParser::ResolveImportType(const JSPandaFile *jsPandaFile, CString baseFileName = jsPandaFile->GetJSPandaFileDesc(); CString entryPoint = base::PathHelper::ConcatFileNameWithMerge(thread_, jsPandaFile, baseFileName, recordName, cstringRelativePath); - ASSERT_PRINT(!entryPoint.empty(), - "EntryPoint is empty. Please check whether concating file name is correct or " - "whether the module request recorded in the import-type literal is correct."); + if (entryPoint.empty()) { + LOG_COMPILER(DEBUG) << "EntryPoint is empty. Please check whether concating file name is correct or " + "whether the module request recorded in the import-type literal is correct."; + } // skip files without type information if (UNLIKELY(!jsPandaFile->HasTypeSummaryOffset(entryPoint))) { return GetAndStoreGT(jsPandaFile, typeId, recordName);