• Home
  • Raw
  • Download

Lines Matching full:module

16 #include "ecmascript/module/js_module_source_text.h"
28 #include "ecmascript/module/js_module_deregister.h"
29 #include "ecmascript/module/js_module_manager.h"
30 #include "ecmascript/module/js_module_namespace.h"
31 #include "ecmascript/module/module_data_extractor.h"
32 #include "ecmascript/module/module_path_helper.h"
40 …ing> SourceTextModule::GetExportedNames(JSThread *thread, const JSHandle<SourceTextModule> &module, in GetExportedNames() argument
44 // 1. Let module be this Source Text Module Record. in GetExportedNames()
45 // 2. If exportStarSet contains module, then in GetExportedNames()
46 if (exportStarSet->GetIdx(module.GetTaggedValue()) != TaggedArray::MAX_ARRAY_INDEX) { in GetExportedNames()
51 // 3. Append module to exportStarSet. in GetExportedNames()
54 newExportStarSet->Set(thread, len, module.GetTaggedValue()); in GetExportedNames()
56 JSTaggedValue entryValue = module->GetLocalExportEntries(); in GetExportedNames()
57 // 5. For each ExportEntry Record e in module.[[LocalExportEntries]], do in GetExportedNames()
60 // 6. For each ExportEntry Record e in module.[[IndirectExportEntries]], do in GetExportedNames()
61 entryValue = module->GetIndirectExportEntries(); in GetExportedNames()
64 entryValue = module->GetStarExportEntries(); in GetExportedNames()
70 // 7. For each ExportEntry Record e in module.[[StarExportEntries]], do in GetExportedNames()
75 // a. Let requestedModule be ? HostResolveImportedModule(module, e.[[ModuleRequest]]). in GetExportedNames()
77 SetExportName(thread, moduleRequest, module, exportedNames, newExportStarSet); in GetExportedNames()
84 // new way with module
86 …JSThread *thread, const JSHandle<SourceTextModule> &module, const JSHandle<JSTaggedValue> &moduleR… in HostResolveImportedModuleWithMerge() argument
92 // check if module need to be mock in HostResolveImportedModuleWithMerge()
101 * Don't load native module in HostResolveImportedModuleWithMerge()
117 ASSERT(module->GetEcmaModuleFilename().IsHeapObject()); in HostResolveImportedModuleWithMerge()
118 CString baseFilename = ConvertToString(module->GetEcmaModuleFilename()); in HostResolveImportedModuleWithMerge()
119 ASSERT(module->GetEcmaModuleRecordName().IsHeapObject()); in HostResolveImportedModuleWithMerge()
120 CString moduleRecordName = ConvertToString(module->GetEcmaModuleRecordName()); in HostResolveImportedModuleWithMerge()
144 … const JSHandle<SourceTextModule> &module, in HostResolveImportedModule() argument
153 ConvertToString(module->GetEcmaModuleFilename())); in HostResolveImportedModule()
161 bool SourceTextModule::CheckCircularImport(const JSHandle<SourceTextModule> &module, in CheckCircularImport() argument
166 // a. If module and r.[[Module]] are the same Module Record and in CheckCircularImport()
168 if (JSTaggedValue::SameValue(rr.first.GetTaggedValue(), module.GetTaggedValue()) && in CheckCircularImport()
179 … const JSHandle<SourceTextModule> &module, in ResolveExportObject() argument
183 // Let module be this Source Text Module Record. in ResolveExportObject()
186 // For CJS, if exports is not JSObject, means the CJS module use default output in ResolveExportObject()
190 return JSHandle<JSTaggedValue>::Cast(factory->NewResolvedIndexBindingRecord(module, -1)); in ResolveExportObject()
201 resolution = ResolveElementOfObject(thread, jsHclass, exportName, module); in ResolveExportObject()
207 … resolution = JSHandle<JSTaggedValue>::Cast(factory->NewResolvedIndexBindingRecord(module, entry)); in ResolveExportObject()
217 …dValue> SourceTextModule::ResolveExport(JSThread *thread, const JSHandle<SourceTextModule> &module, in ResolveExport() argument
221 // 1. Let module be this Source Text Module Record. in ResolveExport()
224 // 2.For each Record { [[Module]], [[ExportName]] } r in resolveVector, do in ResolveExport()
225 if (CheckCircularImport(module, exportName, resolveVector)) { in ResolveExport()
228 // 3. Append the Record { [[Module]]: module, [[ExportName]]: exportName } to resolveVector. in ResolveExport()
229 resolveVector.emplace_back(std::make_pair(module, exportName)); in ResolveExport()
230 // 4. For each ExportEntry Record e in module.[[LocalExportEntries]], do in ResolveExport()
231 JSHandle<JSTaggedValue> localExportEntriesTv(thread, module->GetLocalExportEntries()); in ResolveExport()
233 …e<JSTaggedValue> resolution = ResolveLocalExport(thread, localExportEntriesTv, exportName, module); in ResolveExport()
238 // 5. For each ExportEntry Record e in module.[[IndirectExportEntries]], do in ResolveExport()
239 JSHandle<JSTaggedValue> indirectExportEntriesTv(thread, module->GetIndirectExportEntries()); in ResolveExport()
242 … exportName, module, resolveVector); in ResolveExport()
249 …// In Aot static parse phase, some importModule maybe empty aot module, all elements will be undef… in ResolveExport()
253 // a. Assert: A default export was not explicitly defined by this module. in ResolveExport()
260 // 8. For each ExportEntry Record e in module.[[StarExportEntries]], do in ResolveExport()
261 JSTaggedValue starExportEntriesTv = module->GetStarExportEntries(); in ResolveExport()
277 module, starResolution, resolveVector); in ResolveExport()
292 // Get exported cjs module in InstantiateCJS()
341 LOG_FULL(FATAL) << "Invalid native module " << moduleName; in MakeAppArgs()
346 // use module name as so name in MakeAppArgs()
370 LOG_FULL(DEBUG) << "Request module is " << moduleRequestName; in LoadNativeModule()
427 // update required module in InitializeEnvironment()
441 // if not the same module, then don't have to update in InitializeEnvironment()
452 CString msg = "the requested module '" + in InitializeEnvironment()
461 // in.[[LocalName]], resolution.[[Module]], resolution.[[BindingName]]). in InitializeEnvironment()
477 …t SourceTextModule::HandleInstantiateException([[maybe_unused]] JSHandle<SourceTextModule> &module, in HandleInstantiateException() argument
480 // a. For each module m in stack, do in HandleInstantiateException()
492 // b. Assert: module.[[Status]] is "uninstantiated". in HandleInstantiateException()
493 ASSERT(module->GetStatus() == ModuleStatus::UNINSTANTIATED); in HandleInstantiateException()
504 JSHandle<SourceTextModule> module = JSHandle<SourceTextModule>::Cast(moduleHdl); in Instantiate() local
505 // 1. Let module be this Source Text Module Record. in Instantiate()
506 // 2. Assert: module.[[Status]] is one of UNLINKED, LINKED, EVALUATING-ASYNC, or EVALUATED. in Instantiate()
507 ModuleStatus status = module->GetStatus(); in Instantiate()
512 // 4. Let result be InnerModuleInstantiation(module, stack, 0). in Instantiate()
513 JSHandle<ModuleRecord> moduleRecord = JSHandle<ModuleRecord>::Cast(module); in Instantiate()
517 return HandleInstantiateException(module, stack, result); in Instantiate()
519 // 6. Assert: module.[[Status]] is one of LINKED, EVALUATING-ASYNC, or EVALUATED. in Instantiate()
520 status = module->GetStatus(); in Instantiate()
536 void SourceTextModule::DFSModuleInstantiation(JSHandle<SourceTextModule> &module, in DFSModuleInstantiation() argument
539 // 1. Assert: module occurs exactly once in stack. in DFSModuleInstantiation()
540 // 2. Assert: module.[[DFSAncestorIndex]] is less than or equal to module.[[DFSIndex]]. in DFSModuleInstantiation()
541 int dfsAncIdx = module->GetDFSAncestorIndex(); in DFSModuleInstantiation()
542 int dfsIdx = module->GetDFSIndex(); in DFSModuleInstantiation()
544 // 3. If module.[[DFSAncestorIndex]] equals module.[[DFSIndex]], then in DFSModuleInstantiation()
556 // iv. If requiredModule and module are the same Module Record, set done to true. in DFSModuleInstantiation()
557 … if (JSTaggedValue::SameValue(module.GetTaggedValue(), requiredModule.GetTaggedValue())) { in DFSModuleInstantiation()
565 … JSHandle<SourceTextModule> &module, in HandleInnerModuleInstantiation() argument
570 // a. Let requiredModule be ? HostResolveImportedModule(module, required). in HandleInnerModuleInstantiation()
572 JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName(); in HandleInnerModuleInstantiation()
575 SourceTextModule::HostResolveImportedModule(thread, module, required); in HandleInnerModuleInstantiation()
582 SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, required); in HandleInnerModuleInstantiation()
604 // i. Assert: requiredModule is a Source Text Module Record. in HandleInnerModuleInstantiation()
605 // ii. Set module.[[DFSAncestorIndex]] to min( in HandleInnerModuleInstantiation()
606 // module.[[DFSAncestorIndex]], requiredModule.[[DFSAncestorIndex]]). in HandleInnerModuleInstantiation()
607 … int dfsAncIdx = std::min(module->GetDFSAncestorIndex(), requiredModule->GetDFSAncestorIndex()); in HandleInnerModuleInstantiation()
608 module->SetDFSAncestorIndex(dfsAncIdx); in HandleInnerModuleInstantiation()
616 // 1. If module is not a Source Text Module Record, then in InnerModuleInstantiation()
618 // a. Perform ? module.Instantiate(). in InnerModuleInstantiation()
624 JSHandle<SourceTextModule> module = JSHandle<SourceTextModule>::Cast(moduleRecord); in InnerModuleInstantiation() local
625 …// 2. If module.[[Status]] is one of LINKING, LINKED, EVALUATING-ASYNC, or EVALUATED, then Return … in InnerModuleInstantiation()
626 ModuleStatus status = module->GetStatus(); in InnerModuleInstantiation()
633 // 3. Assert: module.[[Status]] is "uninstantiated". in InnerModuleInstantiation()
635 // 4. Set module.[[Status]] to "instantiating". in InnerModuleInstantiation()
636 module->SetStatus(ModuleStatus::INSTANTIATING); in InnerModuleInstantiation()
637 // 5. Set module.[[DFSIndex]] to index. in InnerModuleInstantiation()
638 module->SetDFSIndex(index); in InnerModuleInstantiation()
639 // 6. Set module.[[DFSAncestorIndex]] to index. in InnerModuleInstantiation()
640 module->SetDFSAncestorIndex(index); in InnerModuleInstantiation()
643 // 8. Append module to stack. in InnerModuleInstantiation()
644 stack.emplace_back(module); in InnerModuleInstantiation()
645 // 9. For each String required that is an element of module.[[RequestedModules]], do in InnerModuleInstantiation()
646 if (!module->GetRequestedModules().IsUndefined()) { in InnerModuleInstantiation()
647 JSHandle<TaggedArray> requestedModules(thread, module->GetRequestedModules()); in InnerModuleInstantiation()
652 …auto result = HandleInnerModuleInstantiation(thread, module, required, stack, index, excuteFromJob… in InnerModuleInstantiation()
659 // 10. Perform ? ModuleDeclarationEnvironmentSetup(module). in InnerModuleInstantiation()
660 if (module->GetIsNewBcVersion()) { in InnerModuleInstantiation()
661 SourceTextModule::ModuleDeclarationArrayEnvironmentSetup(thread, module); in InnerModuleInstantiation()
663 SourceTextModule::ModuleDeclarationEnvironmentSetup(thread, module); in InnerModuleInstantiation()
666 DFSModuleInstantiation(module, stack); in InnerModuleInstantiation()
671 const JSHandle<SourceTextModule> &module) in ModuleDeclarationEnvironmentSetup() argument
673 CheckResolvedBinding(thread, module); in ModuleDeclarationEnvironmentSetup()
674 if (module->GetImportEntries().IsUndefined()) { in ModuleDeclarationEnvironmentSetup()
678 // 2. Assert: All named exports from module are resolvable. in ModuleDeclarationEnvironmentSetup()
679 // 3. Let realm be module.[[Realm]]. in ModuleDeclarationEnvironmentSetup()
682 JSHandle<TaggedArray> importEntries(thread, module->GetImportEntries()); in ModuleDeclarationEnvironmentSetup()
686 // 6. Set module.[[Environment]] to env. in ModuleDeclarationEnvironmentSetup()
687 module->SetEnvironment(thread, map); in ModuleDeclarationEnvironmentSetup()
689 JSMutableHandle<JSTaggedValue> envRec(thread, module->GetEnvironment()); in ModuleDeclarationEnvironmentSetup()
691 // 8. For each ImportEntry Record in in module.[[ImportEntries]], do in ModuleDeclarationEnvironmentSetup()
702 // a. Let importedModule be ! HostResolveImportedModule(module, in.[[ModuleRequest]]). in ModuleDeclarationEnvironmentSetup()
704 JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName(); in ModuleDeclarationEnvironmentSetup()
707 SourceTextModule::HostResolveImportedModule(thread, module, moduleRequest); in ModuleDeclarationEnvironmentSetup()
713 SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, moduleRequest); in ModuleDeclarationEnvironmentSetup()
735 CString msg = "the requested module '" + in ModuleDeclarationEnvironmentSetup()
739 if (!module->GetEcmaModuleRecordName().IsUndefined()) { in ModuleDeclarationEnvironmentSetup()
740 … msg += "' which imported by '" + ConvertToString(module->GetEcmaModuleRecordName()) + "'"; in ModuleDeclarationEnvironmentSetup()
742 … msg += "' which imported by '" + ConvertToString(module->GetEcmaModuleFilename()) + "'"; in ModuleDeclarationEnvironmentSetup()
747 // in.[[LocalName]], resolution.[[Module]], resolution.[[BindingName]]). in ModuleDeclarationEnvironmentSetup()
755 module->SetEnvironment(thread, envRec); in ModuleDeclarationEnvironmentSetup()
759 … const JSHandle<SourceTextModule> &module) in ModuleDeclarationArrayEnvironmentSetup() argument
761 CheckResolvedIndexBinding(thread, module); in ModuleDeclarationArrayEnvironmentSetup()
762 if (module->GetImportEntries().IsUndefined()) { in ModuleDeclarationArrayEnvironmentSetup()
767 // 2. Assert: All named exports from module are resolvable. in ModuleDeclarationArrayEnvironmentSetup()
768 // 3. Let realm be module.[[Realm]]. in ModuleDeclarationArrayEnvironmentSetup()
771 JSHandle<TaggedArray> importEntries(thread, module->GetImportEntries()); in ModuleDeclarationArrayEnvironmentSetup()
774 // 6. Set module.[[Environment]] to env. in ModuleDeclarationArrayEnvironmentSetup()
775 module->SetEnvironment(thread, arr); in ModuleDeclarationArrayEnvironmentSetup()
778 // 8. For each ImportEntry Record in in module.[[ImportEntries]], do in ModuleDeclarationArrayEnvironmentSetup()
787 // a. Let importedModule be ! HostResolveImportedModule(module, in.[[ModuleRequest]]). in ModuleDeclarationArrayEnvironmentSetup()
789 JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName(); in ModuleDeclarationArrayEnvironmentSetup()
792 SourceTextModule::HostResolveImportedModule(thread, module, moduleRequest); in ModuleDeclarationArrayEnvironmentSetup()
798 SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, moduleRequest); in ModuleDeclarationArrayEnvironmentSetup()
815 CString msg = "the requested module '" + in ModuleDeclarationArrayEnvironmentSetup()
819 if (!module->GetEcmaModuleRecordName().IsUndefined()) { in ModuleDeclarationArrayEnvironmentSetup()
820 … msg += "' which imported by '" + ConvertToString(module->GetEcmaModuleRecordName()) + "'"; in ModuleDeclarationArrayEnvironmentSetup()
822 … msg += "' which imported by '" + ConvertToString(module->GetEcmaModuleFilename()) + "'"; in ModuleDeclarationArrayEnvironmentSetup()
832 // in.[[LocalName]], resolution.[[Module]], resolution.[[BindingName]]). in ModuleDeclarationArrayEnvironmentSetup()
836 module->SetEnvironment(thread, envRec); in ModuleDeclarationArrayEnvironmentSetup()
840 … const JSHandle<SourceTextModule> &module) in GetModuleNamespace() argument
843 // 1. Assert: module is an instance of a concrete subclass of Module Record. in GetModuleNamespace()
844 // 2. Assert: module.[[Status]] is not "uninstantiated". in GetModuleNamespace()
845 ASSERT(module->GetStatus() != ModuleStatus::UNINSTANTIATED); in GetModuleNamespace()
846 // 3. Let namespace be module.[[Namespace]]. in GetModuleNamespace()
847 … JSMutableHandle<JSTaggedValue> moduleNamespace(thread, module->GetNamespace().GetWeakRawValue()); in GetModuleNamespace()
850 // a. Let exportedNames be ? module.GetExportedNames(« »). in GetModuleNamespace()
852 …CVector<std::string> exportedNames = SourceTextModule::GetExportedNames(thread, module, exportStar… in GetModuleNamespace()
858 // i. Let resolution be ? module.ResolveExport(name, « »). in GetModuleNamespace()
862 SourceTextModule::ResolveExport(thread, module, nameHandle, resolveVector); in GetModuleNamespace()
870 JSHandle<JSTaggedValue> moduleTagged = JSHandle<JSTaggedValue>::Cast(module); in GetModuleNamespace()
878 void SourceTextModule::HandleEvaluateResult(JSThread *thread, JSHandle<SourceTextModule> &module, in HandleEvaluateResult() argument
885 // a. For each module m in stack, do in HandleEvaluateResult()
894 // b. Assert: module.[[Status]] is "evaluated" and module.[[EvaluationError]] is result. in HandleEvaluateResult()
895 status = module->GetStatus(); in HandleEvaluateResult()
896 ASSERT(status == ModuleStatus::EVALUATED && module->GetEvaluationError() == result); in HandleEvaluateResult()
908 // a. Assert: module.[[Status]] is either EVALUATING-ASYNC or EVALUATED. in HandleEvaluateResult()
909 status = module->GetStatus(); in HandleEvaluateResult()
911 // b. Assert: module.[[EvaluationError]] is EMPTY. in HandleEvaluateResult()
912 ASSERT(module->GetEvaluationError() == SourceTextModule::UNDEFINED_INDEX); in HandleEvaluateResult()
913 // c. If module.[[AsyncEvaluation]] is false, then in HandleEvaluateResult()
914 // i. Assert: module.[[Status]] is EVALUATED. in HandleEvaluateResult()
916 if (!module->IsAsyncEvaluating()) { in HandleEvaluateResult()
928 // 1. Let module be this Source Text Module Record. in Evaluate()
929 // 2. Assert: module.[[Status]] is one of LINKED, EVALUATING-ASYNC, or EVALUATED. in Evaluate()
930 JSMutableHandle<SourceTextModule> module(thread, moduleHdl); in Evaluate() local
931 ModuleStatus status = module->GetStatus(); in Evaluate()
934 …// 3. If module.[[Status]] is either EVALUATING-ASYNC or EVALUATED, set module to module.[[CycleRo… in Evaluate()
936 module.Update(module->GetCycleRoot()); in Evaluate()
938 // 4. If module.[[TopLevelCapability]] is not EMPTY, then in Evaluate()
939 // a. Return module.[[TopLevelCapability]].[[Promise]]. in Evaluate()
948 // 7. Set module.[[TopLevelCapability]] to capability. in Evaluate()
949 module->SetTopLevelCapability(thread, capability); in Evaluate()
950 // 8. Let result be Completion(InnerModuleEvaluation(module, stack, 0)). in Evaluate()
951 JSHandle<ModuleRecord> moduleRecord = JSHandle<ModuleRecord>::Cast(module); in Evaluate()
953 HandleEvaluateResult(thread, module, capability, stack, result); in Evaluate()
961 …SourceTextModule::EvaluateForConcurrent(JSThread *thread, const JSHandle<SourceTextModule> &module, in EvaluateForConcurrent() argument
964 // 1. Let module be this Source Text Module Record. in EvaluateForConcurrent()
965 // 2. Assert: module.[[Status]] is "instantiated" or "evaluated". in EvaluateForConcurrent()
966 [[maybe_unused]] ModuleStatus status = module->GetStatus(); in EvaluateForConcurrent()
968 // 4. Let result be InnerModuleEvaluation(module, stack, 0) in EvaluateForConcurrent()
969 JSHandle<ModuleRecord> moduleRecord = JSHandle<ModuleRecord>::Cast(module); in EvaluateForConcurrent()
985 // 1.If module is not a Cyclic Module Record, then in InnerModuleEvaluation()
987 // a. Let promise be ! module.Evaluate(). in InnerModuleEvaluation()
1006 JSHandle<SourceTextModule> module = JSHandle<SourceTextModule>::Cast(moduleRecord); in InnerModuleEvaluation() local
1007 // 2. If module.[[Status]] is either EVALUATING-ASYNC or EVALUATED, then in InnerModuleEvaluation()
1008 ModuleStatus status = module->GetStatus(); in InnerModuleEvaluation()
1010 // a. If module.[[EvaluationError]] is undefined, return index in InnerModuleEvaluation()
1011 if (module->GetEvaluationError() == SourceTextModule::UNDEFINED_INDEX) { in InnerModuleEvaluation()
1014 // Otherwise return module.[[EvaluationError]]. in InnerModuleEvaluation()
1015 return module->GetEvaluationError(); in InnerModuleEvaluation()
1017 // 3. If module.[[Status]] is "evaluating", return index. in InnerModuleEvaluation()
1021 // 4. Assert: module.[[Status]] is "instantiated". in InnerModuleEvaluation()
1023 // 5. Set module.[[Status]] to "evaluating". in InnerModuleEvaluation()
1024 module->SetStatus(ModuleStatus::EVALUATING); in InnerModuleEvaluation()
1025 // 6. Set module.[[DFSIndex]] to index. in InnerModuleEvaluation()
1026 module->SetDFSIndex(index); in InnerModuleEvaluation()
1027 // 7. Set module.[[DFSAncestorIndex]] to index. in InnerModuleEvaluation()
1028 module->SetDFSAncestorIndex(index); in InnerModuleEvaluation()
1029 // 8. Set module.[[PendingAsyncDependencies]] to 0. in InnerModuleEvaluation()
1030 module->SetPendingAsyncDependencies(0); in InnerModuleEvaluation()
1033 // 10. Append module to stack. in InnerModuleEvaluation()
1034 stack.emplace_back(module); in InnerModuleEvaluation()
1035 // 11. For each String required that is an element of module.[[RequestedModules]], do in InnerModuleEvaluation()
1036 if (!module->GetRequestedModules().IsUndefined()) { in InnerModuleEvaluation()
1037 JSHandle<TaggedArray> requestedModules(thread, module->GetRequestedModules()); in InnerModuleEvaluation()
1042 // a. Let requiredModule be ! HostResolveImportedModule(module, required). in InnerModuleEvaluation()
1044 JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName(); in InnerModuleEvaluation()
1047 SourceTextModule::HostResolveImportedModule(thread, module, required); in InnerModuleEvaluation()
1053 SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, required); in InnerModuleEvaluation()
1059 InstantiateNativeModule(thread, module, requiredModule, required, moduleType); in InnerModuleEvaluation()
1072 // c. If requiredModule is a Cyclic Module Record, then in InnerModuleEvaluation()
1087 // 1. Set module.[[DFSAncestorIndex]] to min(module.[[DFSAncestorIndex]], in InnerModuleEvaluation()
1089 … int dfsAncIdx = std::min(module->GetDFSAncestorIndex(), requiredModule->GetDFSAncestorIndex()); in InnerModuleEvaluation()
1090 module->SetDFSAncestorIndex(dfsAncIdx); in InnerModuleEvaluation()
1105 … // 1. Set module.[[PendingAsyncDependencies]] to module.[[PendingAsyncDependencies]] + 1. in InnerModuleEvaluation()
1106 // 2. Append module to requiredModule.[[AsyncParentModules]]. in InnerModuleEvaluation()
1108 module->SetPendingAsyncDependencies(module->GetPendingAsyncDependencies() + 1); in InnerModuleEvaluation()
1109 AddAsyncParentModule(thread, requiredModule, module); in InnerModuleEvaluation()
1111 // if requiredModule is CommonJS Module, instantiate here (after CommonJS execution). in InnerModuleEvaluation()
1113 InstantiateCJS(thread, module, requiredModule); in InnerModuleEvaluation()
1117 int pendingAsyncDependencies = module->GetPendingAsyncDependencies(); in InnerModuleEvaluation()
1118 bool hasTLA = module->GetHasTLA(); in InnerModuleEvaluation()
1120 // 12. If module.[[PendingAsyncDependencies]] > 0 or module.[[HasTLA]] is true, then in InnerModuleEvaluation()
1122 // a. Assert: module.[[AsyncEvaluation]] is false and was never previously set to true. in InnerModuleEvaluation()
1123 ASSERT(module->GetAsyncEvaluatingOrdinal() == NOT_ASYNC_EVALUATED); in InnerModuleEvaluation()
1124 // b. Set module.[[AsyncEvaluation]] to true. in InnerModuleEvaluation()
1125 module->SetAsyncEvaluatingOrdinal(moduleManager->NextModuleAsyncEvaluatingOrdinal()); in InnerModuleEvaluation()
1126 // d. If module.[[PendingAsyncDependencies]] = 0, perform ExecuteAsyncModule(module). in InnerModuleEvaluation()
1128 SourceTextModule::ExecuteAsyncModule(thread, module, buffer, size, excuteFromJob); in InnerModuleEvaluation()
1132 // 13. Else, Perform ? module.ExecuteModule(). in InnerModuleEvaluation()
1133 SourceTextModule::ModuleExecution(thread, module, buffer, size, excuteFromJob); in InnerModuleEvaluation()
1136 // 14. Assert: module occurs exactly once in stack. in InnerModuleEvaluation()
1137 // 15. Assert: module.[[DFSAncestorIndex]] ≤ module.[[DFSIndex]]. in InnerModuleEvaluation()
1138 int dfsAncIdx = module->GetDFSAncestorIndex(); in InnerModuleEvaluation()
1139 int dfsIdx = module->GetDFSIndex(); in InnerModuleEvaluation()
1141 // 16. If module.[[DFSAncestorIndex]] = module.[[DFSIndex]], then in InnerModuleEvaluation()
1151 // iii. Assert: requiredModule is a Cyclic Module Record. in InnerModuleEvaluation()
1159 // vi. If requiredModule and module are the same Module Record, set done to true. in InnerModuleEvaluation()
1160 … if (JSTaggedValue::SameValue(module.GetTaggedValue(), requiredModule.GetTaggedValue())) { in InnerModuleEvaluation()
1163 // vii. Set requiredModule.[[CycleRoot]] to module. in InnerModuleEvaluation()
1164 requiredModule->SetCycleRoot(thread, module); in InnerModuleEvaluation()
1170 …rceTextModule::HandleConcurrentEvaluateResult(JSThread *thread, JSHandle<SourceTextModule> &module, in HandleConcurrentEvaluateResult() argument
1176 // a. For each module m in stack, do in HandleConcurrentEvaluateResult()
1185 // b. Assert: module.[[Status]] is "evaluated" and module.[[EvaluationError]] is result. in HandleConcurrentEvaluateResult()
1186 status = module->GetStatus(); in HandleConcurrentEvaluateResult()
1187 ASSERT(status == ModuleStatus::EVALUATED && module->GetEvaluationError() == result); in HandleConcurrentEvaluateResult()
1190 // a. Assert: module.[[Status]] is either EVALUATING-ASYNC or EVALUATED. in HandleConcurrentEvaluateResult()
1191 status = module->GetStatus(); in HandleConcurrentEvaluateResult()
1193 // b. Assert: module.[[EvaluationError]] is EMPTY. in HandleConcurrentEvaluateResult()
1194 ASSERT(module->GetEvaluationError() == SourceTextModule::UNDEFINED_INDEX); in HandleConcurrentEvaluateResult()
1195 // c. If module.[[AsyncEvaluation]] is false, then in HandleConcurrentEvaluateResult()
1196 // i. Assert: module.[[Status]] is EVALUATED. in HandleConcurrentEvaluateResult()
1197 if (!module->IsAsyncEvaluating()) { in HandleConcurrentEvaluateResult()
1208 JSHandle<SourceTextModule> module = JSHandle<SourceTextModule>::Cast(moduleRecord); in ModuleEvaluation() local
1209 if (!module->GetRequestedModules().IsUndefined()) { in ModuleEvaluation()
1210 JSHandle<TaggedArray> requestedModules(thread, module->GetRequestedModules()); in ModuleEvaluation()
1216 // skip the unused module in ModuleEvaluation()
1221 JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName(); in ModuleEvaluation()
1223 … requiredModule.Update(SourceTextModule::HostResolveImportedModule(thread, module, required)); in ModuleEvaluation()
1226 …uiredModule.Update(SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, required)); in ModuleEvaluation()
1231 InstantiateNativeModule(thread, module, requiredModule, required, moduleType); in ModuleEvaluation()
1248 InstantiateCJS(thread, module, requiredModule); in ModuleEvaluation()
1256 const JSHandle<SourceTextModule> &module, const void *buffer, size_t size, bool excuteFromJob) in ModuleExecution() argument
1258 JSTaggedValue moduleFileName = module->GetEcmaModuleFilename(); in ModuleExecution()
1263 JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName(); in ModuleExecution()
1288 void SourceTextModule::AddImportEntry(JSThread *thread, const JSHandle<SourceTextModule> &module, in AddImportEntry() argument
1292 JSTaggedValue importEntries = module->GetImportEntries(); in AddImportEntry()
1296 module->SetImportEntries(thread, array); in AddImportEntry()
1302 module->SetImportEntries(thread, entries); in AddImportEntry()
1309 …d SourceTextModule::AddLocalExportEntry(JSThread *thread, const JSHandle<SourceTextModule> &module, in AddLocalExportEntry() argument
1313 JSTaggedValue localExportEntries = module->GetLocalExportEntries(); in AddLocalExportEntry()
1317 module->SetLocalExportEntries(thread, array); in AddLocalExportEntry()
1324 …ourceTextModule::AddIndirectExportEntry(JSThread *thread, const JSHandle<SourceTextModule> &module, in AddIndirectExportEntry() argument
1329 JSTaggedValue indirectExportEntries = module->GetIndirectExportEntries(); in AddIndirectExportEntry()
1333 module->SetIndirectExportEntries(thread, array); in AddIndirectExportEntry()
1340 …id SourceTextModule::AddStarExportEntry(JSThread *thread, const JSHandle<SourceTextModule> &module, in AddStarExportEntry() argument
1344 JSTaggedValue starExportEntries = module->GetStarExportEntries(); in AddStarExportEntry()
1348 module->SetStarExportEntries(thread, array); in AddStarExportEntry()
1379 …THROW_REFERENCE_ERROR_AND_RETURN(thread, "module environment is undefined", JSTaggedValue::Excepti… in GetModuleValue()
1394 …THROW_REFERENCE_ERROR_AND_RETURN(thread, "module environment is undefined", JSTaggedValue::Excepti… in GetModuleValue()
1441 JSHandle<SourceTextModule> module(thread, this); in StoreModuleValue() local
1442 JSTaggedValue localExportEntries = module->GetLocalExportEntries(); in StoreModuleValue()
1445 JSHandle<JSTaggedValue> data(thread, module->GetNameDictionary()); in StoreModuleValue()
1451 module->SetNameDictionary(thread, data); in StoreModuleValue()
1460 JSHandle<SourceTextModule> module(thread, this); in StoreModuleValue() local
1461 JSMutableHandle<JSTaggedValue> data(thread, module->GetNameDictionary()); in StoreModuleValue()
1468 module->SetNameDictionary(thread, data); in StoreModuleValue()
1472 const JSHandle<SourceTextModule> &module, in SetExportName() argument
1477 JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName(); in SetExportName()
1480 SourceTextModule::HostResolveImportedModule(thread, module, moduleRequest); in SetExportName()
1486 SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, moduleRequest); in SetExportName()
1507 … const JSHandle<SourceTextModule> &module, in GetStarResolution() argument
1513 // a. Let importedModule be ? HostResolveImportedModule(module, e.[[ModuleRequest]]). in GetStarResolution()
1515 JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName(); in GetStarResolution()
1518 SourceTextModule::HostResolveImportedModule(thread, module, moduleRequest); in GetStarResolution()
1524 SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, moduleRequest); in GetStarResolution()
1532 …// if step into GetStarResolution in aot phase, the module must be a normal SourceTextModule not a… in GetStarResolution()
1533 …// aot module. Sometimes for normal module, if indirectExportEntries, localExportEntries, starExpo… in GetStarResolution()
1534 // all don't have right exportName which means the export element is not from this module, in GetStarResolution()
1554 … // 2. If resolution.[[Module]] and starResolution.[[Module]] are not the same Module Record or in GetStarResolution()
1588 // a. Assert: module provides the direct binding for this export. in AddExportName()
1599 … const JSHandle<SourceTextModule> &module) in ResolveElementOfObject() argument
1604 return JSHandle<JSTaggedValue>::Cast(factory->NewResolvedIndexBindingRecord(module, idx)); in ResolveElementOfObject()
1612 … const JSHandle<SourceTextModule> &module) in ResolveLocalExport() argument
1623 // if module is type of CommonJS or native, export first, check after execution. in ResolveLocalExport()
1624 auto moduleType = module->GetTypes(); in ResolveLocalExport()
1626 … return JSHandle<JSTaggedValue>::Cast(factory->NewResolvedBindingRecord(module, exportName)); in ResolveLocalExport()
1630 // Adapter new module in ResolveLocalExport()
1631 if (module->GetIsNewBcVersion()) { in ResolveLocalExport()
1632 return JSHandle<JSTaggedValue>::Cast(factory->NewResolvedIndexBindingRecord(module, in ResolveLocalExport()
1635 // i. Assert: module provides the direct binding for this export. in ResolveLocalExport()
1636 … // ii. Return ResolvedBinding Record { [[Module]]: module, [[BindingName]]: e.[[LocalName]] }. in ResolveLocalExport()
1638 … return JSHandle<JSTaggedValue>::Cast(factory->NewResolvedBindingRecord(module, localName)); in ResolveLocalExport()
1647 … const JSHandle<SourceTextModule> &module, in ResolveIndirectExport() argument
1661 // i. Assert: module imports a specific binding for this export. in ResolveIndirectExport()
1662 // ii. Let importedModule be ? HostResolveImportedModule(module, e.[[ModuleRequest]]). in ResolveIndirectExport()
1665 JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName(); in ResolveIndirectExport()
1667 …requestedModule.Update(SourceTextModule::HostResolveImportedModule(thread, module, moduleRequest)); in ResolveIndirectExport()
1671 … SourceTextModule::HostResolveImportedModuleWithMerge(thread, module, moduleRequest)); in ResolveIndirectExport()
1682 … SourceTextModule::CheckResolvedBinding(JSThread *thread, const JSHandle<SourceTextModule> &module) in CheckResolvedBinding() argument
1685 // 1. For each ExportEntry Record e in module.[[IndirectExportEntries]], do in CheckResolvedBinding()
1686 JSTaggedValue indirectExportEntriesTv = module->GetIndirectExportEntries(); in CheckResolvedBinding()
1697 // a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « »). in CheckResolvedBinding()
1701 SourceTextModule::ResolveExport(thread, module, exportName, resolveVector); in CheckResolvedBinding()
1704 CString msg = "the requested module '" + in CheckResolvedBinding()
1708 if (!module->GetEcmaModuleRecordName().IsUndefined()) { in CheckResolvedBinding()
1709 … msg += "' which exported by '" + ConvertToString(module->GetEcmaModuleRecordName()) + "'"; in CheckResolvedBinding()
1711 … msg += "' which exported by '" + ConvertToString(module->GetEcmaModuleFilename()) + "'"; in CheckResolvedBinding()
1720 …ceTextModule::CheckResolvedIndexBinding(JSThread *thread, const JSHandle<SourceTextModule> &module) in CheckResolvedIndexBinding() argument
1723 // 1. For each ExportEntry Record e in module.[[IndirectExportEntries]], do in CheckResolvedIndexBinding()
1724 JSTaggedValue indirectExportEntriesTv = module->GetIndirectExportEntries(); in CheckResolvedIndexBinding()
1735 // a. Let resolution be ? module.ResolveExport(e.[[ExportName]], « »). in CheckResolvedIndexBinding()
1739 SourceTextModule::ResolveExport(thread, module, exportName, resolveVector); in CheckResolvedIndexBinding()
1742 CString msg = "the requested module '" + in CheckResolvedIndexBinding()
1746 if (!module->GetEcmaModuleRecordName().IsUndefined()) { in CheckResolvedIndexBinding()
1747 … msg += "' which exported by '" + ConvertToString(module->GetEcmaModuleRecordName()) + "'"; in CheckResolvedIndexBinding()
1749 … msg += "' which exported by '" + ConvertToString(module->GetEcmaModuleFilename()) + "'"; in CheckResolvedIndexBinding()
1758 SourceTextModule *module = SourceTextModule::Cast(currentModule.GetTaggedObject()); in GetModuleName() local
1759 JSTaggedValue recordName = module->GetEcmaModuleRecordName(); in GetModuleName()
1761 return module->GetEcmaModuleFilename(); in GetModuleName()
1776 void SourceTextModule::AddAsyncParentModule(JSThread *thread, JSHandle<SourceTextModule> &module, in AddAsyncParentModule() argument
1780 JSTaggedValue asyncParentModules = module->GetAsyncParentModules(); in AddAsyncParentModule()
1784 module->SetAsyncParentModules(thread, array); in AddAsyncParentModule()
1789 module->SetAsyncParentModules(thread, array); in AddAsyncParentModule()
1793 …id SourceTextModule::ExecuteAsyncModule(JSThread *thread, const JSHandle<SourceTextModule> &module, in ExecuteAsyncModule() argument
1796 // 1. Assert: module.[[Status]] is either EVALUATING or EVALUATING-ASYNC. in ExecuteAsyncModule()
1797 …ASSERT(module->GetStatus() == ModuleStatus::EVALUATING || module->GetStatus() == ModuleStatus::EVA… in ExecuteAsyncModule()
1798 // 2. Assert: module.[[HasTLA]] is true. in ExecuteAsyncModule()
1799 ASSERT(module->GetHasTLA()); in ExecuteAsyncModule()
1800 JSTaggedValue moduleFileName = module->GetEcmaModuleFilename(); in ExecuteAsyncModule()
1805 JSTaggedValue moduleRecordName = module->GetEcmaModuleRecordName(); in ExecuteAsyncModule()
1831 …// 4. Let fulfilledClosure be a new Abstract Closure with no parameters that captures module and p… in ExecuteAsyncModule()
1833 // a. Perform AsyncModuleExecutionFulfilled(module). in ExecuteAsyncModule()
1836 …rejectedClosure be a new Abstract Closure with parameters (error) that captures module and performs in ExecuteAsyncModule()
1838 // a. Perform AsyncModuleExecutionRejected(module, error). in ExecuteAsyncModule()
1847 onFulfilled->SetModule(thread, module); in ExecuteAsyncModule()
1851 onRejected->SetModule(thread, module); in ExecuteAsyncModule()
1860 …rceTextModule::GatherAvailableAncestors(JSThread *thread, const JSHandle<SourceTextModule> &module, in GatherAvailableAncestors() argument
1864 JSTaggedValue asyncParentModulesValue = module->GetAsyncParentModules(); in GatherAvailableAncestors()
1871 // 1. For each Cyclic Module Record m of module.[[AsyncParentModules]], do in GatherAvailableAncestors()
1901 …xtModule::AsyncModuleExecutionFulfilled(JSThread *thread, const JSHandle<SourceTextModule> &module) in AsyncModuleExecutionFulfilled() argument
1903 // 1. If module.[[Status]] is EVALUATED, then in AsyncModuleExecutionFulfilled()
1904 // a. Assert: module.[[EvaluationError]] is not EMPTY. in AsyncModuleExecutionFulfilled()
1906 if (module->GetStatus() == ModuleStatus::EVALUATED) { in AsyncModuleExecutionFulfilled()
1907 ASSERT(module->GetEvaluationError() != SourceTextModule::UNDEFINED_INDEX); in AsyncModuleExecutionFulfilled()
1910 // 2. Assert: module.[[Status]] is EVALUATING-ASYNC. in AsyncModuleExecutionFulfilled()
1911 ASSERT(module->GetStatus() == ModuleStatus::EVALUATING_ASYNC); in AsyncModuleExecutionFulfilled()
1912 // 3. Assert: module.[[AsyncEvaluation]] is true. in AsyncModuleExecutionFulfilled()
1913 ASSERT(module->IsAsyncEvaluating()); in AsyncModuleExecutionFulfilled()
1914 // 4. Assert: module.[[EvaluationError]] is EMPTY. in AsyncModuleExecutionFulfilled()
1915 ASSERT(module->GetEvaluationError() == SourceTextModule::UNDEFINED_INDEX); in AsyncModuleExecutionFulfilled()
1916 // 5. Set module.[[AsyncEvaluation]] to false. in AsyncModuleExecutionFulfilled()
1917 module->SetAsyncEvaluatingOrdinal(ASYNC_EVALUATE_DID_FINISH); in AsyncModuleExecutionFulfilled()
1918 // 6. Set module.[[Status]] to EVALUATED. in AsyncModuleExecutionFulfilled()
1919 module->SetStatus(ModuleStatus::EVALUATED); in AsyncModuleExecutionFulfilled()
1920 // 7. If module.[[TopLevelCapability]] is not EMPTY, then in AsyncModuleExecutionFulfilled()
1921 // a. Assert: module.[[CycleRoot]] is module. in AsyncModuleExecutionFulfilled()
1922 // b. Perform ! Call(module.[[TopLevelCapability]].[[Resolve]], undefined, « undefined »). in AsyncModuleExecutionFulfilled()
1924 JSTaggedValue topLevelCapabilityValue = module->GetTopLevelCapability(); in AsyncModuleExecutionFulfilled()
1926 ASSERT(JSTaggedValue::SameValue(module->GetCycleRoot(), module.GetTaggedValue())); in AsyncModuleExecutionFulfilled()
1939 // 9. Perform GatherAvailableAncestors(module, execList). in AsyncModuleExecutionFulfilled()
1942 GatherAvailableAncestors(thread, module, execList); in AsyncModuleExecutionFulfilled()
1945 // 12. For each Cyclic Module Record m of sortedExecList, do in AsyncModuleExecutionFulfilled()
1988 …extModule::AsyncModuleExecutionRejected(JSThread *thread, const JSHandle<SourceTextModule> &module, in AsyncModuleExecutionRejected() argument
1991 // 1. If module.[[Status]] is EVALUATED, then in AsyncModuleExecutionRejected()
1992 // a. Assert: module.[[EvaluationError]] is not EMPTY. in AsyncModuleExecutionRejected()
1994 if (module->GetStatus() == ModuleStatus::EVALUATED) { in AsyncModuleExecutionRejected()
1995 ASSERT(module->GetEvaluationError() != SourceTextModule::UNDEFINED_INDEX); in AsyncModuleExecutionRejected()
1998 // 2. Assert: module.[[Status]] is EVALUATING-ASYNC. in AsyncModuleExecutionRejected()
1999 ASSERT(module->GetStatus() == ModuleStatus::EVALUATING_ASYNC); in AsyncModuleExecutionRejected()
2000 // 3. Assert: module.[[AsyncEvaluation]] is true. in AsyncModuleExecutionRejected()
2001 ASSERT(module->IsAsyncEvaluating()); in AsyncModuleExecutionRejected()
2002 // 4. Assert: module.[[EvaluationError]] is EMPTY. in AsyncModuleExecutionRejected()
2003 ASSERT(module->GetEvaluationError() == SourceTextModule::UNDEFINED_INDEX); in AsyncModuleExecutionRejected()
2004 // 5. Set module.[[EvaluationError]] to ThrowCompletion(error). in AsyncModuleExecutionRejected()
2005 module->SetEvaluationError(MODULE_ERROR); in AsyncModuleExecutionRejected()
2006 // 6. Set module.[[Status]] to EVALUATED. in AsyncModuleExecutionRejected()
2007 module->SetStatus(ModuleStatus::EVALUATED); in AsyncModuleExecutionRejected()
2008 // 7. For each Cyclic Module Record m of module.[[AsyncParentModules]], do in AsyncModuleExecutionRejected()
2011 JSTaggedValue asyncParentModulesValue = module->GetAsyncParentModules(); in AsyncModuleExecutionRejected()
2022 // 8. If module.[[TopLevelCapability]] is not EMPTY, then in AsyncModuleExecutionRejected()
2023 // a. Assert: module.[[CycleRoot]] is module. in AsyncModuleExecutionRejected()
2024 // b. Perform ! Call(module.[[TopLevelCapability]].[[Reject]], undefined, « error »). in AsyncModuleExecutionRejected()
2025 JSTaggedValue topLevelCapabilityValue = module->GetTopLevelCapability(); in AsyncModuleExecutionRejected()
2032 ASSERT(JSTaggedValue::SameValue(module->GetCycleRoot(), module.GetTaggedValue())); in AsyncModuleExecutionRejected()
2052 JSHandle<SourceTextModule> module(thread, fulfilledFunc->GetModule()); in AsyncModuleFulfilledFunc() local
2053 AsyncModuleExecutionFulfilled(thread, module); in AsyncModuleFulfilledFunc()
2065 JSHandle<SourceTextModule> module(thread, rejectedFunc->GetModule()); in AsyncModuleRejectedFunc() local
2067 AsyncModuleExecutionRejected(thread, module, value.GetTaggedValue()); in AsyncModuleRejectedFunc()