Files
palemoon27/js/src/builtin/Module.js
T
roytam1 39770f3213 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1274192 part 1 - make the MediaDecoderReaderWrapper as a proxy of WaitForData(); r=jwwang (9debdca9a9)
- Bug 1274192 part 2 - make MDSM and SeekTask to adopt new MediaDecoderReaderWrapper API; r=jwwang (156f924dc9)
- Bug 1276495: Don't reset audio promises for video only seek. r=jwwang,jya (c4632c7ff6)
- Bug 1276318, part 1 - Fix leading tabs in ipc/glue. r=billm (46bcc4ccb3)
- Bug 1035125 Part 6: Take Chromium commit 3181ba39ee787e1b40f4aea4be23f4f666ad0945 to add Windows 10 version to enumeration. r=aklotz (af62c8065f)
- Bug 1270752 - Fix lifetime of buffer passed to PR_SetEnv(). r=jduell (bfce06ebea)
- Bug 1275117 - Fix static strings leaks when mozlogging is on. r=jduell (8e9066c5d7)
- Bug 1273048 - Add MOZ_GCC_VERSION_AT_MOST macro. r=froydnj (cfb5acdbe6)
- Bug 1269968 - Remove unnecessary deduction on RefPtr.h. r=froydnj (30cf9bbf47)
- Bug 525063 - add attribute to mark member variables that should be skipped by clang plugin initialization checker. r=nfroyd (78aa863f88)
- Bug 1278391 - add move constructor to EnumeratedArray (r=njn) (5effe4e473)
- Bug 1268518: Update basic-integer tests for rotations + clean up; r=sunfish (46827b6211)
- Bug 1270370 - Part 1: Move SetIteratorObject to MapObject.h; r=jorendorff (01a27fbd50)
- Bug 1270370 - Part 2: Expose MapIterator and SetIterator through ESClassValues; r=jorendorff (3edb3c7551)
- Bug 1267551 (part 3) - Use MOZ_MUST_USE more in js/src/builtin/. r=jonco. (ea96d0fae0)
- Bug 1267551 (part 4) - Use MOZ_MUST_USE more in js/src/asmjs/. r=bbouvier. (3e622c736d)
- Bug 1268910: Refactor WebAssembly trap handling; r=luke (b59394a287)
- Bug 1268910: Trap on edge cases for integer div/mod; r=sunfish (3d85230cc8)
- Bug 1267551 (part 5) - Use MOZ_MUST_USE more in js/src/ctypes/. r=sfink. (e6580fb645)
- Bug 1267551 (part 6) - Remove dead GenerateBlockId declaration. r=jorendorff. (74afcc549e)
- Bug 1240072 - Add public JS APIs related to modules r=shu Bug 1267551 (part 7) - Use MOZ_MUST_USE more in js/src/frontend/. r=jorendorff. (5275c57768)
- Bug 1267551 (part 8) - Use MOZ_MUST_USE more in js/src/gc/. r=terrence. (2572cc1c58)
- Bug 1261063 - Part 1 - Remove public Telemetry functions that return raw histogram instances. r=chutten (3a68653c8f)
- Bug 1261063 - Part 2 - Expose C++ function to clear Telemetry histograms. r=chutten (1f42f6aa1e)
- Bug 1261063 - Part 3 - Make RasterImage use the public Telemetry API. r=tnikkel (0f564f3836)
- Bug 1261063 - Part 4 - Use a count histogram for WebRTC call counts. r=jesup (b6b7b649e0)
- Bug 1270073 - Point to Telemetry documentation in Telemetry.h. r=chutten (517279b284)
- Bug 1261052 - Move C++ histogram implementation code into a separate module. r=gfritzsche. (66bcb1e167)
- Bug 1145164 - Allow non-unitary increments to count histograms. r=gfritzsche (507e076e28)
- Bug 1173447 - Add test for incremental pre-barriers when storing things under roots, r=jonco (caf8bd16be)
- Bug 1267551 (part 10) - Use MOZ_MUST_USE in AutoVectorRooterBase. r=terrence. (2c5ed87a9f)
- This catches a missing check. (b2fcd30fc5)
- Bug 1267551 (part 11b) - Follow-up to fix Android bustage. r=me (f464ca7b98)
- Bug 1271854 - Part 1: Allow specifying multiple GC zeal levels; r=terrence (da3c3e1281)
- Bug 1271854 - Part 2: Allow specifying zeal modes by name as well; r=terrence (f63926e45b)
- Bug 1271854 - Part 3: Avoid saving the GC zeal string inside the JS shell; r=terrence (f09b262e55)
- Bug 1270062 - Unbust Windows full duplex. a=Tomcat (3c8b5887b6)
- Bug 1270062 - Update libcubeb. rs=jesup (71805cb0e0)
- Bug 1270004 - Update libcubeb. rs=jesup (2d90b9662f)
- Bug 1280280 - Update cubeb to 073c9f011114. r=kinetik (6bee6a7f21)
- Bug 1280280 - Update media/libcube/update.sh to add cubeb_jack.cpp, and sort the list of files. r=kinetik (430b7533c4)
- Bug 1272604 - Add a zeal mode to check the heap after a moving GC r=terrence (85c018d71f)
- Bug 1272604 - Fix bad implicit conversion constructor build error r=me (5c4e1dbc44)
- Bug 1272604 - Fix hazard analysis failure r=me (0591aa2dca)
- Bug 1232417 - Use a Variant to represent the CrossCompartmentWrapperMap key; r=jonco (512da0bab3)
- Bug 1269928 - Fold DirectProxyHandler into Wrapper, which is now its only (non-test) consumer. r=efaust (7c6bb6e898)
- Bug 1273639 - Add a nonunified spidermonkey build, r=terrence (d6fa13545c)
- Bug 1273639 - Fix nonunified spidermonkey builds, r=terrence (3e0544510d)
- Bug 1273180 - Trigger major GC if necessary after minor GC r=terrence (a9a9be8b17)
- Bug 1268992 - Assert that the heap is empty after a shutdown GC; r=jonco (fe3ac5bdd6)
- Bug 1273908 - Refactor GC to make it easier to add new kinds of GC thing r=terrence (51c92e1b05)
2024-10-09 21:36:44 +08:00

281 lines
9.4 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// 15.2.1.16.2 GetExportedNames(exportStarSet)
function ModuleGetExportedNames(exportStarSet = [])
{
if (!IsObject(this) || !IsModule(this)) {
return callFunction(CallModuleMethodIfWrapped, this, exportStarSet,
"ModuleGetExportedNames");
}
// Step 1
let module = this;
// Step 2
if (callFunction(ArrayIncludes, exportStarSet, module))
return [];
// Step 3
_DefineDataProperty(exportStarSet, exportStarSet.length, module);
// Step 4
let exportedNames = [];
let namesCount = 0;
// Step 5
let localExportEntries = module.localExportEntries;
for (let i = 0; i < localExportEntries.length; i++) {
let e = localExportEntries[i];
_DefineDataProperty(exportedNames, namesCount++, e.exportName);
}
// Step 6
let indirectExportEntries = module.indirectExportEntries;
for (let i = 0; i < indirectExportEntries.length; i++) {
let e = indirectExportEntries[i];
_DefineDataProperty(exportedNames, namesCount++, e.exportName);
}
// Step 7
let starExportEntries = module.starExportEntries;
for (let i = 0; i < starExportEntries.length; i++) {
let e = starExportEntries[i];
let requestedModule = HostResolveImportedModule(module, e.moduleRequest);
let starNames = callFunction(requestedModule.getExportedNames, requestedModule,
exportStarSet);
for (let j = 0; j < starNames.length; j++) {
let n = starNames[j];
if (n !== "default" && !callFunction(ArrayIncludes, exportedNames, n))
_DefineDataProperty(exportedNames, namesCount++, n);
}
}
return exportedNames;
}
// 15.2.1.16.3 ResolveExport(exportName, resolveSet, exportStarSet)
function ModuleResolveExport(exportName, resolveSet = [], exportStarSet = [])
{
if (!IsObject(this) || !IsModule(this)) {
return callFunction(CallModuleMethodIfWrapped, this, exportName, resolveSet,
exportStarSet, "ModuleResolveExport");
}
// Step 1
let module = this;
// Step 2
for (let i = 0; i < resolveSet.length; i++) {
let r = resolveSet[i];
if (r.module === module && r.exportName === exportName)
return null;
}
// Step 3
_DefineDataProperty(resolveSet, resolveSet.length, {module: module, exportName: exportName});
// Step 4
let localExportEntries = module.localExportEntries;
for (let i = 0; i < localExportEntries.length; i++) {
let e = localExportEntries[i];
if (exportName === e.exportName)
return {module: module, bindingName: e.localName};
}
// Step 5
let indirectExportEntries = module.indirectExportEntries;
for (let i = 0; i < indirectExportEntries.length; i++) {
let e = indirectExportEntries[i];
if (exportName === e.exportName) {
let importedModule = HostResolveImportedModule(module, e.moduleRequest);
let indirectResolution = callFunction(importedModule.resolveExport, importedModule,
e.importName, resolveSet, exportStarSet);
if (indirectResolution !== null)
return indirectResolution;
}
}
// Step 6
if (exportName === "default") {
// A default export cannot be provided by an export *.
ThrowSyntaxError(JSMSG_BAD_DEFAULT_EXPORT);
}
// Step 7
if (callFunction(ArrayIncludes, exportStarSet, module))
return null;
// Step 8
_DefineDataProperty(exportStarSet, exportStarSet.length, module);
// Step 9
let starResolution = null;
// Step 10
let starExportEntries = module.starExportEntries;
for (let i = 0; i < starExportEntries.length; i++) {
let e = starExportEntries[i];
let importedModule = HostResolveImportedModule(module, e.moduleRequest);
let resolution = callFunction(importedModule.resolveExport, importedModule,
exportName, resolveSet, exportStarSet);
if (resolution === "ambiguous")
return resolution;
if (resolution !== null) {
if (starResolution === null) {
starResolution = resolution;
} else {
if (resolution.module !== starResolution.module ||
resolution.exportName !== starResolution.exportName)
{
return "ambiguous";
}
}
}
}
return starResolution;
}
// 15.2.1.18 GetModuleNamespace(module)
function GetModuleNamespace(module)
{
// Step 2
let namespace = module.namespace;
// Step 3
if (typeof namespace === "undefined") {
let exportedNames = callFunction(module.getExportedNames, module);
let unambiguousNames = [];
for (let i = 0; i < exportedNames.length; i++) {
let name = exportedNames[i];
let resolution = callFunction(module.resolveExport, module, name);
if (resolution === null)
ThrowSyntaxError(JSMSG_MISSING_NAMESPACE_EXPORT);
if (resolution !== "ambiguous")
_DefineDataProperty(unambiguousNames, unambiguousNames.length, name);
}
namespace = ModuleNamespaceCreate(module, unambiguousNames);
}
// Step 4
return namespace;
}
// 9.4.6.13 ModuleNamespaceCreate(module, exports)
function ModuleNamespaceCreate(module, exports)
{
callFunction(std_Array_sort, exports);
let ns = NewModuleNamespace(module, exports);
// Pre-compute all bindings now rather than calling ResolveExport() on every
// access.
for (let i = 0; i < exports.length; i++) {
let name = exports[i];
let binding = callFunction(module.resolveExport, module, name);
assert(binding !== null && binding !== "ambiguous", "Failed to resolve binding");
AddModuleNamespaceBinding(ns, name, binding.module, binding.bindingName);
}
return ns;
}
// 15.2.1.16.4 ModuleDeclarationInstantiation()
function ModuleDeclarationInstantiation()
{
if (!IsObject(this) || !IsModule(this))
return callFunction(CallModuleMethodIfWrapped, this, "ModuleDeclarationInstantiation");
// Step 1
let module = this;
// Step 5
if (GetModuleEnvironment(module) !== undefined)
return;
// Step 7
CreateModuleEnvironment(module);
let env = GetModuleEnvironment(module);
// Step 8
let requestedModules = module.requestedModules;
for (let i = 0; i < requestedModules.length; i++) {
let required = requestedModules[i];
let requiredModule = HostResolveImportedModule(module, required);
callFunction(requiredModule.declarationInstantiation, requiredModule);
}
// Step 9
let indirectExportEntries = module.indirectExportEntries;
for (let i = 0; i < indirectExportEntries.length; i++) {
let e = indirectExportEntries[i];
let resolution = callFunction(module.resolveExport, module, e.exportName);
if (resolution === null)
ThrowSyntaxError(JSMSG_MISSING_INDIRECT_EXPORT, e.exportName);
if (resolution === "ambiguous")
ThrowSyntaxError(JSMSG_AMBIGUOUS_INDIRECT_EXPORT, e.exportName);
}
// Step 12
let importEntries = module.importEntries;
for (let i = 0; i < importEntries.length; i++) {
let imp = importEntries[i];
let importedModule = HostResolveImportedModule(module, imp.moduleRequest);
if (imp.importName === "*") {
let namespace = GetModuleNamespace(importedModule);
CreateNamespaceBinding(env, imp.localName, namespace);
} else {
let resolution = callFunction(importedModule.resolveExport, importedModule,
imp.importName);
if (resolution === null)
ThrowSyntaxError(JSMSG_MISSING_IMPORT, imp.importName);
if (resolution === "ambiguous")
ThrowSyntaxError(JSMSG_AMBIGUOUS_IMPORT, imp.importName);
CreateImportBinding(env, imp.localName, resolution.module, resolution.bindingName);
}
}
// Step 16.iv
InstantiateModuleFunctionDeclarations(module);
}
_SetCanonicalName(ModuleDeclarationInstantiation, "ModuleDeclarationInstantiation");
// 15.2.1.16.5 ModuleEvaluation()
function ModuleEvaluation()
{
if (!IsObject(this) || !IsModule(this))
return callFunction(CallModuleMethodIfWrapped, this, "ModuleEvaluation");
// Step 1
let module = this;
// Step 4
if (module.evaluated)
return undefined;
// Step 5
SetModuleEvaluated(this);
// Step 6
let requestedModules = module.requestedModules;
for (let i = 0; i < requestedModules.length; i++) {
let required = requestedModules[i];
let requiredModule = HostResolveImportedModule(module, required);
callFunction(requiredModule.evaluation, requiredModule);
}
return EvaluateModule(module);
}
_SetCanonicalName(ModuleEvaluation, "ModuleEvaluation");
function ModuleNamespaceEnumerate()
{
if (!IsObject(this) || !IsModuleNamespace(this))
return callFunction(CallModuleMethodIfWrapped, this, "ModuleNamespaceEnumerate");
return CreateListIterator(ModuleNamespaceExports(this));
}