From f3f5ac2a87d511c24ad427d54a8d9c1d1465954c Mon Sep 17 00:00:00 2001 From: jiachongchong Date: Thu, 11 Sep 2025 11:09:34 +0800 Subject: [PATCH] The entry file does not support shared modules Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICXGQ9 Signed-off-by: jiachongchong Change-Id: I03e3c5b15a9bb684ec66c36ce8bad77063998e5e --- .../jspandafile/js_pandafile_executor.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/ecmascript/jspandafile/js_pandafile_executor.cpp b/ecmascript/jspandafile/js_pandafile_executor.cpp index 88ac0ef92a..99e95457d3 100644 --- a/ecmascript/jspandafile/js_pandafile_executor.cpp +++ b/ecmascript/jspandafile/js_pandafile_executor.cpp @@ -62,10 +62,13 @@ Expected JSPandaFileExecutor::ExecuteFromFile(JSThread *thr ThreadManagedScope managedScope(thread); JSHandle moduleRecord = ModuleResolver::HostResolveImportedModule(thread, name, entry, jsPandaFile.get(), executeType); + JSHandle module = JSHandle::Cast(moduleRecord); + if (SourceTextModule::IsSharedModule(module)) { + LOG_ECMA(ERROR) << "Cannot load module '" + entry + "' , the entry file does not support shared modules"; + } RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, Unexpected(false)); SourceTextModule::Instantiate(thread, moduleRecord, executeType); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, Unexpected(false)); - JSHandle module = JSHandle::Cast(moduleRecord); module->SetStatus(ModuleStatus::INSTANTIATED); SourceTextModule::Evaluate(thread, module, nullptr, 0, executeType); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, Unexpected(false)); @@ -200,11 +203,14 @@ Expected JSPandaFileExecutor::CommonExecuteBuffer(JSThread moduleManager->SetExecuteMode(ModuleExecuteMode::ExecuteBufferMode); JSHandle moduleRecord = ModuleResolver::HostResolveImportedModule(thread, filename, entry, buffer, size, executeType); + JSHandle module = JSHandle::Cast(moduleRecord); + if (SourceTextModule::IsSharedModule(module)) { + LOG_ECMA(ERROR) << "Cannot load module '" + entry + "' , the entry file does not support shared modules"; + } RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, Unexpected(false)); SourceTextModule::Instantiate(thread, moduleRecord, executeType); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, Unexpected(false)); - JSHandle module = JSHandle::Cast(moduleRecord); module->SetStatus(ModuleStatus::INSTANTIATED); SourceTextModule::Evaluate(thread, module, buffer, size, executeType); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, Unexpected(false)); @@ -305,10 +311,13 @@ Expected JSPandaFileExecutor::CommonExecuteBuffer(JSThread moduleManager->SetExecuteMode(ModuleExecuteMode::ExecuteBufferMode); JSHandle moduleRecord = ModuleResolver::HostResolveImportedModule(thread, filename, entry, jsPandaFile, ExecuteTypes::STATIC); + JSHandle module = JSHandle::Cast(moduleRecord); + if (SourceTextModule::IsSharedModule(module)) { + LOG_ECMA(ERROR) << "Cannot load module '" + entry + "' , the entry file does not support shared modules"; + } RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, Unexpected(false)); SourceTextModule::Instantiate(thread, moduleRecord); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, Unexpected(false)); - JSHandle module = JSHandle::Cast(moduleRecord); module->SetStatus(ModuleStatus::INSTANTIATED); //After the module is instantiated, stop preloading so and parallel abc loading thread->GetEcmaVM()->StopPreLoadSoOrAbc(); @@ -495,10 +504,13 @@ int JSPandaFileExecutor::ExecuteAbcFileWithSingletonPatternFlag(JSThread *thread ASSERT(!jsPandaFile->IsBundlePack()); JSHandle moduleRecord = ModuleResolver::HostResolveImportedModule(thread, abcFilePath, entryPoint, jsPandaFile.get()); + JSHandle module = JSHandle::Cast(moduleRecord); + if (SourceTextModule::IsSharedModule(module)) { + LOG_ECMA(ERROR) << "Cannot load module '" + entry + "' , the entry file does not support shared modules"; + } RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, ROUTE_INTERNAL_ERROR); SourceTextModule::Instantiate(thread, moduleRecord); RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, ROUTE_INTERNAL_ERROR); - JSHandle module = JSHandle::Cast(moduleRecord); if (!isSingletonPattern) { LOG_ECMA(INFO) << "Route jump to non-singleton page: " << entryPoint; module->SetStatus(ModuleStatus::INSTANTIATED); -- Gitee