mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
Optimize source_text_module field to cstirng
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IADOXR Signed-off-by: chenlincl3 <chenlin201@huawei.com>
This commit is contained in:
parent
e513d62d79
commit
a1e281d7fb
@ -984,10 +984,10 @@ JSTaggedValue BuiltinsGlobal::GetCurrentModuleName(EcmaRuntimeCallInfo *msg)
|
||||
JSThread *thread = msg->GetThread();
|
||||
BUILTINS_API_TRACE(thread, Global, GetCurrentModuleName);
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
std::pair<JSTaggedValue, JSTaggedValue> moduleInfo = EcmaInterpreter::GetCurrentEntryPoint(thread);
|
||||
std::pair<CString, CString> moduleInfo = EcmaInterpreter::GetCurrentEntryPoint(thread);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
EcmaVM *vm = thread->GetEcmaVM();
|
||||
CString recordName = ConvertToString(moduleInfo.first);
|
||||
CString recordName = moduleInfo.first;
|
||||
CString moduleName;
|
||||
if (vm->IsNormalizedOhmUrlPack()) {
|
||||
moduleName = ModulePathHelper::GetModuleNameWithNormalizedName(recordName);
|
||||
@ -1005,10 +1005,10 @@ JSTaggedValue BuiltinsGlobal::GetCurrentBundleName(EcmaRuntimeCallInfo *msg)
|
||||
JSThread *thread = msg->GetThread();
|
||||
BUILTINS_API_TRACE(thread, Global, GetCurrentBundleName);
|
||||
[[maybe_unused]] EcmaHandleScope handleScope(thread);
|
||||
std::pair<JSTaggedValue, JSTaggedValue> moduleInfo = EcmaInterpreter::GetCurrentEntryPoint(thread);
|
||||
std::pair<CString, CString> moduleInfo = EcmaInterpreter::GetCurrentEntryPoint(thread);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
EcmaVM *vm = thread->GetEcmaVM();
|
||||
CString recordName = ConvertToString(moduleInfo.first);
|
||||
CString recordName = moduleInfo.first;
|
||||
CString bundleName = ModulePathHelper::GetBundleNameWithRecordName(vm, recordName);
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<EcmaString> result = factory->NewFromUtf8(bundleName.c_str());
|
||||
|
@ -764,8 +764,8 @@ void DebuggerApi::GetIndirectExportVariables(const EcmaVM *ecmaVm, Local<ObjectR
|
||||
JSHandle<JSTaggedValue> moduleRequest(thread, ee->GetModuleRequest());
|
||||
JSHandle<JSTaggedValue> importModule;
|
||||
JSHandle<SourceTextModule> module = JSHandle<SourceTextModule>::Cast(currentModule);
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
if (moduleRecordName.empty()) {
|
||||
importModule = SourceTextModule::HostResolveImportedModule(thread, module, moduleRequest);
|
||||
} else {
|
||||
importModule = SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, moduleRequest);
|
||||
@ -805,8 +805,8 @@ void DebuggerApi::GetImportVariables(const EcmaVM *ecmaVm, Local<ObjectRef> &mod
|
||||
JSHandle<JSTaggedValue> moduleRequest(thread, ee->GetModuleRequest());
|
||||
JSHandle<JSTaggedValue> importModule;
|
||||
JSHandle<SourceTextModule> module = JSHandle<SourceTextModule>::Cast(currentModule);
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
if (moduleRecordName.empty()) {
|
||||
importModule = SourceTextModule::HostResolveImportedModule(thread, module, moduleRequest);
|
||||
} else {
|
||||
importModule = SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, moduleRequest);
|
||||
|
@ -3699,10 +3699,10 @@ void SourceTextModule::Dump(std::ostream &os) const
|
||||
GetNamespace().Dump(os);
|
||||
os << "\n";
|
||||
os << " - EcmaModuleFilename: ";
|
||||
GetEcmaModuleFilename().Dump(os);
|
||||
os << GetEcmaModuleFilenameString();
|
||||
os << "\n";
|
||||
os << " - EcmaModuleRecordName: ";
|
||||
GetEcmaModuleRecordName().Dump(os);
|
||||
os << GetEcmaModuleRecordNameString();
|
||||
os << "\n";
|
||||
os << " - RequestedModules: ";
|
||||
GetRequestedModules().Dump(os);
|
||||
@ -5940,8 +5940,6 @@ void SourceTextModule::DumpForSnapshot(std::vector<Reference> &vec) const
|
||||
vec.reserve(vec.size() + NUM_OF_ITEMS);
|
||||
vec.emplace_back(CString("Environment"), GetEnvironment());
|
||||
vec.emplace_back(CString("Namespace"), GetNamespace());
|
||||
vec.emplace_back(CString("EcmaModuleFilename"), GetEcmaModuleFilename());
|
||||
vec.emplace_back(CString("EcmaModuleRecordName"), GetEcmaModuleRecordName());
|
||||
vec.emplace_back(CString("RequestedModules"), GetRequestedModules());
|
||||
vec.emplace_back(CString("ImportEntries"), GetImportEntries());
|
||||
vec.emplace_back(CString("LocalExportEntries"), GetLocalExportEntries());
|
||||
|
@ -945,10 +945,10 @@ void EcmaVM::ResumeWorkerVm(uint32_t tid)
|
||||
*/
|
||||
std::pair<std::string, std::string> EcmaVM::GetCurrentModuleInfo(bool needRecordName)
|
||||
{
|
||||
std::pair<JSTaggedValue, JSTaggedValue> moduleInfo = EcmaInterpreter::GetCurrentEntryPoint(thread_);
|
||||
std::pair<CString, CString> moduleInfo = EcmaInterpreter::GetCurrentEntryPoint(thread_);
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread_, std::make_pair("", ""));
|
||||
CString recordName = ModulePathHelper::Utf8ConvertToString(moduleInfo.first);
|
||||
CString fileName = ModulePathHelper::Utf8ConvertToString(moduleInfo.second);
|
||||
CString recordName = moduleInfo.first;
|
||||
CString fileName = moduleInfo.second;
|
||||
LOG_FULL(INFO) << "Current recordName is " << recordName <<", current fileName is " << fileName;
|
||||
if (needRecordName) {
|
||||
if (fileName.length() > ModulePathHelper::BUNDLE_INSTALL_PATH_LEN &&
|
||||
|
@ -969,11 +969,11 @@ const JSPandaFile *EcmaInterpreter::GetNativeCallPandafile(JSThread *thread)
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
std::pair<JSTaggedValue, JSTaggedValue> EcmaInterpreter::GetCurrentEntryPoint(JSThread *thread)
|
||||
std::pair<CString, CString> EcmaInterpreter::GetCurrentEntryPoint(JSThread *thread)
|
||||
{
|
||||
FrameHandler frameHandler(thread);
|
||||
JSMutableHandle<JSTaggedValue> recordName(thread, thread->GlobalConstants()->GetUndefined());
|
||||
JSMutableHandle<JSTaggedValue> fileName(thread, thread->GlobalConstants()->GetUndefined());
|
||||
CString recordName;
|
||||
CString fileName;
|
||||
|
||||
for (; frameHandler.HasFrame(); frameHandler.PrevJSFrame()) {
|
||||
if (frameHandler.IsEntryFrame()) {
|
||||
@ -989,18 +989,17 @@ std::pair<JSTaggedValue, JSTaggedValue> EcmaInterpreter::GetCurrentEntryPoint(JS
|
||||
|
||||
if (module->IsSourceTextModule()) {
|
||||
SourceTextModule *sourceTextModule = SourceTextModule::Cast(module->GetTaggedObject());
|
||||
recordName.Update(sourceTextModule->GetEcmaModuleRecordName());
|
||||
fileName.Update(sourceTextModule->GetEcmaModuleFilename());
|
||||
recordName = sourceTextModule->GetEcmaModuleRecordNameString();
|
||||
fileName = sourceTextModule->GetEcmaModuleFilenameString();
|
||||
} else if (module->IsString()) {
|
||||
recordName.Update(module);
|
||||
recordName = ConvertToString(module.GetTaggedValue());
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
return std::make_pair(recordName.GetTaggedValue(), fileName.GetTaggedValue());
|
||||
return std::make_pair(recordName, fileName);
|
||||
}
|
||||
CString msg = "Unable to get recordName and fileName due to failure in getting current entry point.";
|
||||
THROW_REFERENCE_ERROR_AND_RETURN(thread, msg.c_str(), std::make_pair(JSTaggedValue::Undefined(),
|
||||
JSTaggedValue::Undefined()));
|
||||
THROW_REFERENCE_ERROR_AND_RETURN(thread, msg.c_str(), std::make_pair(recordName, fileName));
|
||||
}
|
||||
|
||||
void EcmaInterpreter::UpdateProfileTypeInfoCellToFunction(JSThread *thread, JSHandle<JSFunction> &function,
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
static void MethodEntry(JSThread *thread);
|
||||
static void MethodExit(JSThread *thread);
|
||||
static const JSPandaFile *GetNativeCallPandafile(JSThread *thread);
|
||||
static std::pair<JSTaggedValue, JSTaggedValue> GetCurrentEntryPoint(JSThread *thread);
|
||||
static std::pair<CString, CString> GetCurrentEntryPoint(JSThread *thread);
|
||||
static JSTaggedValue GetFunction(JSTaggedType *sp);
|
||||
static JSTaggedValue GetNewTarget(JSTaggedType *sp);
|
||||
static JSTaggedValue GetThis(JSTaggedType *sp);
|
||||
|
@ -924,17 +924,17 @@ JSHandle<JSHClass> JSFunction::GetOrCreateDerivedJSHClass(JSThread *thread, JSHa
|
||||
return newJSHClass;
|
||||
}
|
||||
|
||||
JSTaggedValue JSFunction::GetRecordName() const
|
||||
CString JSFunction::GetRecordName() const
|
||||
{
|
||||
JSTaggedValue module = GetModule();
|
||||
if (module.IsSourceTextModule()) {
|
||||
return SourceTextModule::GetModuleName(module);
|
||||
}
|
||||
if (module.IsString()) {
|
||||
return module;
|
||||
return ConvertToString(module);
|
||||
}
|
||||
LOG_INTERPRETER(DEBUG) << "record name is undefined";
|
||||
return JSTaggedValue::Hole();
|
||||
return "";
|
||||
}
|
||||
|
||||
// Those interface below is discarded
|
||||
|
@ -312,7 +312,7 @@ public:
|
||||
|
||||
JSTaggedValue GetFunctionExtraInfo() const;
|
||||
JSTaggedValue GetNativeFunctionExtraInfo() const;
|
||||
JSTaggedValue GetRecordName() const;
|
||||
CString GetRecordName() const;
|
||||
JSTaggedValue GetProfileTypeInfo() const
|
||||
{
|
||||
JSTaggedValue raw = GetRawProfileTypeInfo();
|
||||
|
@ -47,8 +47,7 @@ void ModuleDeregister::FreeModuleRecord([[maybe_unused]] void *env, void *pointe
|
||||
}
|
||||
JSHandle<SourceTextModule> module(thread, SourceTextModule::Cast(moduleVal.GetTaggedObject()));
|
||||
LoadingTypes type = module->GetLoadingTypes();
|
||||
JSTaggedValue moduleRecordName = SourceTextModule::GetModuleName(module.GetTaggedValue());
|
||||
CString recordNameStr = ConvertToString(moduleRecordName);
|
||||
CString recordNameStr = SourceTextModule::GetModuleName(module.GetTaggedValue());
|
||||
if (type != LoadingTypes::DYNAMITC_MODULE) {
|
||||
LOG_FULL(INFO) << "free stable module's ModuleNameSpace" << recordNameStr;
|
||||
}
|
||||
@ -87,8 +86,7 @@ void ModuleDeregister::ReviseLoadedModuleCount(JSThread *thread, const CString &
|
||||
|
||||
void ModuleDeregister::RemoveModule(JSThread *thread, JSHandle<SourceTextModule> module)
|
||||
{
|
||||
JSTaggedValue moduleRecordName = SourceTextModule::GetModuleName(module.GetTaggedValue());
|
||||
CString recordName = ModulePathHelper::Utf8ConvertToString(moduleRecordName);
|
||||
CString recordName = SourceTextModule::GetModuleName(module.GetTaggedValue());
|
||||
ModuleManager *moduleManager = thread->GetCurrentEcmaContext()->GetModuleManager();
|
||||
if (!thread->GetEcmaVM()->IsWorkerThread() &&
|
||||
(module->GetTypes() == ModuleTypes::APP_MODULE || module->GetTypes() == ModuleTypes::OHOS_MODULE)) {
|
||||
@ -111,21 +109,20 @@ void ModuleDeregister::IncreaseRegisterCounts(JSThread *thread, JSHandle<SourceT
|
||||
for (size_t idx = 0; idx < requestedModulesLen; idx++) {
|
||||
required.Update(requestedModules->Get(idx));
|
||||
JSMutableHandle<SourceTextModule> requiredModule(thread, thread->GlobalConstants()->GetUndefined());
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
const CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
CString moduleName;
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
if (moduleRecordName.empty()) {
|
||||
JSHandle<JSTaggedValue> requiredVal =
|
||||
SourceTextModule::HostResolveImportedModule(thread, module, required);
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
requiredModule.Update(JSHandle<SourceTextModule>::Cast(requiredVal));
|
||||
moduleName = ConvertToString(requiredModule->GetEcmaModuleFilename());
|
||||
moduleName = requiredModule->GetEcmaModuleFilenameString();
|
||||
} else {
|
||||
ASSERT(moduleRecordName.IsString());
|
||||
JSHandle<JSTaggedValue> requiredVal =
|
||||
SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, required);
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
requiredModule.Update(JSHandle<SourceTextModule>::Cast(requiredVal));
|
||||
moduleName = ConvertToString(requiredModule->GetEcmaModuleRecordName());
|
||||
moduleName = requiredModule->GetEcmaModuleRecordNameString();
|
||||
}
|
||||
if (increaseModule.find(moduleName) != increaseModule.end()) {
|
||||
LOG_FULL(DEBUG) << "Find module cyclical loading, stop increasing.";
|
||||
@ -161,21 +158,20 @@ void ModuleDeregister::DecreaseRegisterCounts(JSThread *thread, JSHandle<SourceT
|
||||
for (size_t idx = 0; idx < requestedModulesLen; idx++) {
|
||||
required.Update(requestedModules->Get(idx));
|
||||
JSMutableHandle<SourceTextModule> requiredModule(thread, thread->GlobalConstants()->GetUndefined());
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
const CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
CString moduleName;
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
if (moduleRecordName.empty()) {
|
||||
JSHandle<JSTaggedValue> requiredVal =
|
||||
SourceTextModule::HostResolveImportedModule(thread, module, required);
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
requiredModule.Update(JSHandle<SourceTextModule>::Cast(requiredVal));
|
||||
moduleName = ConvertToString(requiredModule->GetEcmaModuleFilename());
|
||||
moduleName = requiredModule->GetEcmaModuleFilenameString();
|
||||
} else {
|
||||
ASSERT(moduleRecordName.IsString());
|
||||
JSHandle<JSTaggedValue> requiredVal =
|
||||
SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, required);
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
requiredModule.Update(JSHandle<SourceTextModule>::Cast(requiredVal));
|
||||
moduleName = ConvertToString(requiredModule->GetEcmaModuleRecordName());
|
||||
moduleName = requiredModule->GetEcmaModuleRecordNameString();
|
||||
}
|
||||
if (decreaseModule.find(moduleName) != decreaseModule.end()) {
|
||||
LOG_FULL(DEBUG) << "Find module cyclical loading, stop increasing.";
|
||||
@ -200,8 +196,7 @@ void ModuleDeregister::DecreaseRegisterCounts(JSThread *thread, JSHandle<SourceT
|
||||
|
||||
uint16_t registerNum = num - 1;
|
||||
if (registerNum == 0) {
|
||||
LOG_FULL(INFO) << "try to remove module " <<
|
||||
ConvertToString(SourceTextModule::GetModuleName(module.GetTaggedValue())).c_str();
|
||||
LOG_FULL(INFO) << "try to remove module " << SourceTextModule::GetModuleName(module.GetTaggedValue());
|
||||
RemoveModule(thread, module);
|
||||
}
|
||||
module->SetRegisterCounts(registerNum);
|
||||
|
@ -50,8 +50,7 @@ JSTaggedValue ModuleManager::GetCurrentModule()
|
||||
JSTaggedValue currentFunc = frameHandler.GetFunction();
|
||||
JSTaggedValue module = JSFunction::Cast(currentFunc.GetTaggedObject())->GetModule();
|
||||
if (SourceTextModule::IsSendableFunctionModule(module)) {
|
||||
JSTaggedValue recordName = SourceTextModule::GetModuleName(module);
|
||||
CString recordNameStr = ModulePathHelper::Utf8ConvertToString(recordName);
|
||||
CString recordNameStr = SourceTextModule::GetModuleName(module);
|
||||
return HostGetImportedModule(recordNameStr).GetTaggedValue();
|
||||
}
|
||||
return module;
|
||||
@ -131,7 +130,7 @@ JSTaggedValue ModuleManager::GetModuleValueOutterInternal(int32_t index, JSTagge
|
||||
EcmaContext *context = thread->GetCurrentEcmaContext();
|
||||
if (context->GetStageOfHotReload() == StageOfHotReload::LOAD_END_EXECUTE_PATCHMAIN) {
|
||||
const JSHandle<JSTaggedValue> resolvedModuleOfHotReload =
|
||||
context->FindPatchModule(ConvertToString(module->GetEcmaModuleRecordName()));
|
||||
context->FindPatchModule(module->GetEcmaModuleRecordNameString());
|
||||
if (!resolvedModuleOfHotReload->IsHole()) {
|
||||
resolvedModule = resolvedModuleOfHotReload.GetTaggedValue();
|
||||
JSHandle<SourceTextModule> moduleOfHotReload(thread, resolvedModule);
|
||||
@ -193,7 +192,7 @@ JSTaggedValue ModuleManager::GetLazyModuleValueOutterInternal(int32_t index, JST
|
||||
EcmaContext *context = thread->GetCurrentEcmaContext();
|
||||
if (context->GetStageOfHotReload() == StageOfHotReload::LOAD_END_EXECUTE_PATCHMAIN) {
|
||||
const JSHandle<JSTaggedValue> resolvedModuleOfHotReload =
|
||||
context->FindPatchModule(ConvertToString(module->GetEcmaModuleRecordName()));
|
||||
context->FindPatchModule(module->GetEcmaModuleRecordNameString());
|
||||
if (!resolvedModuleOfHotReload->IsHole()) {
|
||||
resolvedModule = resolvedModuleOfHotReload.GetTaggedValue();
|
||||
JSHandle<SourceTextModule> moduleOfHotReload(thread, resolvedModule);
|
||||
@ -316,8 +315,9 @@ JSTaggedValue ModuleManager::GetModuleValueOutterInternal(JSTaggedValue key, JST
|
||||
ASSERT(resolvedModule.IsSourceTextModule());
|
||||
SourceTextModule *module = SourceTextModule::Cast(resolvedModule.GetTaggedObject());
|
||||
if (module->GetTypes() == ModuleTypes::CJS_MODULE) {
|
||||
JSHandle<JSTaggedValue> cjsModuleName(thread, SourceTextModule::GetModuleName(JSTaggedValue(module)));
|
||||
return CjsModule::SearchFromModuleCache(thread, cjsModuleName).GetTaggedValue();
|
||||
CString cjsModuleName = SourceTextModule::GetModuleName(JSTaggedValue(module));
|
||||
JSHandle<JSTaggedValue> moduleNameHandle(thread->GetEcmaVM()->GetFactory()->NewFromUtf8(cjsModuleName));
|
||||
return CjsModule::SearchFromModuleCache(thread, moduleNameHandle).GetTaggedValue();
|
||||
}
|
||||
return module->GetModuleValue(thread, binding->GetBindingName(), false);
|
||||
}
|
||||
@ -560,8 +560,7 @@ JSHandle<JSTaggedValue> ModuleManager::ResolveModuleWithMerge(
|
||||
moduleRecord = ModuleDataExtractor::ParseCjsModule(thread, jsPandaFile);
|
||||
}
|
||||
|
||||
JSHandle<EcmaString> recordNameHdl = vm_->GetFactory()->NewFromUtf8(recordName);
|
||||
JSHandle<SourceTextModule>::Cast(moduleRecord)->SetEcmaModuleRecordName(thread, recordNameHdl.GetTaggedValue());
|
||||
JSHandle<SourceTextModule>::Cast(moduleRecord)->SetEcmaModuleRecordNameString(recordName);
|
||||
ModuleDeregister::InitForDeregisterModule(moduleRecord, executeFromJob);
|
||||
return moduleRecord;
|
||||
}
|
||||
@ -603,13 +602,12 @@ JSTaggedValue ModuleManager::GetModuleNamespaceInternal(int32_t index, JSTaggedV
|
||||
SourceTextModule *module = SourceTextModule::Cast(currentModule.GetTaggedObject());
|
||||
JSTaggedValue requestedModule = module->GetRequestedModules();
|
||||
JSTaggedValue moduleName = TaggedArray::Cast(requestedModule.GetTaggedObject())->Get(index);
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
JSHandle<JSTaggedValue> requiredModule;
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
if (moduleRecordName.empty()) {
|
||||
requiredModule = SourceTextModule::HostResolveImportedModule(thread,
|
||||
JSHandle<SourceTextModule>(thread, module), JSHandle<JSTaggedValue>(thread, moduleName));
|
||||
} else {
|
||||
ASSERT(moduleRecordName.IsString());
|
||||
requiredModule = SourceTextModule::HostResolveImportedModuleWithMerge(thread,
|
||||
JSHandle<SourceTextModule>(thread, module), JSHandle<JSTaggedValue>(thread, moduleName));
|
||||
}
|
||||
@ -622,9 +620,9 @@ JSTaggedValue ModuleManager::GetModuleNamespaceInternal(int32_t index, JSTaggedV
|
||||
}
|
||||
// if requiredModuleST is CommonJS
|
||||
if (moduleType == ModuleTypes::CJS_MODULE) {
|
||||
JSHandle<JSTaggedValue> cjsModuleName(thread,
|
||||
SourceTextModule::GetModuleName(requiredModuleST.GetTaggedValue()));
|
||||
return CjsModule::SearchFromModuleCache(thread, cjsModuleName).GetTaggedValue();
|
||||
CString cjsModuleName = SourceTextModule::GetModuleName(requiredModuleST.GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> moduleNameHandle(thread->GetEcmaVM()->GetFactory()->NewFromUtf8(cjsModuleName));
|
||||
return CjsModule::SearchFromModuleCache(thread, moduleNameHandle).GetTaggedValue();
|
||||
}
|
||||
// if requiredModuleST is ESM
|
||||
JSHandle<JSTaggedValue> moduleNamespace = SourceTextModule::GetModuleNamespace(thread, requiredModuleST);
|
||||
@ -680,9 +678,9 @@ CString ModuleManager::GetRecordName(JSTaggedValue module)
|
||||
}
|
||||
if (module.IsSourceTextModule()) {
|
||||
SourceTextModule *sourceTextModule = SourceTextModule::Cast(module.GetTaggedObject());
|
||||
JSTaggedValue recordName = sourceTextModule->GetEcmaModuleRecordName();
|
||||
if (recordName.IsString()) {
|
||||
entry = ModulePathHelper::Utf8ConvertToString(recordName);
|
||||
CString recordName = sourceTextModule->GetEcmaModuleRecordNameString();
|
||||
if (!recordName.empty()) {
|
||||
return recordName;
|
||||
}
|
||||
}
|
||||
return entry;
|
||||
@ -694,10 +692,10 @@ int ModuleManager::GetExportObjectIndex(EcmaVM *vm, JSHandle<SourceTextModule> e
|
||||
JSThread *thread = vm->GetJSThread();
|
||||
if (ecmaModule->GetLocalExportEntries().IsUndefined()) {
|
||||
CString msg = "No export named '" + key;
|
||||
if (!ecmaModule->GetEcmaModuleRecordName().IsUndefined()) {
|
||||
msg += "' which exported by '" + ConvertToString(ecmaModule->GetEcmaModuleRecordName()) + "'";
|
||||
if (!ecmaModule->GetEcmaModuleRecordNameString().empty()) {
|
||||
msg += "' which exported by '" + ecmaModule->GetEcmaModuleRecordNameString() + "'";
|
||||
} else {
|
||||
msg += "' which exported by '" + ConvertToString(ecmaModule->GetEcmaModuleFilename()) + "'";
|
||||
msg += "' which exported by '" + ecmaModule->GetEcmaModuleFilenameString() + "'";
|
||||
}
|
||||
ObjectFactory *factory = vm->GetFactory();
|
||||
JSTaggedValue error = factory->GetJSError(ErrorType::SYNTAX_ERROR, msg.c_str(),
|
||||
@ -810,7 +808,6 @@ JSHandle<JSTaggedValue> ModuleManager::ExecuteJsonModule(JSThread *thread, const
|
||||
JSHandle<JSTaggedValue> ModuleManager::ExecuteCjsModule(JSThread *thread, const CString &recordName,
|
||||
const JSPandaFile *jsPandaFile)
|
||||
{
|
||||
ObjectFactory *factory = vm_->GetFactory();
|
||||
CString entryPoint = JSPandaFile::ENTRY_FUNCTION_NAME;
|
||||
CString moduleRecord = jsPandaFile->GetJSPandaFileDesc();
|
||||
if (!jsPandaFile->IsBundlePack()) {
|
||||
@ -824,8 +821,7 @@ JSHandle<JSTaggedValue> ModuleManager::ExecuteCjsModule(JSThread *thread, const
|
||||
} else {
|
||||
JSHandle<SourceTextModule> module =
|
||||
JSHandle<SourceTextModule>::Cast(ModuleDataExtractor::ParseCjsModule(thread, jsPandaFile));
|
||||
JSHandle<EcmaString> record = factory->NewFromASCII(moduleRecord);
|
||||
module->SetEcmaModuleRecordName(thread, record);
|
||||
module->SetEcmaModuleRecordNameString(moduleRecord);
|
||||
requiredModule.Update(module);
|
||||
JSPandaFileExecutor::Execute(thread, jsPandaFile, entryPoint);
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, requiredModule);
|
||||
@ -870,6 +866,8 @@ void ModuleManager::RemoveModuleFromCache(const CString& recordName)
|
||||
}
|
||||
JSTaggedValue result = entry->second;
|
||||
SourceTextModule::Cast(result)->DestoryLazyImportArray();
|
||||
SourceTextModule::Cast(result)->DestoryEcmaModuleFilenameString();
|
||||
SourceTextModule::Cast(result)->DestoryEcmaModuleRecordNameString();
|
||||
resolvedModules_.erase(recordName);
|
||||
}
|
||||
|
||||
|
@ -130,6 +130,8 @@ public:
|
||||
ASSERT(!key.empty());
|
||||
JSTaggedValue module = it->second;
|
||||
SourceTextModule::Cast(module)->DestoryLazyImportArray();
|
||||
SourceTextModule::Cast(module)->DestoryEcmaModuleFilenameString();
|
||||
SourceTextModule::Cast(module)->DestoryEcmaModuleRecordNameString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,8 +365,7 @@ void ModuleNamespace::SetModuleDeregisterProcession(JSThread *thread, const JSHa
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
|
||||
JSHandle<SourceTextModule> module(thread, nameSpace->GetModule());
|
||||
JSHandle<JSTaggedValue> moduleName(thread, SourceTextModule::GetModuleName(module.GetTaggedValue()));
|
||||
CString moduleStr = ConvertToString(moduleName.GetTaggedValue());
|
||||
CString moduleStr = SourceTextModule::GetModuleName(module.GetTaggedValue());
|
||||
int srcLength = strlen(moduleStr.c_str()) + 1;
|
||||
auto moduleNameData = thread->GetEcmaVM()->GetNativeAreaAllocator()->AllocateBuffer(srcLength);
|
||||
if (memcpy_s(moduleNameData, srcLength, moduleStr.c_str(), srcLength) != EOK) {
|
||||
|
@ -99,8 +99,7 @@ JSHandle<JSTaggedValue> SourceTextModule::HostResolveImportedModuleWithMerge(JST
|
||||
if (thread->GetCurrentEcmaContext()->GetStageOfHotReload() == StageOfHotReload::BEGIN_EXECUTE_PATCHMAIN) {
|
||||
baseFilename = thread->GetEcmaVM()->GetQuickFixManager()->GetCurrentBaseFileName();
|
||||
} else {
|
||||
ASSERT(module->GetEcmaModuleFilename().IsHeapObject());
|
||||
baseFilename = ModulePathHelper::Utf8ConvertToString(module->GetEcmaModuleFilename());
|
||||
baseFilename = module->GetEcmaModuleFilenameString();
|
||||
}
|
||||
|
||||
auto moduleManager = thread->GetCurrentEcmaContext()->GetModuleManager();
|
||||
@ -111,8 +110,7 @@ JSHandle<JSTaggedValue> SourceTextModule::HostResolveImportedModuleWithMerge(JST
|
||||
}
|
||||
return moduleManager->ResolveNativeModule(requestStr, baseFilename, moduleType);
|
||||
}
|
||||
ASSERT(module->GetEcmaModuleRecordName().IsHeapObject());
|
||||
CString recordName = ModulePathHelper::Utf8ConvertToString(module->GetEcmaModuleRecordName());
|
||||
CString recordName = module->GetEcmaModuleRecordNameString();
|
||||
std::shared_ptr<JSPandaFile> jsPandaFile =
|
||||
JSPandaFileManager::GetInstance()->LoadJSPandaFile(thread, baseFilename, recordName);
|
||||
if (jsPandaFile == nullptr) {
|
||||
@ -145,8 +143,7 @@ JSHandle<JSTaggedValue> SourceTextModule::HostResolveImportedModule(JSThread *th
|
||||
return JSHandle<JSTaggedValue>(moduleManager->HostGetImportedModule(moduleRequestStr));
|
||||
}
|
||||
|
||||
CString dirname = base::PathHelper::ResolveDirPath(
|
||||
ModulePathHelper::Utf8ConvertToString(module->GetEcmaModuleFilename()));
|
||||
CString dirname = base::PathHelper::ResolveDirPath(module->GetEcmaModuleFilenameString());
|
||||
CString moduleFilename = ResolveFilenameFromNative(thread, dirname, moduleRequestStr);
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
|
||||
return SharedModuleManager::GetInstance()->ResolveImportedModule(thread,
|
||||
@ -238,7 +235,8 @@ JSHandle<JSTaggedValue> SourceTextModule::ResolveCjsStarExport(JSThread *thread,
|
||||
cjsModule->SetStatus(ModuleStatus::EVALUATED);
|
||||
}
|
||||
|
||||
JSHandle<JSTaggedValue> cjsModuleName(thread, GetModuleName(cjsModule.GetTaggedValue()));
|
||||
CString moduleName = GetModuleName(cjsModule.GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> cjsModuleName(thread->GetEcmaVM()->GetFactory()->NewFromUtf8(moduleName));
|
||||
JSHandle<JSTaggedValue> cjsExports = CjsModule::SearchFromModuleCache(thread, cjsModuleName);
|
||||
return SourceTextModule::ResolveExportObject(thread, cjsModule, cjsExports, exportName);
|
||||
}
|
||||
@ -384,8 +382,7 @@ void SourceTextModule::MakeInternalArgs(const EcmaVM *vm, std::vector<Local<JSVa
|
||||
Local<JSValueRef> SourceTextModule::LoadNativeModuleImpl(EcmaVM *vm, JSThread *thread,
|
||||
const JSHandle<SourceTextModule> &requiredModule, ModuleTypes moduleType)
|
||||
{
|
||||
CString moduleRequestName =
|
||||
ModulePathHelper::Utf8ConvertToString(requiredModule->GetEcmaModuleRecordName());
|
||||
CString moduleRequestName = requiredModule->GetEcmaModuleRecordNameString();
|
||||
bool enableESMTrace = thread->GetEcmaVM()->GetJSOptions().EnableESMTrace();
|
||||
if (enableESMTrace) {
|
||||
CString traceInfo = "LoadNativeModule: " + moduleRequestName;
|
||||
@ -393,8 +390,7 @@ Local<JSValueRef> SourceTextModule::LoadNativeModuleImpl(EcmaVM *vm, JSThread *t
|
||||
}
|
||||
CString soName = PathHelper::GetStrippedModuleName(moduleRequestName);
|
||||
|
||||
CString fileName =
|
||||
ModulePathHelper::Utf8ConvertToString(requiredModule->GetEcmaModuleFilename());
|
||||
CString fileName = requiredModule->GetEcmaModuleFilenameString();
|
||||
CString moduleName = ModulePathHelper::GetModuleNameWithBaseFile(fileName);
|
||||
std::vector<Local<JSValueRef>> arguments;
|
||||
LOG_FULL(DEBUG) << "Request module is " << moduleRequestName;
|
||||
@ -443,8 +439,7 @@ bool SourceTextModule::LoadNativeModule(JSThread *thread, const JSHandle<SourceT
|
||||
|
||||
auto exportObject = LoadNativeModuleImpl(vm, thread, requiredModule, moduleType);
|
||||
bool enableESMTrace = thread->GetEcmaVM()->GetJSOptions().EnableESMTrace();
|
||||
CString fileName =
|
||||
ModulePathHelper::Utf8ConvertToString(requiredModule->GetEcmaModuleFilename());
|
||||
CString fileName = requiredModule->GetEcmaModuleFilenameString();
|
||||
CString moduleName = ModulePathHelper::GetModuleNameWithBaseFile(fileName);
|
||||
if (UNLIKELY(exportObject->IsUndefined())) {
|
||||
LOG_FULL(ERROR) << "export objects of native so is undefined, so name is " << moduleName;
|
||||
@ -474,8 +469,7 @@ void SourceTextModule::EvaluateNativeModule(JSThread *thread, JSHandle<SourceTex
|
||||
return;
|
||||
}
|
||||
if (!SourceTextModule::LoadNativeModule(thread, nativeModule, moduleType)) {
|
||||
LOG_FULL(INFO) << "LoadNativeModule " <<
|
||||
ModulePathHelper::Utf8ConvertToString(nativeModule->GetEcmaModuleRecordName()) << " failed";
|
||||
LOG_FULL(INFO) << "LoadNativeModule " << nativeModule->GetEcmaModuleRecordNameString() << " failed";
|
||||
return;
|
||||
}
|
||||
nativeModule->SetStatus(ModuleStatus::EVALUATED);
|
||||
@ -588,14 +582,13 @@ std::optional<int> SourceTextModule::HandleInnerModuleInstantiation(JSThread *th
|
||||
{
|
||||
// a. Let requiredModule be ? HostResolveImportedModule(module, required).
|
||||
JSMutableHandle<SourceTextModule> requiredModule(thread, thread->GlobalConstants()->GetUndefined());
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
if (moduleRecordName.empty()) {
|
||||
JSHandle<JSTaggedValue> requiredVal =
|
||||
SourceTextModule::HostResolveImportedModule(thread, module, required, executeFromJob);
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, SourceTextModule::UNDEFINED_INDEX);
|
||||
requiredModule.Update(JSHandle<SourceTextModule>::Cast(requiredVal));
|
||||
} else {
|
||||
ASSERT(moduleRecordName.IsString());
|
||||
JSHandle<JSTaggedValue> requiredVal =
|
||||
SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, required, executeFromJob);
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, SourceTextModule::UNDEFINED_INDEX);
|
||||
@ -718,14 +711,13 @@ void SourceTextModule::ModuleDeclarationEnvironmentSetup(JSThread *thread,
|
||||
moduleRequest.Update(in->GetModuleRequest());
|
||||
// a. Let importedModule be ! HostResolveImportedModule(module, in.[[ModuleRequest]]).
|
||||
JSMutableHandle<SourceTextModule> importedModule(thread, thread->GlobalConstants()->GetUndefined());
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
if (moduleRecordName.empty()) {
|
||||
JSHandle<JSTaggedValue> importedVal =
|
||||
SourceTextModule::HostResolveImportedModule(thread, module, moduleRequest);
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
importedModule.Update(JSHandle<SourceTextModule>::Cast(importedVal));
|
||||
} else {
|
||||
ASSERT(moduleRecordName.IsString());
|
||||
JSHandle<JSTaggedValue> importedVal =
|
||||
SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, moduleRequest);
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
@ -752,12 +744,11 @@ void SourceTextModule::ModuleDeclarationEnvironmentSetup(JSThread *thread,
|
||||
CString requestMod = ModulePathHelper::ReformatPath(ConvertToString(moduleRequest.GetTaggedValue()));
|
||||
CString msg = "the requested module '" + requestMod + GetResolveErrorReason(resolution) +
|
||||
ConvertToString(importName.GetTaggedValue());
|
||||
if (!module->GetEcmaModuleRecordName().IsUndefined()) {
|
||||
CString recordStr = ModulePathHelper::ReformatPath(ConvertToString(
|
||||
module->GetEcmaModuleRecordName()));
|
||||
if (!module->GetEcmaModuleRecordNameString().empty()) {
|
||||
CString recordStr = ModulePathHelper::ReformatPath(module->GetEcmaModuleRecordNameString());
|
||||
msg += "' which imported by '" + recordStr + "'";
|
||||
} else {
|
||||
msg += "' which imported by '" + ConvertToString(module->GetEcmaModuleFilename()) + "'";
|
||||
msg += "' which imported by '" + module->GetEcmaModuleFilenameString() + "'";
|
||||
}
|
||||
THROW_ERROR(thread, ErrorType::SYNTAX_ERROR, msg.c_str());
|
||||
}
|
||||
@ -805,14 +796,13 @@ void SourceTextModule::ModuleDeclarationArrayEnvironmentSetup(JSThread *thread,
|
||||
moduleRequest.Update(in->GetModuleRequest());
|
||||
// a. Let importedModule be ! HostResolveImportedModule(module, in.[[ModuleRequest]]).
|
||||
JSMutableHandle<SourceTextModule> importedModule(thread, thread->GlobalConstants()->GetUndefined());
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
if (moduleRecordName.empty()) {
|
||||
JSHandle<JSTaggedValue> importedVal =
|
||||
SourceTextModule::HostResolveImportedModule(thread, module, moduleRequest);
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
importedModule.Update(JSHandle<SourceTextModule>::Cast(importedVal));
|
||||
} else {
|
||||
ASSERT(moduleRecordName.IsString());
|
||||
JSHandle<JSTaggedValue> importedVal =
|
||||
SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, moduleRequest);
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
@ -835,12 +825,12 @@ void SourceTextModule::ModuleDeclarationArrayEnvironmentSetup(JSThread *thread,
|
||||
CString requestMod = ModulePathHelper::ReformatPath(ConvertToString(moduleRequest.GetTaggedValue()));
|
||||
CString msg = "the requested module '" + requestMod + GetResolveErrorReason(resolution) +
|
||||
ConvertToString(importName.GetTaggedValue());
|
||||
if (!module->GetEcmaModuleRecordName().IsUndefined()) {
|
||||
CString recordStr = ModulePathHelper::ReformatPath(ConvertToString(
|
||||
module->GetEcmaModuleRecordName()));
|
||||
if (!module->GetEcmaModuleRecordNameString().empty()) {
|
||||
CString recordStr = ModulePathHelper::ReformatPath(
|
||||
module->GetEcmaModuleRecordNameString());
|
||||
msg += "' which imported by '" + recordStr + "'";
|
||||
} else {
|
||||
msg += "' which imported by '" + ConvertToString(module->GetEcmaModuleFilename()) + "'";
|
||||
msg += "' which imported by '" + module->GetEcmaModuleFilenameString() + "'";
|
||||
}
|
||||
THROW_ERROR(thread, ErrorType::SYNTAX_ERROR, msg.c_str());
|
||||
}
|
||||
@ -1044,12 +1034,11 @@ int SourceTextModule::InnerModuleEvaluationUnsafe(JSThread *thread, const JSHand
|
||||
continue;
|
||||
}
|
||||
required.Update(requestedModules->Get(idx));
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
if (moduleRecordName.empty()) {
|
||||
requiredModule = JSHandle<SourceTextModule>::Cast(
|
||||
SourceTextModule::HostResolveImportedModule(thread, module, required));
|
||||
} else {
|
||||
ASSERT(moduleRecordName.IsString());
|
||||
requiredModule = JSHandle<SourceTextModule>::Cast(
|
||||
SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, required));
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, index);
|
||||
@ -1267,12 +1256,11 @@ int SourceTextModule::ModuleEvaluation(JSThread *thread, const JSHandle<ModuleRe
|
||||
}
|
||||
required.Update(requestedModules->Get(idx));
|
||||
JSMutableHandle<SourceTextModule> requiredModule(thread, thread->GlobalConstants()->GetUndefined());
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
if (moduleRecordName.empty()) {
|
||||
requiredModule.Update(SourceTextModule::HostResolveImportedModule(thread, module, required));
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, index);
|
||||
} else {
|
||||
ASSERT(moduleRecordName.IsString());
|
||||
requiredModule.Update(SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, required));
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, index);
|
||||
}
|
||||
@ -1298,18 +1286,13 @@ int SourceTextModule::ModuleEvaluation(JSThread *thread, const JSHandle<ModuleRe
|
||||
Expected<JSTaggedValue, bool> SourceTextModule::ModuleExecution(JSThread *thread,
|
||||
const JSHandle<SourceTextModule> &module, const void *buffer, size_t size, bool executeFromJob)
|
||||
{
|
||||
JSTaggedValue moduleFileName = module->GetEcmaModuleFilename();
|
||||
ASSERT(moduleFileName.IsString());
|
||||
CString moduleFilenameStr =
|
||||
ModulePathHelper::Utf8ConvertToString(moduleFileName);
|
||||
|
||||
CString moduleFilenameStr = module->GetEcmaModuleFilenameString();
|
||||
std::string entryPoint;
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
if (moduleRecordName.empty()) {
|
||||
entryPoint = JSPandaFile::ENTRY_FUNCTION_NAME;
|
||||
} else {
|
||||
ASSERT(moduleRecordName.IsString());
|
||||
entryPoint = ModulePathHelper::Utf8ConvertToString(moduleRecordName);
|
||||
entryPoint = moduleRecordName;
|
||||
}
|
||||
|
||||
std::shared_ptr<JSPandaFile> jsPandaFile;
|
||||
@ -1513,14 +1496,13 @@ void SourceTextModule::SetExportName(JSThread *thread, const JSHandle<JSTaggedVa
|
||||
|
||||
{
|
||||
JSMutableHandle<SourceTextModule> requestedModule(thread, thread->GlobalConstants()->GetUndefined());
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
if (moduleRecordName.empty()) {
|
||||
JSHandle<JSTaggedValue> requestedVal =
|
||||
SourceTextModule::HostResolveImportedModule(thread, module, moduleRequest);
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
requestedModule.Update(JSHandle<SourceTextModule>::Cast(requestedVal));
|
||||
} else {
|
||||
ASSERT(moduleRecordName.IsString());
|
||||
JSHandle<JSTaggedValue> requestedVal =
|
||||
SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, moduleRequest);
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
@ -1551,14 +1533,13 @@ JSHandle<JSTaggedValue> SourceTextModule::GetStarResolution(JSThread *thread,
|
||||
auto globalConstants = thread->GlobalConstants();
|
||||
// a. Let importedModule be ? HostResolveImportedModule(module, e.[[ModuleRequest]]).
|
||||
JSMutableHandle<SourceTextModule> importedModule(thread, thread->GlobalConstants()->GetUndefined());
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
if (moduleRecordName.empty()) {
|
||||
JSHandle<JSTaggedValue> importedVal =
|
||||
SourceTextModule::HostResolveImportedModule(thread, module, moduleRequest);
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
|
||||
importedModule.Update(JSHandle<SourceTextModule>::Cast(importedVal));
|
||||
} else {
|
||||
ASSERT(moduleRecordName.IsString());
|
||||
JSHandle<JSTaggedValue> importedVal =
|
||||
SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, moduleRequest);
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
|
||||
@ -1704,11 +1685,10 @@ JSHandle<JSTaggedValue> SourceTextModule::ResolveIndirectExport(JSThread *thread
|
||||
// ii. Let importedModule be ? HostResolveImportedModule(module, e.[[ModuleRequest]]).
|
||||
moduleRequest.Update(ee->GetModuleRequest());
|
||||
JSMutableHandle<SourceTextModule> requestedModule(thread, undefined);
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
if (moduleRecordName.empty()) {
|
||||
requestedModule.Update(SourceTextModule::HostResolveImportedModule(thread, module, moduleRequest));
|
||||
} else {
|
||||
ASSERT(moduleRecordName.IsString());
|
||||
requestedModule.Update(
|
||||
SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, moduleRequest));
|
||||
}
|
||||
@ -1746,11 +1726,11 @@ void SourceTextModule::CheckResolvedBinding(JSThread *thread, const JSHandle<Sou
|
||||
CString requestMod = ModulePathHelper::ReformatPath(ConvertToString(ee->GetModuleRequest()));
|
||||
CString msg = "the requested module '" + requestMod + GetResolveErrorReason(resolution) +
|
||||
ConvertToString(exportName.GetTaggedValue());
|
||||
if (!module->GetEcmaModuleRecordName().IsUndefined()) {
|
||||
CString recordStr = ModulePathHelper::ReformatPath(ConvertToString(module->GetEcmaModuleRecordName()));
|
||||
if (!module->GetEcmaModuleRecordNameString().empty()) {
|
||||
CString recordStr = ModulePathHelper::ReformatPath(module->GetEcmaModuleRecordNameString());
|
||||
msg += "' which exported by '" + recordStr + "'";
|
||||
} else {
|
||||
msg += "' which exported by '" + ConvertToString(module->GetEcmaModuleFilename()) + "'";
|
||||
msg += "' which exported by '" + module->GetEcmaModuleFilenameString() + "'";
|
||||
}
|
||||
THROW_ERROR(thread, ErrorType::SYNTAX_ERROR, msg.c_str());
|
||||
}
|
||||
@ -1784,23 +1764,23 @@ void SourceTextModule::CheckResolvedIndexBinding(JSThread *thread, const JSHandl
|
||||
CString requestMod = ModulePathHelper::ReformatPath(ConvertToString(ee->GetModuleRequest()));
|
||||
CString msg = "the requested module '" + requestMod + GetResolveErrorReason(resolution) +
|
||||
ConvertToString(exportName.GetTaggedValue());
|
||||
if (!module->GetEcmaModuleRecordName().IsUndefined()) {
|
||||
CString record = ModulePathHelper::ReformatPath(ConvertToString(module->GetEcmaModuleRecordName()));
|
||||
if (!module->GetEcmaModuleRecordNameString().empty()) {
|
||||
CString record = ModulePathHelper::ReformatPath(module->GetEcmaModuleRecordNameString());
|
||||
msg += "' which exported by '" + record + "'";
|
||||
} else {
|
||||
msg += "' which exported by '" + ConvertToString(module->GetEcmaModuleFilename()) + "'";
|
||||
msg += "' which exported by '" + module->GetEcmaModuleFilenameString() + "'";
|
||||
}
|
||||
THROW_ERROR(thread, ErrorType::SYNTAX_ERROR, msg.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSTaggedValue SourceTextModule::GetModuleName(JSTaggedValue currentModule)
|
||||
CString SourceTextModule::GetModuleName(JSTaggedValue currentModule)
|
||||
{
|
||||
SourceTextModule *module = SourceTextModule::Cast(currentModule.GetTaggedObject());
|
||||
JSTaggedValue recordName = module->GetEcmaModuleRecordName();
|
||||
if (recordName.IsUndefined()) {
|
||||
return module->GetEcmaModuleFilename();
|
||||
CString recordName = module->GetEcmaModuleRecordNameString();
|
||||
if (recordName.empty()) {
|
||||
recordName = module->GetEcmaModuleFilenameString();
|
||||
}
|
||||
return recordName;
|
||||
}
|
||||
@ -1840,18 +1820,14 @@ void SourceTextModule::ExecuteAsyncModule(JSThread *thread, const JSHandle<Sourc
|
||||
ASSERT(module->GetStatus() == ModuleStatus::EVALUATING || module->GetStatus() == ModuleStatus::EVALUATING_ASYNC);
|
||||
// 2. Assert: module.[[HasTLA]] is true.
|
||||
ASSERT(module->GetHasTLA());
|
||||
JSTaggedValue moduleFileName = module->GetEcmaModuleFilename();
|
||||
ASSERT(moduleFileName.IsString());
|
||||
CString moduleFilenameStr =
|
||||
ModulePathHelper::Utf8ConvertToString(moduleFileName);
|
||||
CString moduleFilenameStr = module->GetEcmaModuleFilenameString();
|
||||
|
||||
std::string entryPoint;
|
||||
JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName();
|
||||
if (moduleRecordName.IsUndefined()) {
|
||||
CString moduleRecordName = module->GetEcmaModuleRecordNameString();
|
||||
if (moduleRecordName.empty()) {
|
||||
entryPoint = JSPandaFile::ENTRY_FUNCTION_NAME;
|
||||
} else {
|
||||
ASSERT(moduleRecordName.IsString());
|
||||
entryPoint = ModulePathHelper::Utf8ConvertToString(moduleRecordName);
|
||||
entryPoint = moduleRecordName;
|
||||
}
|
||||
|
||||
std::shared_ptr<JSPandaFile> jsPandaFile;
|
||||
@ -2145,8 +2121,7 @@ void SourceTextModule::SearchCircularImport(JSThread *thread, const CString &cir
|
||||
requiredModule.Update(JSHandle<SourceTextModule>::Cast(
|
||||
SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, required)));
|
||||
RETURN_IF_ABRUPT_COMPLETION(thread);
|
||||
requiredModuleName =
|
||||
ModulePathHelper::Utf8ConvertToString(requiredModule->GetEcmaModuleRecordName());
|
||||
requiredModuleName = requiredModule->GetEcmaModuleRecordNameString();
|
||||
referenceList.push_back(requiredModuleName);
|
||||
if (requiredModuleName == circularModuleRecordName) {
|
||||
PrintCircular(referenceList, ERROR);
|
||||
@ -2205,8 +2180,7 @@ CString SourceTextModule::ReplaceModuleThroughFeature(JSThread *thread, const CS
|
||||
std::tuple<bool, JSHandle<SourceTextModule>> SourceTextModule::GetResolvedModule(JSThread *thread,
|
||||
const JSHandle<SourceTextModule> &module, const JSHandle<JSTaggedValue> &moduleRequest)
|
||||
{
|
||||
CString dirname = base::PathHelper::ResolveDirPath(
|
||||
ModulePathHelper::Utf8ConvertToString(module->GetEcmaModuleFilename()));
|
||||
CString dirname = base::PathHelper::ResolveDirPath(module->GetEcmaModuleFilenameString());
|
||||
CString moduleRequestStr = ModulePathHelper::Utf8ConvertToString(moduleRequest.GetTaggedValue());
|
||||
CString fileName = ResolveFilenameFromNative(thread, dirname, moduleRequestStr);
|
||||
|
||||
@ -2239,8 +2213,8 @@ std::tuple<bool, JSHandle<SourceTextModule>> SourceTextModule::GetResolvedModule
|
||||
moduleManager->HostGetImportedModule(moduleRequestStr));
|
||||
}
|
||||
|
||||
CString baseFilename = ModulePathHelper::Utf8ConvertToString(module->GetEcmaModuleFilename());
|
||||
CString recordName = ModulePathHelper::Utf8ConvertToString(module->GetEcmaModuleRecordName());
|
||||
CString baseFilename = module->GetEcmaModuleFilenameString();
|
||||
CString recordName = module->GetEcmaModuleRecordNameString();
|
||||
std::shared_ptr<JSPandaFile> jsPandaFile =
|
||||
JSPandaFileManager::GetInstance()->LoadJSPandaFile(thread, baseFilename, recordName);
|
||||
ASSERT(!(jsPandaFile == nullptr));
|
||||
|
@ -259,11 +259,55 @@ public:
|
||||
return lazyArray[index];
|
||||
}
|
||||
|
||||
inline CString GetEcmaModuleFilenameString() const
|
||||
{
|
||||
CString *fileName = reinterpret_cast<CString *>(GetEcmaModuleFilename());
|
||||
if (fileName == nullptr) {
|
||||
return CString();
|
||||
}
|
||||
return *fileName;
|
||||
}
|
||||
|
||||
inline CString GetEcmaModuleRecordNameString() const
|
||||
{
|
||||
CString *recordName = reinterpret_cast<CString *>(GetEcmaModuleRecordName());
|
||||
if (recordName == nullptr) {
|
||||
return CString();
|
||||
}
|
||||
return *recordName;
|
||||
}
|
||||
|
||||
inline void SetEcmaModuleFilenameString(const CString &fileName)
|
||||
{
|
||||
CString *ptr = new CString(fileName);
|
||||
DestoryEcmaModuleFilenameString();
|
||||
SetEcmaModuleFilename(ToUintPtr(ptr));
|
||||
}
|
||||
|
||||
inline void SetEcmaModuleRecordNameString(const CString &recordName)
|
||||
{
|
||||
CString *ptr = new CString(recordName);
|
||||
DestoryEcmaModuleRecordNameString();
|
||||
SetEcmaModuleRecordName(ToUintPtr(ptr));
|
||||
}
|
||||
|
||||
inline void DestoryEcmaModuleFilenameString()
|
||||
{
|
||||
CString *ptr = reinterpret_cast<CString *>(GetEcmaModuleFilename());
|
||||
delete ptr;
|
||||
SetEcmaModuleFilename(ToUintPtr(nullptr));
|
||||
}
|
||||
|
||||
inline void DestoryEcmaModuleRecordNameString()
|
||||
{
|
||||
CString *ptr = reinterpret_cast<CString *>(GetEcmaModuleRecordName());
|
||||
delete ptr;
|
||||
SetEcmaModuleRecordName(ToUintPtr(nullptr));
|
||||
}
|
||||
|
||||
static constexpr size_t SOURCE_TEXT_MODULE_OFFSET = ModuleRecord::SIZE;
|
||||
ACCESSORS(Environment, SOURCE_TEXT_MODULE_OFFSET, NAMESPACE_OFFSET);
|
||||
ACCESSORS(Namespace, NAMESPACE_OFFSET, ECMA_MODULE_FILENAME);
|
||||
ACCESSORS(EcmaModuleFilename, ECMA_MODULE_FILENAME, ECMA_MODULE_RECORDNAME);
|
||||
ACCESSORS(EcmaModuleRecordName, ECMA_MODULE_RECORDNAME, REQUESTED_MODULES_OFFSET);
|
||||
ACCESSORS(Namespace, NAMESPACE_OFFSET, REQUESTED_MODULES_OFFSET);
|
||||
ACCESSORS(RequestedModules, REQUESTED_MODULES_OFFSET, IMPORT_ENTRIES_OFFSET);
|
||||
ACCESSORS(ImportEntries, IMPORT_ENTRIES_OFFSET, LOCAL_EXPORT_ENTTRIES_OFFSET);
|
||||
ACCESSORS(LocalExportEntries, LOCAL_EXPORT_ENTTRIES_OFFSET, INDIRECT_EXPORT_ENTTRIES_OFFSET);
|
||||
@ -280,7 +324,9 @@ public:
|
||||
ACCESSORS_PRIMITIVE_FIELD(AsyncEvaluatingOrdinal, uint32_t, ASYNC_EVALUATION_OFFSET, PENDING_DEPENDENCIES_OFFSET);
|
||||
ACCESSORS_PRIMITIVE_FIELD(PendingAsyncDependencies,
|
||||
int32_t, PENDING_DEPENDENCIES_OFFSET, LAYZ_IMPORT_STATUS_OFFSET);
|
||||
ACCESSORS_PRIMITIVE_FIELD(LazyImportStatus, uintptr_t, LAYZ_IMPORT_STATUS_OFFSET, BIT_FIELD_OFFSET);
|
||||
ACCESSORS_PRIMITIVE_FIELD(LazyImportStatus, uintptr_t, LAYZ_IMPORT_STATUS_OFFSET, ECMA_MODULE_FILENAME);
|
||||
ACCESSORS_PRIMITIVE_FIELD(EcmaModuleFilename, uintptr_t, ECMA_MODULE_FILENAME, ECMA_MODULE_RECORDNAME);
|
||||
ACCESSORS_PRIMITIVE_FIELD(EcmaModuleRecordName, uintptr_t, ECMA_MODULE_RECORDNAME, BIT_FIELD_OFFSET);
|
||||
ACCESSORS_BIT_FIELD(BitField, BIT_FIELD_OFFSET, LAST_OFFSET)
|
||||
|
||||
DEFINE_ALIGN_SIZE(LAST_OFFSET);
|
||||
@ -333,7 +379,7 @@ public:
|
||||
const JSHandle<SourceTextModule> &module,
|
||||
CVector<std::pair<JSHandle<SourceTextModule>,
|
||||
JSHandle<JSTaggedValue>>> &resolveVector);
|
||||
static JSTaggedValue GetModuleName(JSTaggedValue currentModule);
|
||||
static CString GetModuleName(JSTaggedValue currentModule);
|
||||
|
||||
static bool IsDynamicModule(LoadingTypes types);
|
||||
|
||||
@ -373,6 +419,8 @@ private:
|
||||
const JSHandle<JSTaggedValue> &exportName,
|
||||
CVector<std::pair<JSHandle<SourceTextModule>,
|
||||
JSHandle<JSTaggedValue>>> &resolveVector);
|
||||
static void InitializeEnvironment(JSThread *thread, const JSHandle<SourceTextModule> ¤tModule,
|
||||
CString &moduleName, JSHandle<JSTaggedValue> &exports, bool isBundle);
|
||||
|
||||
static void CheckResolvedBinding(JSThread *thread, const JSHandle<SourceTextModule> &module);
|
||||
static void CheckResolvedIndexBinding(JSThread *thread, const JSHandle<SourceTextModule> &module);
|
||||
|
@ -41,8 +41,8 @@ JSHandle<JSTaggedValue> SendableClassModule::GenerateSendableFuncModule(JSThread
|
||||
currentEnvironment);
|
||||
sModule->SetSharedType(SharedTypes::SENDABLE_FUNCTION_MODULE);
|
||||
sModule->SetEnvironment(thread, sendableEnvironment);
|
||||
sModule->SetEcmaModuleFilename(thread, currentModule->GetEcmaModuleFilename());
|
||||
sModule->SetEcmaModuleRecordName(thread, currentModule->GetEcmaModuleRecordName());
|
||||
sModule->SetEcmaModuleFilenameString(currentModule->GetEcmaModuleFilenameString());
|
||||
sModule->SetEcmaModuleRecordNameString(currentModule->GetEcmaModuleRecordNameString());
|
||||
sModule->SetSendableEnv(thread, JSTaggedValue::Undefined());
|
||||
return JSHandle<JSTaggedValue>(sModule);
|
||||
}
|
||||
@ -50,15 +50,16 @@ JSHandle<JSTaggedValue> SendableClassModule::GenerateSendableFuncModule(JSThread
|
||||
JSHandle<JSTaggedValue> SendableClassModule::CloneRecordIndexBinding(JSThread *thread, JSTaggedValue indexBinding)
|
||||
{
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
ResolvedIndexBinding *binding = ResolvedIndexBinding::Cast(indexBinding.GetTaggedObject());
|
||||
JSHandle<ResolvedIndexBinding> binding(thread, indexBinding);
|
||||
JSHandle<SourceTextModule> resolvedModule(thread, binding->GetModule());
|
||||
if (SourceTextModule::IsSharedModule((resolvedModule))) {
|
||||
return JSHandle<JSTaggedValue>::Cast(
|
||||
factory->NewSResolvedIndexBindingRecord(resolvedModule, binding->GetIndex()));
|
||||
}
|
||||
|
||||
JSHandle<EcmaString> record(thread, SourceTextModule::GetModuleName(resolvedModule.GetTaggedValue()));
|
||||
JSHandle<EcmaString> fileName(thread, resolvedModule->GetEcmaModuleFilename());
|
||||
CString moduleName = SourceTextModule::GetModuleName(resolvedModule.GetTaggedValue());
|
||||
JSHandle<EcmaString> record = thread->GetEcmaVM()->GetFactory()->NewFromUtf8(moduleName);
|
||||
JSHandle<EcmaString> fileName = factory->NewFromUtf8(resolvedModule->GetEcmaModuleFilenameString());
|
||||
int32_t index = binding->GetIndex();
|
||||
return JSHandle<JSTaggedValue>::Cast(factory->NewSResolvedRecordIndexBindingRecord(record, fileName, index));
|
||||
}
|
||||
@ -74,7 +75,8 @@ JSHandle<JSTaggedValue> SendableClassModule::CloneRecordNameBinding(JSThread *th
|
||||
factory->NewSResolvedBindingRecord(resolvedModule, bindingName));
|
||||
}
|
||||
|
||||
JSHandle<EcmaString> record(thread, SourceTextModule::GetModuleName(resolvedModule.GetTaggedValue()));
|
||||
CString moduleName = SourceTextModule::GetModuleName(resolvedModule.GetTaggedValue());
|
||||
JSHandle<EcmaString> record = thread->GetEcmaVM()->GetFactory()->NewFromUtf8(moduleName);
|
||||
JSHandle<JSTaggedValue> bindingName(thread, resolvedBinding->GetBindingName());
|
||||
return JSHandle<JSTaggedValue>::Cast(factory->NewSResolvedRecordBindingRecord(record, bindingName));
|
||||
}
|
||||
@ -141,8 +143,7 @@ JSHandle<JSTaggedValue> SharedModuleHelper::ParseSharedModule(JSThread *thread,
|
||||
|
||||
bool hasTLA = jsPandaFile->GetHasTopLevelAwait(descriptor);
|
||||
moduleRecord->SetHasTLA(hasTLA);
|
||||
JSHandle<EcmaString> ecmaModuleFilename = factory->NewFromUtf8(moduleFilename);
|
||||
moduleRecord->SetEcmaModuleFilename(thread, ecmaModuleFilename);
|
||||
moduleRecord->SetEcmaModuleFilenameString(moduleFilename);
|
||||
moduleRecord->SetStatus(ModuleStatus::UNINSTANTIATED);
|
||||
moduleRecord->SetTypes(ModuleTypes::ECMA_MODULE);
|
||||
moduleRecord->SetIsNewBcVersion(true);
|
||||
|
@ -208,9 +208,7 @@ JSHandle<JSTaggedValue> SharedModuleManager::ResolveSharedImportedModuleWithMerg
|
||||
ASSERT(jsPandaFile->IsModule(recordInfo));
|
||||
JSHandle<JSTaggedValue> moduleRecord = SharedModuleHelper::ParseSharedModule(thread, jsPandaFile, recordName,
|
||||
fileName, recordInfo);
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<JSTaggedValue> requireModule = JSHandle<JSTaggedValue>(factory->NewFromUtf8(recordName));
|
||||
JSHandle<SourceTextModule>::Cast(moduleRecord)->SetEcmaModuleRecordName(thread, requireModule);
|
||||
JSHandle<SourceTextModule>::Cast(moduleRecord)->SetEcmaModuleRecordNameString(recordName);
|
||||
moduleManager->AddResolveImportedModule(recordName, moduleRecord.GetTaggedValue());
|
||||
moduleManager->AddToInstantiatingSModuleList(recordName);
|
||||
return moduleRecord;
|
||||
@ -274,8 +272,7 @@ void SharedModuleManager::TransferSModule(JSThread *thread)
|
||||
StateVisit &SharedModuleManager::findModuleMutexWithLock(JSThread *thread, const JSHandle<SourceTextModule> &module)
|
||||
{
|
||||
RuntimeLockHolder locker(thread, mutex_);
|
||||
CString moduleName =
|
||||
ModulePathHelper::Utf8ConvertToString(SourceTextModule::GetModuleName(module.GetTaggedValue()));
|
||||
CString moduleName = SourceTextModule::GetModuleName(module.GetTaggedValue());
|
||||
auto it = sharedModuleMutex_.find(moduleName);
|
||||
if (it == sharedModuleMutex_.end()) {
|
||||
LOG_ECMA(FATAL) << " Get shared module mutex failed";
|
||||
@ -329,6 +326,8 @@ void SharedModuleManager::SharedNativeObjDestory()
|
||||
ASSERT(!key.empty());
|
||||
JSTaggedValue module = it->second;
|
||||
SourceTextModule::Cast(module)->DestoryLazyImportArray();
|
||||
SourceTextModule::Cast(module)->DestoryEcmaModuleFilenameString();
|
||||
SourceTextModule::Cast(module)->DestoryEcmaModuleRecordNameString();
|
||||
}
|
||||
}
|
||||
} // namespace panda::ecmascript
|
||||
|
@ -51,8 +51,7 @@ JSHandle<JSTaggedValue> ModuleDataExtractor::ParseModule(JSThread *thread, const
|
||||
bool hasTLA = recordInfo->hasTopLevelAwait;
|
||||
moduleRecord->SetHasTLA(hasTLA);
|
||||
|
||||
JSHandle<EcmaString> ecmaModuleFilename = factory->NewFromUtf8(moduleFilename);
|
||||
moduleRecord->SetEcmaModuleFilename(thread, ecmaModuleFilename);
|
||||
moduleRecord->SetEcmaModuleFilenameString(moduleFilename);
|
||||
|
||||
moduleRecord->SetStatus(ModuleStatus::UNINSTANTIATED);
|
||||
moduleRecord->SetTypes(ModuleTypes::ECMA_MODULE);
|
||||
@ -106,8 +105,7 @@ JSHandle<JSTaggedValue> ModuleDataExtractor::ParseCjsModule(JSThread *thread, co
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
JSHandle<SourceTextModule> moduleRecord = factory->NewSourceTextModule();
|
||||
|
||||
JSHandle<EcmaString> cjsModuleFilename = factory->NewFromUtf8(descriptor);
|
||||
moduleRecord->SetEcmaModuleFilename(thread, cjsModuleFilename);
|
||||
moduleRecord->SetEcmaModuleFilenameString(descriptor);
|
||||
|
||||
JSHandle<JSTaggedValue> defaultName = thread->GlobalConstants()->GetHandledDefaultString();
|
||||
JSHandle<LocalExportEntry> localExportEntry = factory->NewLocalExportEntry(defaultName,
|
||||
@ -133,8 +131,7 @@ JSHandle<JSTaggedValue> ModuleDataExtractor::ParseJsonModule(JSThread *thread, c
|
||||
JSTaggedValue jsonData = JsonParse(thread, jsPandaFile, recordName);
|
||||
moduleRecord->StoreModuleValue(thread, 0, JSHandle<JSTaggedValue>(thread, jsonData)); // index = 0
|
||||
|
||||
JSHandle<EcmaString> ecmaModuleFilename = factory->NewFromUtf8(moduleFilename);
|
||||
moduleRecord->SetEcmaModuleFilename(thread, ecmaModuleFilename);
|
||||
moduleRecord->SetEcmaModuleFilenameString(moduleFilename);
|
||||
|
||||
moduleRecord->SetStatus(ModuleStatus::UNINSTANTIATED);
|
||||
moduleRecord->SetTypes(ModuleTypes::JSON_MODULE);
|
||||
@ -150,10 +147,8 @@ JSHandle<JSTaggedValue> ModuleDataExtractor::ParseNativeModule(JSThread *thread,
|
||||
JSHandle<SourceTextModule> moduleRecord = factory->NewSourceTextModule();
|
||||
|
||||
// set moduleRecordName as non-undefined to distinguish between merge and non-merge mode
|
||||
JSHandle<EcmaString> falsyRecordName = factory->NewFromUtf8(moduleRequestName);
|
||||
JSHandle<EcmaString> fileName = factory->NewFromUtf8(baseFileName);
|
||||
moduleRecord->SetEcmaModuleRecordName(thread, falsyRecordName);
|
||||
moduleRecord->SetEcmaModuleFilename(thread, fileName);
|
||||
moduleRecord->SetEcmaModuleRecordNameString(moduleRequestName);
|
||||
moduleRecord->SetEcmaModuleFilenameString(baseFileName);
|
||||
JSHandle<JSTaggedValue> defaultName = thread->GlobalConstants()->GetHandledDefaultString();
|
||||
JSHandle<LocalExportEntry> localExportEntry = factory->NewLocalExportEntry(defaultName,
|
||||
defaultName, LocalExportEntry::LOCAL_DEFAULT_INDEX, SharedTypes::UNSENDABLE_MODULE);
|
||||
|
@ -50,17 +50,17 @@ JSHandle<JSTaggedValue> ModuleManagerHelper::GetNativeOrCjsExports(JSThread *thr
|
||||
if (SourceTextModule::IsNativeModule(moduleType)) {
|
||||
exports.Update(module->GetModuleValue(thread, 0, false));
|
||||
if (!exports->IsJSObject()) {
|
||||
LOG_FULL(WARN) << "Load native module failed, so is " <<
|
||||
ConvertToString(SourceTextModule::GetModuleName(resolvedModule));
|
||||
LOG_FULL(WARN) << "Load native module failed, so is " << SourceTextModule::GetModuleName(resolvedModule);
|
||||
}
|
||||
return exports;
|
||||
}
|
||||
if (SourceTextModule::IsCjsModule(moduleType)) {
|
||||
JSHandle<JSTaggedValue> cjsModuleName(thread, SourceTextModule::GetModuleName(module.GetTaggedValue()));
|
||||
exports.Update(CjsModule::SearchFromModuleCache(thread, cjsModuleName).GetTaggedValue());
|
||||
CString cjsModuleName = SourceTextModule::GetModuleName(module.GetTaggedValue());
|
||||
JSHandle<JSTaggedValue> moduleNameHandle(thread->GetEcmaVM()->GetFactory()->NewFromUtf8(cjsModuleName));
|
||||
exports.Update(CjsModule::SearchFromModuleCache(thread, moduleNameHandle).GetTaggedValue());
|
||||
if (exports->IsHole()) {
|
||||
CString errorMsg =
|
||||
"Loading cjs module:" + ConvertToString(SourceTextModule::GetModuleName(resolvedModule)) + ", failed";
|
||||
"Loading cjs module:" + SourceTextModule::GetModuleName(resolvedModule) + ", failed";
|
||||
JSHandle<JSTaggedValue> exception(thread, JSTaggedValue::Exception());
|
||||
THROW_NEW_ERROR_WITH_MSG_AND_RETURN_VALUE(thread,
|
||||
ErrorType::SYNTAX_ERROR, errorMsg.c_str(), exception);
|
||||
@ -100,7 +100,7 @@ JSTaggedValue ModuleManagerHelper::GetModuleValueFromIndexBinding(JSThread *thre
|
||||
if (moduleManager->IsEvaluatedModule(recordNameStr)) {
|
||||
resolvedModule = moduleManager->HostGetImportedModule(recordNameStr);
|
||||
} else {
|
||||
auto isMergedAbc = !module->GetEcmaModuleRecordName().IsUndefined();
|
||||
auto isMergedAbc = !module->GetEcmaModuleRecordNameString().empty();
|
||||
CString fileName = ModulePathHelper::Utf8ConvertToString((binding->GetAbcFileName()));
|
||||
if (!JSPandaFileExecutor::LazyExecuteModule(thread, recordNameStr, fileName, isMergedAbc)) {
|
||||
LOG_ECMA(FATAL) << "LazyExecuteModule failed";
|
||||
@ -123,8 +123,8 @@ JSTaggedValue ModuleManagerHelper::GetModuleValueFromRecordBinding(JSThread *thr
|
||||
if (moduleManager->IsEvaluatedModule(recordNameStr)) {
|
||||
resolvedModule = moduleManager->HostGetImportedModule(recordNameStr);
|
||||
} else {
|
||||
auto isMergedAbc = !module->GetEcmaModuleRecordName().IsUndefined();
|
||||
CString fileName = ModulePathHelper::Utf8ConvertToString((module->GetEcmaModuleFilename()));
|
||||
auto isMergedAbc = !module->GetEcmaModuleRecordNameString().empty();
|
||||
CString fileName = module->GetEcmaModuleFilenameString();
|
||||
if (!JSPandaFileExecutor::LazyExecuteModule(thread, recordNameStr, fileName, isMergedAbc)) {
|
||||
LOG_ECMA(FATAL) << "LazyExecuteModule failed";
|
||||
}
|
||||
@ -151,7 +151,7 @@ JSTaggedValue ModuleManagerHelper::GetLazyModuleValueFromIndexBinding(JSThread *
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception());
|
||||
}
|
||||
} else {
|
||||
auto isMergedAbc = !module->GetEcmaModuleRecordName().IsUndefined();
|
||||
auto isMergedAbc = !module->GetEcmaModuleRecordNameString().empty();
|
||||
CString fileName = ModulePathHelper::Utf8ConvertToString(binding->GetAbcFileName());
|
||||
if (!JSPandaFileExecutor::LazyExecuteModule(thread, recordNameStr, fileName, isMergedAbc)) {
|
||||
LOG_ECMA(FATAL) << "LazyExecuteModule failed";
|
||||
@ -178,8 +178,8 @@ JSTaggedValue ModuleManagerHelper::GetLazyModuleValueFromRecordBinding(
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, JSTaggedValue::Exception());
|
||||
}
|
||||
} else {
|
||||
auto isMergedAbc = !module->GetEcmaModuleRecordName().IsUndefined();
|
||||
CString fileName = ModulePathHelper::Utf8ConvertToString(module->GetEcmaModuleFilename());
|
||||
auto isMergedAbc = !module->GetEcmaModuleRecordNameString().empty();
|
||||
CString fileName = module->GetEcmaModuleFilenameString();
|
||||
if (!JSPandaFileExecutor::LazyExecuteModule(thread, recordNameStr, fileName, isMergedAbc)) {
|
||||
LOG_ECMA(FATAL) << "LazyExecuteModule failed";
|
||||
}
|
||||
@ -203,10 +203,10 @@ JSTaggedValue ModuleManagerHelper::UpdateBindingAndGetModuleValue(JSThread *thre
|
||||
SourceTextModule::ResolveExportObject(thread, requiredModule, exports, exportName);
|
||||
// ii. If resolution is null or "ambiguous", throw a SyntaxError exception.
|
||||
if (resolution->IsNull() || resolution->IsString()) {
|
||||
CString requestMod = ModulePathHelper::ReformatPath(
|
||||
ModulePathHelper::Utf8ConvertToString(SourceTextModule::GetModuleName(requiredModule.GetTaggedValue())));
|
||||
CString recordStr = ModulePathHelper::ReformatPath(
|
||||
ModulePathHelper::Utf8ConvertToString(SourceTextModule::GetModuleName(module.GetTaggedValue())));
|
||||
CString requestMod = ModulePathHelper::ReformatPath(SourceTextModule::GetModuleName(
|
||||
requiredModule.GetTaggedValue()));
|
||||
CString recordStr = ModulePathHelper::ReformatPath(SourceTextModule::GetModuleName(
|
||||
module.GetTaggedValue()));
|
||||
CString msg = "the requested module '" + requestMod + SourceTextModule::GetResolveErrorReason(resolution) +
|
||||
ModulePathHelper::Utf8ConvertToString(bindingName) +
|
||||
"' which imported by '" + recordStr + "'";
|
||||
|
@ -260,8 +260,7 @@ HWTEST_F_L0(EcmaModuleTest, PreventExtensions_IsExtensible)
|
||||
SourceTextModule::AddLocalExportEntry(thread, module, localExportEntry2, 1, 2);
|
||||
JSHandle<TaggedArray> localExportEntries(thread, module->GetLocalExportEntries());
|
||||
CString baseFileName = "a.abc";
|
||||
JSHandle<EcmaString> moduleFilename = objectFactory->NewFromUtf8(baseFileName);
|
||||
module->SetEcmaModuleFilename(thread, moduleFilename);
|
||||
module->SetEcmaModuleFilenameString(baseFileName);
|
||||
ModuleManager *moduleManager = thread->GetCurrentEcmaContext()->GetModuleManager();
|
||||
JSHandle<JSTaggedValue> moduleRecord = JSHandle<JSTaggedValue>::Cast(module);
|
||||
moduleManager->AddResolveImportedModule(baseFileName, moduleRecord.GetTaggedValue());
|
||||
|
@ -3476,9 +3476,9 @@ Local<StringRef> FunctionRef::GetSourceCode(const EcmaVM *vm, int lineNumber)
|
||||
ecmascript::CString entry = JSPandaFile::ENTRY_FUNCTION_NAME;
|
||||
if (!jsPandaFile->IsBundlePack()) {
|
||||
JSFunction *function = JSFunction::Cast(func.GetTaggedValue().GetTaggedObject());
|
||||
JSTaggedValue recordName = function->GetRecordName();
|
||||
ASSERT(!recordName.IsHole());
|
||||
entry = ConvertToString(recordName);
|
||||
ecmascript::CString recordName = function->GetRecordName();
|
||||
ASSERT(!recordName.empty());
|
||||
entry = recordName;
|
||||
}
|
||||
|
||||
uint32_t mainMethodIndex = jsPandaFile->GetMainMethodIndex(entry);
|
||||
|
@ -1150,8 +1150,7 @@ HWTEST_F_L0(JSNApiTests, JSValueRef_IsModuleNamespaceObject)
|
||||
SourceTextModule::AddLocalExportEntry(thread_, module, localExportEntry2, 1, 2);
|
||||
JSHandle<TaggedArray> localExportEntries(thread_, module->GetLocalExportEntries());
|
||||
CString baseFileName = "a.abc";
|
||||
JSHandle<EcmaString> moduleFilename = objectFactory->NewFromUtf8(baseFileName);
|
||||
module->SetEcmaModuleFilename(thread_, moduleFilename);
|
||||
module->SetEcmaModuleFilenameString(baseFileName);
|
||||
ModuleManager *moduleManager = thread_->GetCurrentEcmaContext()->GetModuleManager();
|
||||
moduleManager->AddResolveImportedModule(baseFileName, module.GetTaggedValue());
|
||||
JSHandle<ModuleNamespace> np =
|
||||
|
@ -4700,8 +4700,6 @@ JSHandle<SourceTextModule> ObjectFactory::NewSourceTextModule()
|
||||
JSTaggedValue undefinedValue = thread_->GlobalConstants()->GetUndefined();
|
||||
obj->SetEnvironment(thread_, undefinedValue);
|
||||
obj->SetNamespace(thread_, undefinedValue);
|
||||
obj->SetEcmaModuleFilename(thread_, undefinedValue);
|
||||
obj->SetEcmaModuleRecordName(thread_, undefinedValue);
|
||||
obj->SetRequestedModules(thread_, undefinedValue);
|
||||
obj->SetImportEntries(thread_, undefinedValue);
|
||||
obj->SetLocalExportEntries(thread_, undefinedValue);
|
||||
@ -4723,6 +4721,8 @@ JSHandle<SourceTextModule> ObjectFactory::NewSourceTextModule()
|
||||
obj->SetIsNewBcVersion(false);
|
||||
obj->SetRegisterCounts(UINT16_MAX);
|
||||
obj->SetLazyImportStatus(ToUintPtr(nullptr));
|
||||
obj->SetEcmaModuleFilename(ToUintPtr(nullptr));
|
||||
obj->SetEcmaModuleRecordName(ToUintPtr(nullptr));
|
||||
obj->SetSharedType(SharedTypes::UNSENDABLE_MODULE);
|
||||
obj->SetSendableEnv(thread_, undefinedValue);
|
||||
return obj;
|
||||
|
@ -572,11 +572,10 @@ void PGOProfiler::HandlePGOPreDump()
|
||||
if (!methodValue.IsMethod()) {
|
||||
return;
|
||||
}
|
||||
JSTaggedValue recordNameValue = func->GetRecordName();
|
||||
if (!recordNameValue.IsString()) {
|
||||
CString recordName = func->GetRecordName();
|
||||
if (recordName.empty()) {
|
||||
return;
|
||||
}
|
||||
CString recordName = ConvertToString(recordNameValue);
|
||||
auto abcId = GetMethodAbcId(func);
|
||||
|
||||
if (current->HasExtraProfileTypeInfo()) {
|
||||
@ -623,12 +622,11 @@ void PGOProfiler::HandlePGODumpByDumpThread(bool force)
|
||||
current = PopFromProfileQueue();
|
||||
continue;
|
||||
}
|
||||
JSTaggedValue recordNameValue = func->GetRecordName();
|
||||
if (!recordNameValue.IsString()) {
|
||||
CString recordName = func->GetRecordName();
|
||||
if (recordName.empty()) {
|
||||
current = PopFromProfileQueue();
|
||||
continue;
|
||||
}
|
||||
CString recordName = ConvertToString(recordNameValue);
|
||||
auto abcId = GetMethodAbcId(func);
|
||||
|
||||
if (current->HasExtraProfileTypeInfo()) {
|
||||
|
@ -186,7 +186,7 @@ bool TryToRemoveSO(JSThread *thread, JSHandle<SourceTextModule> module)
|
||||
return false;
|
||||
}
|
||||
|
||||
CString soName = base::PathHelper::GetStrippedModuleName(ConvertToString(module->GetEcmaModuleRecordName()));
|
||||
CString soName = base::PathHelper::GetStrippedModuleName(module->GetEcmaModuleRecordNameString());
|
||||
return unloadNativeModuleCallback(soName.c_str());
|
||||
}
|
||||
|
||||
|
@ -108,8 +108,7 @@ JSHandle<JSTaggedValue> CjsModule::Load(JSThread *thread, JSHandle<EcmaString> &
|
||||
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
|
||||
filename = recordName;
|
||||
} else {
|
||||
JSHandle<JSTaggedValue> entrypointVal(thread, EcmaInterpreter::GetCurrentEntryPoint(thread).first);
|
||||
CString currentEntryPoint = ModulePathHelper::Utf8ConvertToString(entrypointVal.GetTaggedValue());
|
||||
CString currentEntryPoint = EcmaInterpreter::GetCurrentEntryPoint(thread).first;
|
||||
requestEntryPoint = ModulePathHelper::ConcatFileNameWithMerge(thread, jsPandaFile, filename,
|
||||
currentEntryPoint, requestStr);
|
||||
recordName = requestEntryPoint;
|
||||
|
@ -667,8 +667,6 @@ JSHandle<SourceTextModule> ObjectFactory::NewSSourceTextModule()
|
||||
JSTaggedValue undefinedValue = thread_->GlobalConstants()->GetUndefined();
|
||||
obj->SetEnvironment(thread_, undefinedValue);
|
||||
obj->SetNamespace(thread_, undefinedValue);
|
||||
obj->SetEcmaModuleFilename(thread_, undefinedValue);
|
||||
obj->SetEcmaModuleRecordName(thread_, undefinedValue);
|
||||
obj->SetRequestedModules(thread_, undefinedValue);
|
||||
obj->SetImportEntries(thread_, undefinedValue);
|
||||
obj->SetLocalExportEntries(thread_, undefinedValue);
|
||||
@ -690,6 +688,8 @@ JSHandle<SourceTextModule> ObjectFactory::NewSSourceTextModule()
|
||||
obj->SetIsNewBcVersion(false);
|
||||
obj->SetRegisterCounts(UINT16_MAX);
|
||||
obj->SetLazyImportStatus(ToUintPtr(nullptr));
|
||||
obj->SetEcmaModuleFilename(ToUintPtr(nullptr));
|
||||
obj->SetEcmaModuleRecordName(ToUintPtr(nullptr));
|
||||
obj->SetSharedType(SharedTypes::UNSENDABLE_MODULE);
|
||||
obj->SetSendableEnv(thread_, undefinedValue);
|
||||
return obj;
|
||||
|
@ -1674,7 +1674,7 @@ JSTaggedValue RuntimeStubs::RuntimeDynamicImport(JSThread *thread, const JSHandl
|
||||
if (jsPandaFile->IsBundlePack()) {
|
||||
dirPath.Update(factory->NewFromUtf8(currentfilename).GetTaggedValue());
|
||||
} else {
|
||||
recordName.Update(function->GetRecordName());
|
||||
recordName.Update(factory->NewFromUtf8(function->GetRecordName()));
|
||||
dirPath.Update(factory->NewFromUtf8(currentfilename).GetTaggedValue());
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,7 @@ void IsModuleNamespaceObjectFuzztest([[maybe_unused]]const uint8_t *data, size_t
|
||||
SourceTextModule::AddLocalExportEntry(vm->GetJSThread(), module, localExportEntry2, 1, ERROR_TYPE_LEN);
|
||||
JSHandle<TaggedArray> localExportEntries(vm->GetJSThread(), module->GetLocalExportEntries());
|
||||
CString baseFileName = "a.abc";
|
||||
JSHandle<EcmaString> moduleFilename = objectFactory->NewFromUtf8(baseFileName);
|
||||
module->SetEcmaModuleFilename(vm->GetJSThread(), moduleFilename);
|
||||
module->SetEcmaModuleFilenameString(baseFileName);
|
||||
ModuleManager *moduleManager = vm->GetJSThread()->GetCurrentEcmaContext()->GetModuleManager();
|
||||
moduleManager->AddResolveImportedModule(baseFileName, module.GetTaggedValue());
|
||||
JSHandle<ModuleNamespace> np = ModuleNamespace::ModuleNamespaceCreate(vm->GetJSThread(),
|
||||
|
Loading…
Reference in New Issue
Block a user