Backed out changeset 71791e10b6e9 (bug 1485031)
authorJon Coppeard <jcoppeard@mozilla.com>
Thu, 04 Oct 2018 11:50:55 +0100
changeset 495352 18f0d23d05745b37d67c6842b88dab90d3db21a6
parent 495351 cf579f097fff49b756b8888fa7812c500796cd96
child 495353 92181c289ffa370c103d333f6cc3b0c620a897b4
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1485031
milestone64.0a1
backs out71791e10b6e9c29fc3ff36ddee232d07961ba81d
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 71791e10b6e9 (bug 1485031)
js/src/builtin/ModuleObject.cpp
js/src/builtin/TestingFunctions.cpp
js/src/jit-test/tests/basic/bug1470732.js
js/src/jit-test/tests/debug/RematerializedFrame-retval.js
js/src/jit-test/tests/debug/Script-isModule-01.js
js/src/jit-test/tests/debug/Script-isModule-03.js
js/src/jit-test/tests/debug/Script-isModule-04.js
js/src/jit-test/tests/debug/bug1304553.js
js/src/jit-test/tests/for-of/bug-1341339.js
js/src/jit-test/tests/gc/bug-1282986.js
js/src/jit-test/tests/ion/bug1269756.js
js/src/jit-test/tests/modules/ambiguous-star-export.js
js/src/jit-test/tests/modules/bad-namespace-created.js
js/src/jit-test/tests/modules/bug-1233915.js
js/src/jit-test/tests/modules/bug-1236875.js
js/src/jit-test/tests/modules/bug-1245518.js
js/src/jit-test/tests/modules/bug-1247934.js
js/src/jit-test/tests/modules/bug-1283448.js
js/src/jit-test/tests/modules/bug-1284486-2.js
js/src/jit-test/tests/modules/bug-1284486.js
js/src/jit-test/tests/modules/bug-1287410.js
js/src/jit-test/tests/modules/bug-1372258.js
js/src/jit-test/tests/modules/bug-1402535.js
js/src/jit-test/tests/modules/bug-1402649.js
js/src/jit-test/tests/modules/bug-1406452.js
js/src/jit-test/tests/modules/bug-1420420-2.js
js/src/jit-test/tests/modules/bug-1420420-3.js
js/src/jit-test/tests/modules/bug-1420420-4.js
js/src/jit-test/tests/modules/bug-1420420.js
js/src/jit-test/tests/modules/bug-1435327.js
js/src/jit-test/tests/modules/bug-1443555.js
js/src/jit-test/tests/modules/bug-1462286.js
js/src/jit-test/tests/modules/bug-1462326.js
js/src/jit-test/tests/modules/bug-1463371.js
js/src/jit-test/tests/modules/bug-1463373.js
js/src/jit-test/tests/modules/bug-1466487.js
js/src/jit-test/tests/modules/bug-1476921.js
js/src/jit-test/tests/modules/bug1210391.js
js/src/jit-test/tests/modules/bug1394492.js
js/src/jit-test/tests/modules/bug1429031.js
js/src/jit-test/tests/modules/bug1449153.js
js/src/jit-test/tests/modules/bug1485698.js
js/src/jit-test/tests/modules/debugger-frames.js
js/src/jit-test/tests/modules/debugger-vars-function.js
js/src/jit-test/tests/modules/debugger-vars-toplevel.js
js/src/jit-test/tests/modules/eval-module-oom.js
js/src/jit-test/tests/modules/export-destructuring.js
js/src/jit-test/tests/modules/export-entries.js
js/src/jit-test/tests/modules/global-scope.js
js/src/jit-test/tests/modules/import-entries.js
js/src/jit-test/tests/modules/import-namespace.js
js/src/jit-test/tests/modules/many-exports.js
js/src/jit-test/tests/modules/many-imports.js
js/src/jit-test/tests/modules/many-namespace-imports.js
js/src/jit-test/tests/modules/module-declaration-instantiation.js
js/src/jit-test/tests/modules/module-evaluation.js
js/src/jit-test/tests/modules/module-this.js
js/src/jit-test/tests/modules/off-thread-compile.js
js/src/jit-test/tests/modules/requested-modules.js
js/src/jit-test/tests/parser/bug-1263355-16.js
js/src/jit-test/tests/parser/bug-1263355-23.js
js/src/jit-test/tests/parser/bug-1263355-48.js
js/src/shell/ModuleLoader.js
js/src/shell/js.cpp
js/src/shell/jsshell.h
--- a/js/src/builtin/ModuleObject.cpp
+++ b/js/src/builtin/ModuleObject.cpp
@@ -1238,16 +1238,18 @@ GlobalObject::initModuleProto(JSContext*
         JS_PSG("dfsIndex", ModuleObject_dfsIndexGetter, 0),
         JS_PSG("dfsAncestorIndex", ModuleObject_dfsAncestorIndexGetter, 0),
         JS_PS_END
     };
 
     static const JSFunctionSpec protoFunctions[] = {
         JS_SELF_HOSTED_FN("getExportedNames", "ModuleGetExportedNames", 1, 0),
         JS_SELF_HOSTED_FN("resolveExport", "ModuleResolveExport", 2, 0),
+        JS_SELF_HOSTED_FN("declarationInstantiation", "ModuleInstantiate", 0, 0),
+        JS_SELF_HOSTED_FN("evaluation", "ModuleEvaluate", 0, 0),
         JS_FS_END
     };
 
     RootedObject proto(cx, GlobalObject::createBlankPrototype<PlainObject>(cx, global));
     if (!proto) {
         return false;
     }
 
--- a/js/src/builtin/TestingFunctions.cpp
+++ b/js/src/builtin/TestingFunctions.cpp
@@ -4567,16 +4567,111 @@ SetRNGState(JSContext* cx, unsigned argc
 
     cx->realm()->getOrCreateRandomNumberGenerator().setState(seed0, seed1);
 
     args.rval().setUndefined();
     return true;
 }
 #endif
 
+static ModuleEnvironmentObject*
+GetModuleEnvironment(JSContext* cx, HandleModuleObject module)
+{
+    // Use the initial environment so that tests can check bindings exists
+    // before they have been instantiated.
+    RootedModuleEnvironmentObject env(cx, &module->initialEnvironment());
+    MOZ_ASSERT(env);
+    return env;
+}
+
+static bool
+GetModuleEnvironmentNames(JSContext* cx, unsigned argc, Value* vp)
+{
+    CallArgs args = CallArgsFromVp(argc, vp);
+    if (args.length() != 1) {
+        JS_ReportErrorASCII(cx, "Wrong number of arguments");
+        return false;
+    }
+
+    if (!args[0].isObject() || !args[0].toObject().is<ModuleObject>()) {
+        JS_ReportErrorASCII(cx, "First argument should be a ModuleObject");
+        return false;
+    }
+
+    RootedModuleObject module(cx, &args[0].toObject().as<ModuleObject>());
+    if (module->hadEvaluationError()) {
+        JS_ReportErrorASCII(cx, "Module environment unavailable");
+        return false;
+    }
+
+    RootedModuleEnvironmentObject env(cx, GetModuleEnvironment(cx, module));
+    Rooted<IdVector> ids(cx, IdVector(cx));
+    if (!JS_Enumerate(cx, env, &ids)) {
+        return false;
+    }
+
+    uint32_t length = ids.length();
+    RootedArrayObject array(cx, NewDenseFullyAllocatedArray(cx, length));
+    if (!array) {
+        return false;
+    }
+
+    array->setDenseInitializedLength(length);
+    for (uint32_t i = 0; i < length; i++) {
+        array->initDenseElement(i, StringValue(JSID_TO_STRING(ids[i])));
+    }
+
+    args.rval().setObject(*array);
+    return true;
+}
+
+static bool
+GetModuleEnvironmentValue(JSContext* cx, unsigned argc, Value* vp)
+{
+    CallArgs args = CallArgsFromVp(argc, vp);
+    if (args.length() != 2) {
+        JS_ReportErrorASCII(cx, "Wrong number of arguments");
+        return false;
+    }
+
+    if (!args[0].isObject() || !args[0].toObject().is<ModuleObject>()) {
+        JS_ReportErrorASCII(cx, "First argument should be a ModuleObject");
+        return false;
+    }
+
+    if (!args[1].isString()) {
+        JS_ReportErrorASCII(cx, "Second argument should be a string");
+        return false;
+    }
+
+    RootedModuleObject module(cx, &args[0].toObject().as<ModuleObject>());
+    if (module->hadEvaluationError()) {
+        JS_ReportErrorASCII(cx, "Module environment unavailable");
+        return false;
+    }
+
+    RootedModuleEnvironmentObject env(cx, GetModuleEnvironment(cx, module));
+    RootedString name(cx, args[1].toString());
+    RootedId id(cx);
+    if (!JS_StringToId(cx, name, &id)) {
+        return false;
+    }
+
+    if (!GetProperty(cx, env, env, id, args.rval())) {
+        return false;
+    }
+
+    if (args.rval().isMagic(JS_UNINITIALIZED_LEXICAL)) {
+        ReportRuntimeLexicalError(cx, JSMSG_UNINITIALIZED_LEXICAL, id);
+        return false;
+    }
+
+    return true;
+}
+
 #ifdef DEBUG
 static const char*
 AssertionTypeToString(irregexp::RegExpAssertion::AssertionType type)
 {
     switch (type) {
       case irregexp::RegExpAssertion::START_OF_LINE:
         return "START_OF_LINE";
       case irregexp::RegExpAssertion::START_OF_INPUT:
@@ -6159,16 +6254,24 @@ gc::ZealModeHelpText),
 "  the current global is used as the default one.\n"),
 
 #ifdef DEBUG
     JS_FN_HELP("setRNGState", SetRNGState, 2, 0,
 "setRNGState(seed0, seed1)",
 "  Set this compartment's RNG state.\n"),
 #endif
 
+    JS_FN_HELP("getModuleEnvironmentNames", GetModuleEnvironmentNames, 1, 0,
+"getModuleEnvironmentNames(module)",
+"  Get the list of a module environment's bound names for a specified module.\n"),
+
+    JS_FN_HELP("getModuleEnvironmentValue", GetModuleEnvironmentValue, 2, 0,
+"getModuleEnvironmentValue(module, name)",
+"  Get the value of a bound name in a module environment.\n"),
+
 #if defined(FUZZING) && defined(__AFL_COMPILER)
     JS_FN_HELP("aflloop", AflLoop, 1, 0,
 "aflloop(max_cnt)",
 "  Call the __AFL_LOOP() runtime function (see AFL docs)\n"),
 #endif
 
     JS_FN_HELP("monotonicNow", MonotonicNow, 0, 0,
 "monotonicNow()",
--- a/js/src/jit-test/tests/basic/bug1470732.js
+++ b/js/src/jit-test/tests/basic/bug1470732.js
@@ -2,11 +2,11 @@ if (helperThreadCount() === 0)
     quit();
 
 var i = 0;
 while(i++ < 500) {
   evalInWorker(`
     assertFloat32(0x23456789 | 0, false);
   `);
   let m = parseModule("");
-  instantiateModule(m);
+  m.declarationInstantiation();
 }
 
--- a/js/src/jit-test/tests/debug/RematerializedFrame-retval.js
+++ b/js/src/jit-test/tests/debug/RematerializedFrame-retval.js
@@ -27,13 +27,13 @@ function testResumptionVal(resumptionVal
   } finally {  }
 }
 assertEq(testResumptionVal({ return: "not 42" }), "not 42");
 `;
 loadFile(lfLogBuffer);
 function loadFile(lfVarx) {
     try {
          let m = parseModule(lfVarx);
-         instantiateModule(m);
-         evaluateModule(m);
+         m.declarationInstantiation();
+         m.evaluation();
     } catch (lfVare) {}
 }
 
--- a/js/src/jit-test/tests/debug/Script-isModule-01.js
+++ b/js/src/jit-test/tests/debug/Script-isModule-01.js
@@ -3,11 +3,11 @@
 const g = newGlobal();
 const dbg = Debugger(g);
 let count = 0;
 dbg.onNewScript = function (script) {
     count += 1;
     assertEq(script.isModule, true);
 };
 const m = g.parseModule("");
-g.instantiateModule(m);
-g.evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
 assertEq(count, 1);
--- a/js/src/jit-test/tests/debug/Script-isModule-03.js
+++ b/js/src/jit-test/tests/debug/Script-isModule-03.js
@@ -8,11 +8,11 @@ dbg.onNewScript = function (script) {
     assertEq(script.isModule, true);
 
     dbg.onNewScript = function (script) {
         count += 1;
         assertEq(script.isModule, false);
     };
 };
 const m = g.parseModule("eval('')");
-g.instantiateModule(m);
-g.evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
 assertEq(count, 2);
--- a/js/src/jit-test/tests/debug/Script-isModule-04.js
+++ b/js/src/jit-test/tests/debug/Script-isModule-04.js
@@ -8,12 +8,12 @@ dbg.onNewScript = function (script) {
     assertEq(script.isModule, true);
 };
 dbg.onDebuggerStatement = function (frame) {
     const { script } = frame;
 
     assertEq(script.isModule, false);
 };
 const m = g.parseModule("(function(){ debugger; })()");
-g.instantiateModule(m);
-g.evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
 
 assertEq(count, 1);
--- a/js/src/jit-test/tests/debug/bug1304553.js
+++ b/js/src/jit-test/tests/debug/bug1304553.js
@@ -12,10 +12,10 @@ try {
     }
 } catch (e) {}
 let m = parseModule(`
                     actual = '';
                     for (var i = 0; i < 1; ++i)
                         f(i);
                     actual;
                     `);
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
--- a/js/src/jit-test/tests/for-of/bug-1341339.js
+++ b/js/src/jit-test/tests/for-of/bug-1341339.js
@@ -1,9 +1,9 @@
 let m = parseModule(`
 function* values() {}
 var iterator = values();
 for (var i=0; i < 10000; ++i) {
     for (var x of iterator) {}
 }
 `);
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
--- a/js/src/jit-test/tests/gc/bug-1282986.js
+++ b/js/src/jit-test/tests/gc/bug-1282986.js
@@ -6,12 +6,12 @@ evalInWorker(\`
         try { oomAfterAllocations(2); } catch(e) {}
     \`);
 `;
 loadFile("");
 loadFile(lfLogBuffer);
 function loadFile(lfVarx) {
     oomTest(function() {
         let m = parseModule(lfVarx);
-        instantiateModule(m);
-        evaluateModule(m);
+        m.declarationInstantiation();
+        m.evaluation();
     });
 }
--- a/js/src/jit-test/tests/ion/bug1269756.js
+++ b/js/src/jit-test/tests/ion/bug1269756.js
@@ -1,8 +1,8 @@
 if (!('oomTest' in this))
     quit();
 
 oomTest(function() {
     m = parseModule(`while (x && NaN) prototype; let x`);
-    instantiateModule(m);
-    evaluateModule(m);
+    m.declarationInstantiation();
+    m.evaluation();
 })
--- a/js/src/jit-test/tests/modules/ambiguous-star-export.js
+++ b/js/src/jit-test/tests/modules/ambiguous-star-export.js
@@ -2,43 +2,43 @@
 
 "use strict";
 
 load(libdir + "asserts.js");
 load(libdir + "dummyModuleResolveHook.js");
 
 function checkModuleEval(source) {
     let m = parseModule(source);
-    instantiateModule(m);
-    evaluateModule(m);
+    m.declarationInstantiation();
+    m.evaluation();
     return m;
 }
 
 function checkModuleSyntaxError(source) {
     let m = parseModule(source);
-    assertThrowsInstanceOf(() => instantiateModule(m), SyntaxError);
+    assertThrowsInstanceOf(() => m.declarationInstantiation(), SyntaxError);
 }
 
 let a = moduleRepo['a'] = parseModule("export var a = 1; export var b = 2;");
 let b = moduleRepo['b'] = parseModule("export var b = 3; export var c = 4;");
 let c = moduleRepo['c'] = parseModule("export * from 'a'; export * from 'b';");
-instantiateModule(c);
-evaluateModule(c);
+c.declarationInstantiation();
+c.evaluation();
 
 // Check importing/exporting non-ambiguous name works.
 let d = checkModuleEval("import { a } from 'c';");
 assertEq(getModuleEnvironmentValue(d, "a"), 1);
 checkModuleEval("export { a } from 'c';");
 
 // Check importing/exporting ambiguous name is a syntax error.
 checkModuleSyntaxError("import { b } from 'c';");
 checkModuleSyntaxError("export { b } from 'c';");
 
 // Check that namespace objects include only non-ambiguous names.
 let m = parseModule("import * as ns from 'c';");
-instantiateModule(m);
-evaluateModule(m);
-let ns = getModuleObject(c).namespace;
+m.declarationInstantiation();
+m.evaluation();
+let ns = c.namespace;
 let names = Object.keys(ns);
 assertEq(names.length, 2);
 assertEq('a' in ns, true);
 assertEq('b' in ns, false);
 assertEq('c' in ns, true);
--- a/js/src/jit-test/tests/modules/bad-namespace-created.js
+++ b/js/src/jit-test/tests/modules/bad-namespace-created.js
@@ -9,9 +9,9 @@ load(libdir + "dummyModuleResolveHook.js
 
 moduleRepo['A'] = parseModule('import "B"; export {x} from "C"');
 moduleRepo['B'] = parseModule('import * as a from "A"');
 moduleRepo['C'] = parseModule('export * from "D"; export * from "E"');
 moduleRepo['D'] = parseModule('export let x');
 moduleRepo['E'] = parseModule('export let x');
 
 let m = moduleRepo['A'];
-assertThrowsInstanceOf(() => instantiateModule(m), SyntaxError);
+assertThrowsInstanceOf(() => m.declarationInstantiation(), SyntaxError);
--- a/js/src/jit-test/tests/modules/bug-1233915.js
+++ b/js/src/jit-test/tests/modules/bug-1233915.js
@@ -2,10 +2,10 @@ g = newGlobal();
 g.parent = this;
 g.eval("(" + function() {
     Debugger(parent)
         .onExceptionUnwind = function(frame) {
         return frame.eval("");
     };
 } + ")()");
 m = parseModule(` s1 `);
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
--- a/js/src/jit-test/tests/modules/bug-1236875.js
+++ b/js/src/jit-test/tests/modules/bug-1236875.js
@@ -1,2 +1,2 @@
 let m = parseModule(`{ function x() {} }`);
-instantiateModule(m);
+m.declarationInstantiation();
--- a/js/src/jit-test/tests/modules/bug-1245518.js
+++ b/js/src/jit-test/tests/modules/bug-1245518.js
@@ -6,10 +6,10 @@ evalInFrame = function(global) {
     frame = dbg.getNewestFrame().older;
     frame.eval(code);
   }
 }(this);
 m = parseModule(`
   function g() { return this.hours = 0; }
   evalInFrame.call(0, 0, "g()")
 `);
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
--- a/js/src/jit-test/tests/modules/bug-1247934.js
+++ b/js/src/jit-test/tests/modules/bug-1247934.js
@@ -1,9 +1,9 @@
 let moduleRepo = {};
 setModuleResolveHook(function(module, specifier) {
         return moduleRepo[specifier];
 });
 setJitCompilerOption("ion.warmup.trigger", 50);
 s = "";
 for (i = 0; i < 1024; i++) s += "export let e" + i + "\n";
 moduleRepo['a'] = parseModule(s);
-instantiateModule(parseModule("import * as ns from 'a'"));
+parseModule("import * as ns from 'a'").declarationInstantiation();
--- a/js/src/jit-test/tests/modules/bug-1283448.js
+++ b/js/src/jit-test/tests/modules/bug-1283448.js
@@ -1,10 +1,10 @@
 // |jit-test| error: TypeError
 
 let moduleRepo = {};
 setModuleResolveHook(function(module, specifier) {
         return moduleRepo[specifier];
 });
 let a = moduleRepo['a'] = parseModule("var x = 1; export { x };");
 let b = moduleRepo['b'] = parseModule("import { x as y } from 'a';");
-getModuleObject(a).__proto__ = {15: 1337};
-instantiateModule(b);
+a.__proto__ = {15: 1337};
+b.declarationInstantiation();
--- a/js/src/jit-test/tests/modules/bug-1284486-2.js
+++ b/js/src/jit-test/tests/modules/bug-1284486-2.js
@@ -10,26 +10,26 @@
 load(libdir + "dummyModuleResolveHook.js");
 
 let b = moduleRepo['b'] = parseModule("export var b = 3; export var c = 4;");
 let c = moduleRepo['c'] = parseModule("export * from 'a'; export * from 'b';");
 
 let e1;
 let threw = false;
 try {
-    instantiateModule(c);
+    c.declarationInstantiation();
 } catch (exc) {
     threw = true;
     e1 = exc;
 }
 assertEq(threw, true);
 assertEq(typeof e1 === "undefined", false);
 
 threw = false;
 let e2;
 try {
-    instantiateModule(c);
+    c.declarationInstantiation();
 } catch (exc) {
     threw = true;
     e2 = exc;
 }
 assertEq(threw, true);
 assertEq(e1, e2);
--- a/js/src/jit-test/tests/modules/bug-1284486.js
+++ b/js/src/jit-test/tests/modules/bug-1284486.js
@@ -10,26 +10,26 @@
 load(libdir + "dummyModuleResolveHook.js");
 
 let b = moduleRepo['b'] = parseModule("export var b = 3; export var c = 4;");
 let c = moduleRepo['c'] = parseModule("export * from 'a'; export * from 'b';");
 
 let e1;
 let threw = false;
 try {
-    instantiateModule(c);
+    c.declarationInstantiation();
 } catch (exc) {
     threw = true;
     e1 = exc;
 }
 assertEq(threw, true);
 assertEq(typeof e1 === "undefined", false);
 
 let a = moduleRepo['a'] = parseModule("export var a = 1; export var b = 2;");
 let d = moduleRepo['d'] = parseModule("import { a } from 'c'; a;");
 
 threw = false;
 try {
-    instantiateModule(d);
+    d.declarationInstantiation();
 } catch (exc) {
     threw = true;
 }
 assertEq(threw, false);
--- a/js/src/jit-test/tests/modules/bug-1287410.js
+++ b/js/src/jit-test/tests/modules/bug-1287410.js
@@ -4,20 +4,20 @@ let moduleRepo = {};
 setModuleResolveHook(function(module, specifier) {
     if (specifier in moduleRepo)
         return moduleRepo[specifier];
     throw "Module '" + specifier + "' not found";
 });
 let a = moduleRepo['a'] = parseModule("export var a = 1; export var b = 2;");
 let b = moduleRepo['b'] = parseModule("export var b = 3; export var c = 4;");
 let c = moduleRepo['c'] = parseModule("export * from 'a'; export * from 'b';");
-instantiateModule(c);
+c.declarationInstantiation();
 
 // Module 'a' is replaced with another module that has not been instantiated.
 // This should not happen and would be a bug in the module loader.
 a = moduleRepo['a'] = parseModule("export var a = 1; export var b = 2;");
 
 let d = moduleRepo['d'] = parseModule("import { a } from 'c'; a;");
 
 // Attempting to instantiate 'd' throws an error because depdency 'a' of
 // instantiated module 'c' is not instantiated.
-instantiateModule(d);
-evaluateModule(d);
+d.declarationInstantiation();
+d.evaluation();
--- a/js/src/jit-test/tests/modules/bug-1372258.js
+++ b/js/src/jit-test/tests/modules/bug-1372258.js
@@ -19,10 +19,10 @@ let a = moduleRepo['a'] = parseModule("e
 
 let s = "";
 for (let i = 0; i < count; i++) {
     s += "import { a as i" + i + " } from 'a';\n";
     s += "assertEq(i" + i + ", 1);\n";
 }
 let b = moduleRepo['b'] = parseModule(s);
 
-instantiateModule(b);
-evaluateModule(b);
+b.declarationInstantiation();
+b.evaluation();
--- a/js/src/jit-test/tests/modules/bug-1402535.js
+++ b/js/src/jit-test/tests/modules/bug-1402535.js
@@ -1,7 +1,7 @@
 if (!('stackTest' in this))
    quit();
 
 stackTest(function() {
     let m = parseModule(``);
-    instantiateModule(m);
+    m.declarationInstantiation();
 });
--- a/js/src/jit-test/tests/modules/bug-1402649.js
+++ b/js/src/jit-test/tests/modules/bug-1402649.js
@@ -1,15 +1,15 @@
 if (!('oomTest' in this))
    quit();
 
 loadFile(`
 function parseAndEvaluate(source) {
     let m = parseModule(source);
-    instantiateModule(m);
+    m.declarationInstantiation();
 }
 parseAndEvaluate("async function a() { await 2 + 3; }")
 `);
 function loadFile(lfVarx) {
     oomTest(function() {
         eval(lfVarx);
     });
 }
--- a/js/src/jit-test/tests/modules/bug-1406452.js
+++ b/js/src/jit-test/tests/modules/bug-1406452.js
@@ -1,5 +1,5 @@
 // |jit-test| error: Error
 let m = parseModule(`for (var x of iterator) {}`);
-instantiateModule(m);
-try { evaluateModule(m); } catch (e) {}
+m.declarationInstantiation();
+try { m.evaluation(); } catch (e) {}
 getModuleEnvironmentValue(m, "r");
--- a/js/src/jit-test/tests/modules/bug-1420420-2.js
+++ b/js/src/jit-test/tests/modules/bug-1420420-2.js
@@ -9,10 +9,10 @@ moduleRepo["y1"] = parseModule(`export l
 moduleRepo["y2"] = parseModule(`export let y`);
 moduleRepo["bad"] = parseModule(`export* from "y1"; export* from "y2";`);
 
 moduleRepo["a"] = parseModule(`import* as ns from "good"; import {y} from "bad";`);
 
 let b = moduleRepo["b"] = parseModule(`import "a";`);
 let c = moduleRepo["c"] = parseModule(`import "a";`);
 
-assertThrowsInstanceOf(() => instantiateModule(b), SyntaxError);
-assertThrowsInstanceOf(() => instantiateModule(c), SyntaxError);
+assertThrowsInstanceOf(() => b.declarationInstantiation(), SyntaxError);
+assertThrowsInstanceOf(() => c.declarationInstantiation(), SyntaxError);
--- a/js/src/jit-test/tests/modules/bug-1420420-3.js
+++ b/js/src/jit-test/tests/modules/bug-1420420-3.js
@@ -1,8 +1,8 @@
 if (!('stackTest' in this))
    quit();
 
 let a = parseModule(`throw new Error`);
-instantiateModule(a);
+a.declarationInstantiation();
 stackTest(function() {
-    evaluateModule(a);
+    a.evaluation();
 });
--- a/js/src/jit-test/tests/modules/bug-1420420-4.js
+++ b/js/src/jit-test/tests/modules/bug-1420420-4.js
@@ -1,15 +1,15 @@
 load(libdir + "asserts.js");
 load(libdir + "dummyModuleResolveHook.js");
 
 moduleRepo["a"] = parseModule(`throw undefined`);
 
 let b = moduleRepo["b"] = parseModule(`import "a";`);
 let c = moduleRepo["c"] = parseModule(`import "a";`);
 
-instantiateModule(b);
-instantiateModule(c);
+b.declarationInstantiation();
+c.declarationInstantiation();
 
 let count = 0;
-try { evaluateModule(b) } catch (e) { count++; }
-try { evaluateModule(c) } catch (e) { count++; }
+try { b.evaluation() } catch (e) { count++; }
+try { c.evaluation() } catch (e) { count++; }
 assertEq(count, 2);
--- a/js/src/jit-test/tests/modules/bug-1420420.js
+++ b/js/src/jit-test/tests/modules/bug-1420420.js
@@ -9,10 +9,10 @@ moduleRepo["y1"] = parseModule(`export l
 moduleRepo["y2"] = parseModule(`export let y`);
 moduleRepo["bad"] = parseModule(`export* from "y1"; export* from "y2";`);
 
 moduleRepo["a"] = parseModule(`import {x} from "good"; import {y} from "bad";`);
 
 let b = moduleRepo["b"] = parseModule(`import "a";`);
 let c = moduleRepo["c"] = parseModule(`import "a";`);
 
-assertThrowsInstanceOf(() => instantiateModule(b), SyntaxError);
-assertThrowsInstanceOf(() => instantiateModule(c), SyntaxError);
+assertThrowsInstanceOf(() => b.declarationInstantiation(), SyntaxError);
+assertThrowsInstanceOf(() => c.declarationInstantiation(), SyntaxError);
--- a/js/src/jit-test/tests/modules/bug-1435327.js
+++ b/js/src/jit-test/tests/modules/bug-1435327.js
@@ -3,30 +3,30 @@ if (!('oomTest' in this))
 
 lfLogBuffer = `
   let moduleRepo = {};
   setModuleResolveHook(function(x, specifier) {
         return moduleRepo[specifier];
   });
   let c = moduleRepo['c'] = parseModule("");
   let d = moduleRepo['d'] = parseModule("import { a } from 'c'; a;");
-  instantiateModule(d);
+  d.declarationInstantiation();
 `;
 lfLogBuffer = lfLogBuffer.split('\n');
 var lfCodeBuffer = "";
 while (true) {
     var line = lfLogBuffer.shift();
     if (line == null) {
         break;
     } else {
         lfCodeBuffer += line + "\n";
     }
 }
 if (lfCodeBuffer) loadFile(lfCodeBuffer);
 function loadFile(lfVarx) {
     try {
         oomTest(function() {
             let m = parseModule(lfVarx);
-            instantiateModule(m);
-            evaluateModule(m);
+            m.declarationInstantiation();
+            m.evaluation();
         });
     } catch (lfVare) {}
 }
--- a/js/src/jit-test/tests/modules/bug-1443555.js
+++ b/js/src/jit-test/tests/modules/bug-1443555.js
@@ -27,10 +27,10 @@ function loopy() {
 
 let ASrc = `
 export default 1;
 `;
 
 moduleRepo['A'] = parseModule(ASrc);
 
 let m = parseModule(mainSrc);
-instantiateModule(m)
-evaluateModule(m);
+m.declarationInstantiation()
+m.evaluation();
--- a/js/src/jit-test/tests/modules/bug-1462286.js
+++ b/js/src/jit-test/tests/modules/bug-1462286.js
@@ -1,10 +1,10 @@
 load(libdir + "dummyModuleResolveHook.js");
 
 let a = moduleRepo['a'] = parseModule(`
   export var { ... get } = { x: "foo" };
 `);
 
 let m = parseModule("import { get } from 'a'; export { get };");
-instantiateModule(m);
-evaluateModule(m)
+m.declarationInstantiation();
+m.evaluation()
 assertEq(getModuleEnvironmentValue(m, "get").x, "foo");
--- a/js/src/jit-test/tests/modules/bug-1462326.js
+++ b/js/src/jit-test/tests/modules/bug-1462326.js
@@ -1,6 +1,6 @@
 // |jit-test| error: Error
 
 let m = parseModule(`
   import A from "A";
 `);
-instantiateModule(m);
+m.declarationInstantiation();
--- a/js/src/jit-test/tests/modules/bug-1463371.js
+++ b/js/src/jit-test/tests/modules/bug-1463371.js
@@ -2,9 +2,9 @@
 
 var g = newGlobal();
 g.eval(`
   setModuleResolveHook(function(module, specifier) { return module; });
 `);
 let m = parseModule(`
   import {} from './foo.js';
 `);
-instantiateModule(m);
+m.declarationInstantiation();
--- a/js/src/jit-test/tests/modules/bug-1463373.js
+++ b/js/src/jit-test/tests/modules/bug-1463373.js
@@ -1,11 +1,11 @@
 // |jit-test| error: InternalError
 
 let m = parseModule(`
   let c = parseModule(\`
     import "a";
   \`);
-  instantiateModule(c);
+  c.declarationInstantiation();
 `);
 setModuleResolveHook(function(module, specifier) { return m; });
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
--- a/js/src/jit-test/tests/modules/bug-1466487.js
+++ b/js/src/jit-test/tests/modules/bug-1466487.js
@@ -1,7 +1,7 @@
 if (helperThreadCount() === 0)
     quit();
 evalInWorker(`
     let m = parseModule("import.meta;");
-    instantiateModule(m);
-    evaluateModule(m);
+    m.declarationInstantiation();
+    m.evaluation();
 `);
--- a/js/src/jit-test/tests/modules/bug-1476921.js
+++ b/js/src/jit-test/tests/modules/bug-1476921.js
@@ -8,12 +8,12 @@ class UniqueError extends Error {}
 let a = moduleRepo['a'] = parseModule(`
     throw new UniqueError();
 `);
 
 let b = moduleRepo['b'] = parseModule(`
     import * as ns0 from "a";
 `);
 
-instantiateModule(a);
-assertThrowsInstanceOf(() => evaluateModule(a), UniqueError);
-instantiateModule(b);
-assertThrowsInstanceOf(() => evaluateModule(b), UniqueError);
+a.declarationInstantiation();
+assertThrowsInstanceOf(() => a.evaluation(), UniqueError);
+b.declarationInstantiation();
+assertThrowsInstanceOf(() => b.evaluation(), UniqueError);
--- a/js/src/jit-test/tests/modules/bug1210391.js
+++ b/js/src/jit-test/tests/modules/bug1210391.js
@@ -1,8 +1,8 @@
 load(libdir + "dummyModuleResolveHook.js");
 let a = moduleRepo['a'] = parseModule("export var a = 1; export var b = 2;");
 let b = moduleRepo['b'] = parseModule("export var b = 3; export var c = 4;");
 let c = moduleRepo['c'] = parseModule("export * from 'a'; export * from 'b';");
 let d = moduleRepo['d'] = parseModule("import { a } from 'c'; a;");
-instantiateModule(d);
-evaluateModule(d);
+d.declarationInstantiation();
+d.evaluation();
 
--- a/js/src/jit-test/tests/modules/bug1394492.js
+++ b/js/src/jit-test/tests/modules/bug1394492.js
@@ -1,6 +1,6 @@
-// |jit-test| error: TypeError
+// |jit-test| error: NaN
 let m = parseModule(`
   throw i => { return 5; }, m-1;
 `);
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
--- a/js/src/jit-test/tests/modules/bug1429031.js
+++ b/js/src/jit-test/tests/modules/bug1429031.js
@@ -8,13 +8,13 @@ assertEq = function(a, b) {}
 evaluate(`
 let a = moduleRepo['a'] = parseModule(
     'export var a = 1;'
 );
 let b = moduleRepo['b'] = parseModule(
     \`import * as ns from 'a';
      export var x = ns.a + ns.b;\`
 );
-instantiateModule(b);
+b.declarationInstantiation();
 let ns = getModuleEnvironmentValue(b, "ns");
 assertEq(ns.a, 1);
 while ( t.ArrayType() ) 1;
 `);
--- a/js/src/jit-test/tests/modules/bug1449153.js
+++ b/js/src/jit-test/tests/modules/bug1449153.js
@@ -21,16 +21,16 @@ setModuleResolveHook(function(module, sp
 
 moduleRepo["a"] = parseModule(`
     throw new MyError();
 `);
 
 let c = moduleRepo["c"] = parseModule(`
     import "a";
 `);
-instantiateModule(c);
-assertThrowsMyError(() => evaluateModule(c));
+c.declarationInstantiation();
+assertThrowsMyError(() => c.evaluation());
 
 let b = moduleRepo['b'] = parseModule(`
     import * as ns0 from 'a'
 `);
-instantiateModule(b);
-assertThrowsMyError(() => evaluateModule(b));
+b.declarationInstantiation();
+assertThrowsMyError(() => b.evaluation(b));
--- a/js/src/jit-test/tests/modules/bug1485698.js
+++ b/js/src/jit-test/tests/modules/bug1485698.js
@@ -1,9 +1,9 @@
 let m = parseModule(`
   function f(x,y,z) {
     delete arguments[2];
     import.meta[2]
   }
   f(1,2,3)
 `);
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
--- a/js/src/jit-test/tests/modules/debugger-frames.js
+++ b/js/src/jit-test/tests/modules/debugger-frames.js
@@ -67,23 +67,23 @@ f = g2.eval(
     // Set up a module to import from.
     a = moduleRepo['a'] = parseModule(
     \`
         export var a = 1;
         export let b = 2;
         export const c = 3;
         export function f(x) { return x + 1; }
     \`);
-    instantiateModule(a);
-    evaluateModule(a);
+    a.declarationInstantiation();
+    a.evaluation();
 
     let m = parseModule(
     \`
         import { a, b, c } from 'a';
         var x = 4;
         let y = 5;
         const z = 6;
 
         debugger;
     \`);
-    instantiateModule(m);
-    evaluateModule(m);
+    m.declarationInstantiation();
+    m.evaluation();
 `);
--- a/js/src/jit-test/tests/modules/debugger-vars-function.js
+++ b/js/src/jit-test/tests/modules/debugger-vars-function.js
@@ -26,12 +26,12 @@ g.eval(
     \`
         var a = 1;
         let b = 2;
         export var c = 3;
         export let d = 4;
         let e = 5;
         function f() { debugger; return e; }
     \`);
-    instantiateModule(m);
-    evaluateModule(m);
+    m.declarationInstantiation();
+    m.evaluation();
 `);
 
--- a/js/src/jit-test/tests/modules/debugger-vars-toplevel.js
+++ b/js/src/jit-test/tests/modules/debugger-vars-toplevel.js
@@ -27,12 +27,12 @@ g.eval(
         var a = 1;
         let b = 2;
         export var c = 3;
         export let d = 4;
         let e = 5;
         function f() { return e; }
         debugger;
     \`);
-    instantiateModule(m);
-    evaluateModule(m);
+    m.declarationInstantiation();
+    m.evaluation();
 `);
 
--- a/js/src/jit-test/tests/modules/eval-module-oom.js
+++ b/js/src/jit-test/tests/modules/eval-module-oom.js
@@ -16,11 +16,11 @@ const sb =
  import { a as y } from "a";
  import * as ns from "a";
  ns.f(x, y);
 `;
 
 oomTest(() => {
     let a = moduleRepo['a'] = parseModule(sa);
     let b = moduleRepo['b'] = parseModule(sb);
-    instantiateModule(b);
-    assertEq(evaluateModule(b), 42);
+    b.declarationInstantiation();
+    assertEq(b.evaluation(), 42);
 });
--- a/js/src/jit-test/tests/modules/export-destructuring.js
+++ b/js/src/jit-test/tests/modules/export-destructuring.js
@@ -35,18 +35,18 @@ m = parseModule(`
     assertEq(a.i, 10);
     assertEq(a.j, 13);
     assertArrayEq(a.k, [14, 15, 16]);
     assertEq(a.l, 17);
     assertArrayEq(a.m, [18, 19]);
     assertArrayEq(a.n, [22]);
 `);
 
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
 
 moduleRepo['o'] = parseModule(`
     export const {} = {};
     export const {x: a=0} = {};
     export const {x: b=0} = {x: 1};
     export const {c, d, e} = {c: 2, d: 3, e: 4};
     export const {x: f} = {x: 5};
     export const {g} = {};
@@ -61,18 +61,18 @@ m = parseModule(`
     assertEq(o.c, 2);
     assertEq(o.d, 3);
     assertEq(o.e, 4);
     assertEq(o.f, 5);
     assertEq(o.g, undefined);
     assertEq(o.h, 6);
 `);
 
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
 
 moduleRepo['ao'] = parseModule(`
     export const [{x: a}, {x: b}] = [{x: 1}, {x: 2}];
     export const [{c}, {d}] = [{c: 3}, {d: 4}];
     export const [,, {e}, ...f] = [5, 6, {e: 7}, 8, 9];
 
     export const {x: [g, h, i]} = {x: [10, 11, 12]};
 
@@ -97,10 +97,10 @@ m = parseModule(`
     assertEq(ao.k, 16);
     assertEq(ao.l, 17);
     assertEq(ao.m, 18);
     assertEq(ao.n, 19);
     assertEq(ao.o, 20);
     assertEq(ao.p, 21);
 `);
 
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
--- a/js/src/jit-test/tests/modules/export-entries.js
+++ b/js/src/jit-test/tests/modules/export-entries.js
@@ -5,17 +5,17 @@ function testArrayContents(actual, expec
     for (var i = 0; i < actual.length; i++) {
         for (var property in expected[i]) {
             assertEq(actual[i][property], expected[i][property]);
         }
     }
 }
 
 function testLocalExportEntries(source, expected) {
-    var module = getModuleObject(parseModule(source));
+    var module = parseModule(source);
     testArrayContents(module.localExportEntries, expected);
 }
 
 testLocalExportEntries(
     'export var v;',
     [{exportName: 'v', moduleRequest: null, importName: null, localName: 'v'}]);
 
 testLocalExportEntries(
@@ -64,17 +64,17 @@ testLocalExportEntries(
 
 testLocalExportEntries(
     'export * from "mod";',
     []);
 
 // Test indirectExportEntries property
 
 function testIndirectExportEntries(source, expected) {
-    var module = getModuleObject(parseModule(source));
+    var module = parseModule(source);
     testArrayContents(module.indirectExportEntries, expected);
 }
 
 testIndirectExportEntries(
     'export default function f() {};',
     []);
 
 testIndirectExportEntries(
@@ -95,17 +95,17 @@ testIndirectExportEntries(
 
 testIndirectExportEntries(
     'import {v as x} from "mod"; export {x as y};',
     [{exportName: 'y', moduleRequest: 'mod', importName: 'v', localName: null}]);
 
 // Test starExportEntries property
 
 function testStarExportEntries(source, expected) {
-    var module = getModuleObject(parseModule(source));
+    var module = parseModule(source);
     testArrayContents(module.starExportEntries, expected);
 }
 
 testStarExportEntries(
     'export default function f() {};',
     []);
 
 testStarExportEntries(
--- a/js/src/jit-test/tests/modules/global-scope.js
+++ b/js/src/jit-test/tests/modules/global-scope.js
@@ -1,14 +1,14 @@
 // Test interaction with global object and global lexical scope.
 
 function evalModuleAndCheck(source, expected) {
     let m = parseModule(source);
-    instantiateModule(m);
-    evaluateModule(m);
+    m.declarationInstantiation();
+    m.evaluation();
     assertEq(getModuleEnvironmentValue(m, "r"), expected);
 }
 
 var x = 1;
 evalModuleAndCheck("export let r = x; x = 2;", 1);
 assertEq(x, 2);
 
 let y = 3;
@@ -17,18 +17,18 @@ assertEq(y, 4);
 
 if (helperThreadCount() == 0)
     quit();
 
 function offThreadEvalModuleAndCheck(source, expected) {
     offThreadCompileModule(source);
     let m = finishOffThreadModule();
     print("compiled");
-    instantiateModule(m);
-    evaluateModule(m);
+    m.declarationInstantiation();
+    m.evaluation();
     assertEq(getModuleEnvironmentValue(m, "r"), expected);
 }
 
 offThreadEvalModuleAndCheck("export let r = x; x = 5;", 2);
 assertEq(x, 5);
 
 offThreadEvalModuleAndCheck("export let r = y; y = 6;", 4);
 assertEq(y, 6);
--- a/js/src/jit-test/tests/modules/import-entries.js
+++ b/js/src/jit-test/tests/modules/import-entries.js
@@ -12,17 +12,17 @@ function findImportEntry(array, target)
     for (let i = 0; i < array.length; i++) {
         if (importEntryEq(array[i], target))
             return i;
     }
     return -1;
 }
 
 function testImportEntries(source, expected) {
-    var module = getModuleObject(parseModule(source));
+    var module = parseModule(source);
     var actual = module.importEntries.slice(0);
     assertEq(actual.length, expected.length);
     for (var i = 0; i < expected.length; i++) {
         let index = findImportEntry(actual, expected[i]);
         assertEq(index >= 0, true);
         actual.splice(index, 1);
     }
 }
--- a/js/src/jit-test/tests/modules/import-namespace.js
+++ b/js/src/jit-test/tests/modules/import-namespace.js
@@ -3,18 +3,18 @@
 "use strict";
 
 load(libdir + "asserts.js");
 load(libdir + "iteration.js");
 load(libdir + "dummyModuleResolveHook.js");
 
 function parseAndEvaluate(source) {
     let m = parseModule(source);
-    instantiateModule(m);
-    return evaluateModule(m);
+    m.declarationInstantiation();
+    return m.evaluation();
 }
 
 function testHasNames(names, expected) {
     assertEq(names.length, expected.length);
     expected.forEach(function(name) {
         assertEq(names.includes(name), true);
     });
 }
@@ -35,18 +35,18 @@ let a = moduleRepo['a'] = parseModule(
 );
 
 let b = moduleRepo['b'] = parseModule(
     `import * as ns from 'a';
      export { ns };
      export var x = ns.a + ns.b;`
 );
 
-instantiateModule(b);
-evaluateModule(b);
+b.declarationInstantiation();
+b.evaluation();
 testHasNames(getModuleEnvironmentNames(b), ["ns", "x"]);
 let ns = getModuleEnvironmentValue(b, "ns");
 testHasNames(Object.keys(ns), ["a", "b"]);
 assertEq(ns.a, 1);
 assertEq(ns.b, 2);
 assertEq(ns.c, undefined);
 assertEq(getModuleEnvironmentValue(b, "x"), 3);
 
@@ -84,23 +84,23 @@ testEqualArrays(Reflect.ownKeys(ns), ["a
 testEqualArrays(Object.getOwnPropertyNames(ns), ["a", "b"]);
 testEqualArrays(Object.getOwnPropertySymbols(ns), [Symbol.toStringTag]);
 
 // Test cyclic namespace import and access in module evaluation.
 let c = moduleRepo['c'] =
     parseModule("export let c = 1; import * as ns from 'd'; let d = ns.d;");
 let d = moduleRepo['d'] =
     parseModule("export let d = 2; import * as ns from 'c'; let c = ns.c;");
-instantiateModule(c);
-instantiateModule(d);
-assertThrowsInstanceOf(() => evaluateModule(c), ReferenceError);
+c.declarationInstantiation();
+d.declarationInstantiation();
+assertThrowsInstanceOf(() => c.evaluation(), ReferenceError);
 
 // Test cyclic namespace import.
 let e = moduleRepo['e'] =
     parseModule("export let e = 1; import * as ns from 'f'; export function f() { return ns.f }");
 let f = moduleRepo['f'] =
     parseModule("export let f = 2; import * as ns from 'e'; export function e() { return ns.e }");
-instantiateModule(e);
-instantiateModule(f);
-evaluateModule(e);
-evaluateModule(f);
-assertEq(getModuleObject(e).namespace.f(), 2);
-assertEq(getModuleObject(f).namespace.e(), 1);
+e.declarationInstantiation();
+f.declarationInstantiation();
+e.evaluation();
+f.evaluation();
+assertEq(e.namespace.f(), 2);
+assertEq(f.namespace.e(), 1);
--- a/js/src/jit-test/tests/modules/many-exports.js
+++ b/js/src/jit-test/tests/modules/many-exports.js
@@ -6,14 +6,14 @@ const count = 1024;
 
 let s = "";
 for (let i = 0; i < count; i++)
     s += "export let e" + i + " = " + (i * i) + ";\n";
 let a = moduleRepo['a'] = parseModule(s);
 
 let b = moduleRepo['b'] = parseModule("import * as ns from 'a'");
 
-instantiateModule(b);
-evaluateModule(b);
+b.declarationInstantiation();
+b.evaluation();
 
-let ns = getModuleObject(a).namespace;
+let ns = a.namespace;
 for (let i = 0; i < count; i++)
     assertEq(ns["e" + i], i * i);
--- a/js/src/jit-test/tests/modules/many-imports.js
+++ b/js/src/jit-test/tests/modules/many-imports.js
@@ -8,10 +8,10 @@ let a = moduleRepo['a'] = parseModule("e
 
 let s = "";
 for (let i = 0; i < count; i++) {
     s += "import { a as i" + i + " } from 'a';\n";
     s += "assertEq(i" + i + ", 1);\n";
 }
 let b = moduleRepo['b'] = parseModule(s);
 
-instantiateModule(b);
-evaluateModule(b);
+b.declarationInstantiation();
+b.evaluation();
--- a/js/src/jit-test/tests/modules/many-namespace-imports.js
+++ b/js/src/jit-test/tests/modules/many-namespace-imports.js
@@ -8,10 +8,10 @@ let a = moduleRepo['a'] = parseModule("e
 
 let s = "";
 for (let i = 0; i < count; i++) {
     s += "import * as ns" + i + " from 'a';\n";
     s += "assertEq(ns" + i + ".a, 1);\n";
 }
 let b = moduleRepo['b'] = parseModule(s);
 
-instantiateModule(b);
-evaluateModule(b);
+b.declarationInstantiation();
+b.evaluation();
--- a/js/src/jit-test/tests/modules/module-declaration-instantiation.js
+++ b/js/src/jit-test/tests/modules/module-declaration-instantiation.js
@@ -7,33 +7,33 @@ function testModuleEnvironment(module, e
     assertEq(actual.length, expected.length);
     for (var i = 0; i < actual.length; i++) {
         assertEq(actual[i], expected[i]);
     }
 }
 
 // Check the environment of an empty module.
 let m = parseModule("");
-instantiateModule(m);
+m.declarationInstantiation();
 testModuleEnvironment(m, []);
 
 let a = moduleRepo['a'] = parseModule("var x = 1; export { x };");
 let b = moduleRepo['b'] = parseModule("import { x as y } from 'a';");
 
-instantiateModule(a);
-instantiateModule(b);
+a.declarationInstantiation();
+b.declarationInstantiation();
 
 testModuleEnvironment(a, ['x']);
 testModuleEnvironment(b, ['y']);
 
 // Function bindings are initialized as well as instantiated.
 let c = parseModule(`function a(x) { return x; }
                      function b(x) { return x + 1; }
                      function c(x) { return x + 2; }
                      function d(x) { return x + 3; }`);
 const names = ['a', 'b', 'c', 'd'];
 testModuleEnvironment(c, names);
 names.forEach((n) => assertEq(typeof getModuleEnvironmentValue(c, n), "undefined"));
-instantiateModule(c);
+c.declarationInstantiation();
 for (let i = 0; i < names.length; i++) {
     let f = getModuleEnvironmentValue(c, names[i]);
     assertEq(f(21), 21 + i);
 }
--- a/js/src/jit-test/tests/modules/module-evaluation.js
+++ b/js/src/jit-test/tests/modules/module-evaluation.js
@@ -1,39 +1,39 @@
 // Exercise ModuleEvaluation() concrete method.
 
 load(libdir + "asserts.js");
 load(libdir + "dummyModuleResolveHook.js");
 
 function parseAndEvaluate(source) {
     let m = parseModule(source);
-    instantiateModule(m);
-    evaluateModule(m);
+    m.declarationInstantiation();
+    m.evaluation();
     return m;
 }
 
 // Check the evaluation of an empty module succeeds.
 parseAndEvaluate("");
 
 // Check evaluation returns evaluation result the first time, then undefined.
 let m = parseModule("1");
-instantiateModule(m);
-assertEq(evaluateModule(m), undefined);
-assertEq(typeof evaluateModule(m), "undefined");
+m.declarationInstantiation();
+assertEq(m.evaluation(), undefined);
+assertEq(typeof m.evaluation(), "undefined");
 
 // Check top level variables are initialized by evaluation.
 m = parseModule("export var x = 2 + 2;");
 assertEq(typeof getModuleEnvironmentValue(m, "x"), "undefined");
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
 assertEq(getModuleEnvironmentValue(m, "x"), 4);
 
 m = parseModule("export let x = 2 * 3;");
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
 assertEq(getModuleEnvironmentValue(m, "x"), 6);
 
 // Set up a module to import from.
 let a = moduleRepo['a'] =
 parseModule(`var x = 1;
              export { x };
              export default 2;
              export function f(x) { return x + 1; }`);
@@ -57,30 +57,30 @@ parseAndEvaluate("import a from 'a';");
 parseAndEvaluate("import { x } from 'a';");
 parseAndEvaluate("import * as ns from 'a';");
 parseAndEvaluate("export * from 'a'");
 parseAndEvaluate("export default class { constructor() {} };");
 parseAndEvaluate("export default class foo { constructor() {} };");
 
 // Test default import
 m = parseModule("import a from 'a'; export { a };")
-instantiateModule(m);
-evaluateModule(m)
+m.declarationInstantiation();
+m.evaluation()
 assertEq(getModuleEnvironmentValue(m, "a"), 2);
 
 // Test named import
 m = parseModule("import { x as y } from 'a'; export { y };")
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
 assertEq(getModuleEnvironmentValue(m, "y"), 1);
 
 // Call exported function
 m = parseModule("import { f } from 'a'; export let x = f(3);")
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
 assertEq(getModuleEnvironmentValue(m, "x"), 4);
 
 // Test importing an indirect export
 moduleRepo['b'] = parseModule("export { x as z } from 'a';");
 m = parseAndEvaluate("import { z } from 'b'; export { z }");
 assertEq(getModuleEnvironmentValue(m, "z"), 1);
 
 // Test cyclic dependencies
@@ -88,12 +88,12 @@ moduleRepo['c1'] = parseModule("export v
 moduleRepo['c2'] = parseModule("export var y = 2; export {x} from 'c1'");
 m = parseAndEvaluate(`import { x as x1, y as y1 } from 'c1';
                       import { x as x2, y as y2 } from 'c2';
                       export let z = [x1, y1, x2, y2]`),
 assertDeepEq(getModuleEnvironmentValue(m, "z"), [1, 2, 1, 2]);
 
 // Import access in functions
 m = parseModule("import { x } from 'a'; function f() { return x; }")
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
 let f = getModuleEnvironmentValue(m, "f");
 assertEq(f(), 1);
--- a/js/src/jit-test/tests/modules/module-this.js
+++ b/js/src/jit-test/tests/modules/module-this.js
@@ -1,15 +1,15 @@
 // Test 'this' is undefined in modules.
 
 function parseAndEvaluate(source) {
     let m = parseModule(source);
-    instantiateModule(m);
-    return evaluateModule(m);
+    m.declarationInstantiation();
+    return m.evaluation();
 }
 
 assertEq(typeof(parseAndEvaluate("this")), "undefined");
 
 let m = parseModule("export function getThis() { return this; }");
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
 let f = getModuleEnvironmentValue(m, "getThis");
 assertEq(typeof(f()), "undefined");
--- a/js/src/jit-test/tests/modules/off-thread-compile.js
+++ b/js/src/jit-test/tests/modules/off-thread-compile.js
@@ -4,13 +4,13 @@ if (helperThreadCount() == 0)
     quit();
 
 load(libdir + "asserts.js");
 load(libdir + "dummyModuleResolveHook.js");
 
 function offThreadParseAndEvaluate(source) {
     offThreadCompileModule(source);
     let m = finishOffThreadModule();
-    instantiateModule(m);
-    return evaluateModule(m);
+    m.declarationInstantiation();
+    return m.evaluation();
 }
 
 offThreadParseAndEvaluate("export let x = 2 * 3;");
--- a/js/src/jit-test/tests/modules/requested-modules.js
+++ b/js/src/jit-test/tests/modules/requested-modules.js
@@ -1,12 +1,12 @@
 // Test requestedModules property
 
 function testRequestedModules(source, expected) {
-    var module = getModuleObject(parseModule(source));
+    var module = parseModule(source);
     var actual = module.requestedModules;
     assertEq(actual.length, expected.length);
     for (var i = 0; i < actual.length; i++) {
         assertEq(actual[i].moduleSpecifier, expected[i]);
     }
 }
 
 testRequestedModules("", []);
--- a/js/src/jit-test/tests/parser/bug-1263355-16.js
+++ b/js/src/jit-test/tests/parser/bug-1263355-16.js
@@ -2,10 +2,10 @@
 
 let m = parseModule(`
 var i = 0;
 addThis();
 function addThis() {
   return statusmessages[i] = Number;
 }
 `);
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
--- a/js/src/jit-test/tests/parser/bug-1263355-23.js
+++ b/js/src/jit-test/tests/parser/bug-1263355-23.js
@@ -1,7 +1,7 @@
 let m = parseModule(`
   const root = newGlobal();
   minorgc();
   root.eval();
 `);
-instantiateModule(m);
-evaluateModule(m);
+m.declarationInstantiation();
+m.evaluation();
--- a/js/src/jit-test/tests/parser/bug-1263355-48.js
+++ b/js/src/jit-test/tests/parser/bug-1263355-48.js
@@ -1,16 +1,16 @@
 if (helperThreadCount() == 0)
   quit();
 
 function eval(source) {
     offThreadCompileModule(source);
     let m = finishOffThreadModule();
-    instantiateModule(m);
-    return evaluateModule(m);
+    m.declarationInstantiation();
+    return m.evaluation();
 }
 function runTestCase(testcase) {
     if (testcase() !== true) {}
 }
 eval(`
   function testcase() {
     function set () {}
   }
--- a/js/src/shell/ModuleLoader.js
+++ b/js/src/shell/ModuleLoader.js
@@ -1,14 +1,14 @@
 /* -*- Mode: javascript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
 /* 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/. */
 
-/* global getModuleLoadPath setModuleLoadHook setModuleResolveHook parseModule instantiateModule evaluateModule os */
+/* global getModuleLoadPath setModuleLoadHook setModuleResolveHook parseModule os */
 
 // A basic synchronous module loader for testing the shell.
 {
 // Save standard built-ins before scripts can modify them.
 const ArrayPrototypeJoin = Array.prototype.join;
 const MapPrototypeGet = Map.prototype.get;
 const MapPrototypeHas = Map.prototype.has;
 const MapPrototypeSet = Map.prototype.set;
@@ -156,18 +156,18 @@ const ReflectLoader = new class {
         let module = parseModule(source, path);
         ReflectApply(MapPrototypeSet, this.registry, [normalized, module]);
         ReflectApply(MapPrototypeSet, this.modulePaths, [module, path]);
         return module;
     }
 
     loadAndExecute(path) {
         let module = this.loadAndParse(path);
-        instantiateModule(module);
-        return evaluateModule(module);
+        module.declarationInstantiation();
+        return module.evaluation();
     }
 
     importRoot(path) {
         return this.loadAndExecute(path);
     }
 
     ["import"](name, referrer) {
         let path = this.resolve(name, null);
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -483,24 +483,18 @@ OffThreadJob::waitUntilDone(JSContext* c
     while (state != DONE) {
         alm.wait();
     }
 
     MOZ_ASSERT(token);
     return token;
 }
 
-using ScriptObjectMap = JS::WeakCache<js::GCHashMap<HeapPtr<JSScript*>,
-                                                    HeapPtr<JSObject*>,
-                                                    MovableCellHasher<HeapPtr<JSScript*>>,
-                                                    SystemAllocPolicy>>;
-
 struct ShellCompartmentPrivate {
     GCPtrObject grayRoot;
-    UniquePtr<ScriptObjectMap> moduleLoaderScriptObjectMap;
 };
 
 struct MOZ_STACK_CLASS EnvironmentPreparer : public js::ScriptEnvironmentPreparer {
     explicit EnvironmentPreparer(JSContext* cx)
     {
         js::SetScriptEnvironmentPreparer(cx, this);
     }
     void invoke(JS::HandleObject global, Closure& closure) override;
@@ -3837,36 +3831,36 @@ EnsureGeckoProfilingStackInstalled(JSCon
         JS_ReportOutOfMemory(cx);
         return false;
     }
 
     SetContextProfilingStack(cx, sc->geckoProfilingStack.get());
     return true;
 }
 
-static void
-DestroyShellCompartmentPrivate(JSFreeOp* fop, JS::Compartment* compartment)
-{
-    auto priv = static_cast<ShellCompartmentPrivate*>(JS_GetCompartmentPrivate(compartment));
-    js_delete(priv);
-}
-
 struct WorkerInput
 {
     JSRuntime* parentRuntime;
     UniqueTwoByteChars chars;
     size_t length;
 
     WorkerInput(JSRuntime* parentRuntime, UniqueTwoByteChars chars, size_t length)
       : parentRuntime(parentRuntime), chars(std::move(chars)), length(length)
     {}
 
     ~WorkerInput() = default;
 };
 
+static void
+DestroyShellCompartmentPrivate(JSFreeOp* fop, JS::Compartment* compartment)
+{
+    auto priv = static_cast<ShellCompartmentPrivate*>(JS_GetCompartmentPrivate(compartment));
+    js_delete(priv);
+}
+
 static void SetWorkerContextOptions(JSContext* cx);
 static bool ShellBuildId(JS::BuildIdCharVector* buildId);
 
 static void
 WorkerMain(WorkerInput* input)
 {
     MOZ_ASSERT(input->parentRuntime);
 
@@ -4615,93 +4609,16 @@ EnsureShellCompartmentPrivate(JSContext*
     auto priv = static_cast<ShellCompartmentPrivate*>(JS_GetCompartmentPrivate(comp));
     if (!priv) {
         priv = cx->new_<ShellCompartmentPrivate>();
         JS_SetCompartmentPrivate(cx->compartment(), priv);
     }
     return priv;
 }
 
-static ScriptObjectMap*
-EnsureModuleLoaderScriptObjectMap(JSContext* cx)
-{
-    auto priv = EnsureShellCompartmentPrivate(cx);
-    if (!priv) {
-        return nullptr;
-    }
-
-    if (priv->moduleLoaderScriptObjectMap) {
-        return priv->moduleLoaderScriptObjectMap.get();
-    }
-
-    JS::Zone* zone = cx->zone();
-    auto* map = cx->new_<ScriptObjectMap>(zone);
-    if (!map) {
-        return nullptr;
-    }
-
-    priv->moduleLoaderScriptObjectMap.reset(map);
-    return map;
-}
-
-// An object used to represent a JSScript in the shell's self-hosted module
-// loader since we can't pass those directly.
-class ShellScriptObject : public NativeObject
-{
-  public:
-    static const Class class_;
-
-    enum {
-        ScriptSlot = 0
-    };
-
-    static JSObject* get(JSContext* cx, HandleScript script);
-
-    JSScript* script() const;
-};
-
-const Class ShellScriptObject::class_ = {
-    "ShellScriptObject",
-    JSCLASS_HAS_RESERVED_SLOTS(1)
-};
-
-/* static */ JSObject*
-ShellScriptObject::get(JSContext* cx, HandleScript script)
-{
-    auto map = EnsureModuleLoaderScriptObjectMap(cx);
-    if (!map) {
-        return nullptr;
-    }
-
-    auto ptr = map->lookup(script);
-    if (ptr) {
-        return ptr->value();
-    }
-
-    JSObject* obj = NewObjectWithGivenProto(cx, &class_, nullptr);
-    if (!obj) {
-        return nullptr;
-    }
-
-    obj->as<NativeObject>().setReservedSlot(ScriptSlot, PrivateGCThingValue(script));
-
-    if (!map->put(script, obj)) {
-        ReportOutOfMemory(cx);
-        return nullptr;
-    }
-
-    return obj;
-}
-
-JSScript*
-ShellScriptObject::script() const
-{
-    return getReservedSlot(ScriptSlot).toGCThing()->as<JSScript>();
-}
-
 static bool
 ParseModule(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     if (args.length() == 0) {
         JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED,
                                   "parseModule", "0", "s");
         return false;
@@ -4747,81 +4664,18 @@ ParseModule(JSContext* cx, unsigned argc
     JS::SourceBufferHolder srcBuf(chars, scriptContents->length(),
                                   JS::SourceBufferHolder::NoOwnership);
 
     RootedScript script(cx, frontend::CompileModule(cx, options, srcBuf));
     if (!script) {
         return false;
     }
 
-    JSObject* obj = ShellScriptObject::get(cx, script);
-    if (!obj) {
-        return false;
-    }
-
-    args.rval().setObject(*obj);
-    return true;
-}
-
-static bool
-ReportArgumentTypeError(JSContext* cx, HandleValue value, const char* expected)
-{
-    const char* typeName = InformalValueTypeName(value);
-    JS_ReportErrorASCII(cx, "Expected %s, got %s", expected, typeName);
-    return false;
-}
-
-static bool
-InstantiateModule(JSContext* cx, unsigned argc, Value* vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-    if (args.length() != 1) {
-        JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED,
-                                  "instantiateModule", "0", "s");
-        return false;
-    }
-
-    if (!args[0].isObject() || !args[0].toObject().is<ShellScriptObject>()) {
-        return ReportArgumentTypeError(cx, args[0], "ShellScriptObject");
-    }
-
-    JSScript* script = args[0].toObject().as<ShellScriptObject>().script();
-    RootedModuleObject module(cx, script->module());
-    if (!module) {
-        JS_ReportErrorASCII(cx, "Expected a module script");
-        return false;
-    }
-
-    args.rval().setUndefined();
-    return ModuleObject::Instantiate(cx, module);
-}
-
-static bool
-EvaluateModule(JSContext* cx, unsigned argc, Value* vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-    if (args.length() != 1) {
-        JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED,
-                                  "evaluateModule", "0", "s");
-        return false;
-    }
-
-    if (!args[0].isObject() || !args[0].toObject().is<ShellScriptObject>()) {
-        return ReportArgumentTypeError(cx, args[0], "ShellScriptObject");
-    }
-
-    JSScript* script = args[0].toObject().as<ShellScriptObject>().script();
-    RootedModuleObject module(cx, script->module());
-    if (!module) {
-        JS_ReportErrorASCII(cx, "Expected a module script");
-        return false;
-    }
-
-    args.rval().setUndefined();
-    return ModuleObject::Evaluate(cx, module);
+    args.rval().setObject(*script->module());
+    return true;
 }
 
 static bool
 SetModuleLoadHook(JSContext* cx, unsigned argc, Value* vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
     if (args.length() != 1) {
         JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED,
@@ -4873,36 +4727,31 @@ CallModuleResolveHook(JSContext* cx, Han
     Handle<GlobalObject*> global = cx->global();
     RootedValue hookValue(cx, global->getReservedSlot(GlobalAppSlotModuleResolveHook));
     if (hookValue.isUndefined()) {
         JS_ReportErrorASCII(cx, "Module resolve hook not set");
         return nullptr;
     }
     MOZ_ASSERT(hookValue.toObject().is<JSFunction>());
 
-    JSObject* obj = ShellScriptObject::get(cx, script);
-    if (!obj) {
-        return nullptr;
-    }
-
     JS::AutoValueArray<2> args(cx);
-    args[0].setObject(*obj);
+    args[0].setObject(*script->module());
     args[1].setString(specifier);
 
     RootedValue result(cx);
     if (!JS_CallFunctionValue(cx, nullptr, hookValue, args, &result)) {
         return nullptr;
     }
 
-    if (!result.isObject() || !result.toObject().is<ShellScriptObject>()) {
-         JS_ReportErrorASCII(cx, "Module resolve hook did not return script object");
+    if (!result.isObject() || !result.toObject().is<ModuleObject>()) {
+         JS_ReportErrorASCII(cx, "Module resolve hook did not return Module object");
          return nullptr;
     }
 
-    return result.toObject().as<ShellScriptObject>().script();
+    return result.toObject().as<ModuleObject>().script();
 }
 
 static bool
 ShellModuleMetadataHook(JSContext* cx, HandleScript script, HandleObject metaObject)
 {
     // For the shell, just use the script's filename as the base URL.
     const char* filename = script->scriptSource()->filename();
     MOZ_ASSERT(filename);
@@ -4933,143 +4782,16 @@ GetModuleLoadPath(JSContext* cx, unsigne
 
         args.rval().setString(str);
     } else {
         args.rval().setNull();
     }
     return true;
 }
 
-static ModuleEnvironmentObject*
-GetModuleEnvironment(JSContext* cx, HandleValue scriptValue)
-{
-    JSScript* script = scriptValue.toObject().as<ShellScriptObject>().script();
-    RootedModuleObject module(cx, script->module());
-    if (!module) {
-        JS_ReportErrorASCII(cx, "Expecting a module script");
-        return nullptr;
-    }
-
-    if (module->hadEvaluationError()) {
-        JS_ReportErrorASCII(cx, "Module environment unavailable");
-        return nullptr;
-    }
-
-    // Use the initial environment so that tests can check bindings exist before
-    // they have been instantiated.
-    RootedModuleEnvironmentObject env(cx, &module->initialEnvironment());
-    MOZ_ASSERT(env);
-    return env;
-}
-
-static bool
-GetModuleEnvironmentNames(JSContext* cx, unsigned argc, Value* vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-    if (args.length() != 1) {
-        JS_ReportErrorASCII(cx, "Wrong number of arguments");
-        return false;
-    }
-
-    if (!args[0].isObject() || !args[0].toObject().is<ShellScriptObject>()) {
-        JS_ReportErrorASCII(cx, "First argument should be a ShellScriptObject");
-        return false;
-    }
-
-    RootedModuleEnvironmentObject env(cx, GetModuleEnvironment(cx, args[0]));
-    if (!env) {
-        return false;
-    }
-
-    Rooted<IdVector> ids(cx, IdVector(cx));
-    if (!JS_Enumerate(cx, env, &ids)) {
-        return false;
-    }
-
-    uint32_t length = ids.length();
-    RootedArrayObject array(cx, NewDenseFullyAllocatedArray(cx, length));
-    if (!array) {
-        return false;
-    }
-
-    array->setDenseInitializedLength(length);
-    for (uint32_t i = 0; i < length; i++) {
-        array->initDenseElement(i, StringValue(JSID_TO_STRING(ids[i])));
-    }
-
-    args.rval().setObject(*array);
-    return true;
-}
-
-static bool
-GetModuleEnvironmentValue(JSContext* cx, unsigned argc, Value* vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-    if (args.length() != 2) {
-        JS_ReportErrorASCII(cx, "Wrong number of arguments");
-        return false;
-    }
-
-    if (!args[0].isObject() || !args[0].toObject().is<ShellScriptObject>()) {
-        JS_ReportErrorASCII(cx, "First argument should be a ShellScriptObject");
-        return false;
-    }
-
-    RootedModuleEnvironmentObject env(cx, GetModuleEnvironment(cx, args[0]));
-    if (!env) {
-        return false;
-    }
-
-    RootedString name(cx, JS::ToString(cx, args[1]));
-    if (!name) {
-        return false;
-    }
-
-    RootedId id(cx);
-    if (!JS_StringToId(cx, name, &id)) {
-        return false;
-    }
-
-    if (!GetProperty(cx, env, env, id, args.rval())) {
-        return false;
-    }
-
-    if (args.rval().isMagic(JS_UNINITIALIZED_LEXICAL)) {
-        ReportRuntimeLexicalError(cx, JSMSG_UNINITIALIZED_LEXICAL, id);
-        return false;
-    }
-
-    return true;
-}
-
-static bool
-GetModuleObject(JSContext* cx, unsigned argc, Value* vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-    if (args.length() != 1) {
-        JS_ReportErrorASCII(cx, "Wrong number of arguments");
-        return false;
-    }
-
-    if (!args[0].isObject() || !args[0].toObject().is<ShellScriptObject>()) {
-        JS_ReportErrorASCII(cx, "First argument should be a ShellScriptObject");
-        return false;
-    }
-
-    JSScript* script = args[0].toObject().as<ShellScriptObject>().script();
-    RootedModuleObject module(cx, script->module());
-    if (!module) {
-        JS_ReportErrorASCII(cx, "Expecting a module script");
-        return false;
-    }
-
-    args.rval().setObject(*module);
-    return true;
-}
-
 #if defined(JS_BUILD_BINAST)
 
 using js::frontend::BinASTParser;
 using js::frontend::Directives;
 using js::frontend::GlobalSharedContext;
 using js::frontend::ParseNode;
 using js::frontend::UsedNameTracker;
 
@@ -5572,22 +5294,17 @@ FinishOffThreadModule(JSContext* cx, uns
 
     DeleteOffThreadJob(cx, job);
 
     RootedScript script(cx, JS::FinishOffThreadModule(cx, token));
     if (!script) {
         return false;
     }
 
-    JSObject* obj = ShellScriptObject::get(cx, script);
-    if (!obj) {
-        return false;
-    }
-
-    args.rval().setObject(*obj);
+    args.rval().setObject(*script->module());
     return true;
 }
 
 static bool
 OffThreadDecodeScript(JSContext* cx, unsigned argc, Value* vp)
 {
     if (!CanUseExtraThreads()) {
         JS_ReportErrorASCII(cx, "Can't use offThreadDecodeScript with --no-threads");
@@ -8240,25 +7957,17 @@ static const JSFunctionSpecWithHelp shel
 "  Sleep for dt seconds."),
 
     JS_FN_HELP("compile", Compile, 1, 0,
 "compile(code)",
 "  Compiles a string to bytecode, potentially throwing."),
 
     JS_FN_HELP("parseModule", ParseModule, 1, 0,
 "parseModule(code)",
-"  Parses source text as a module and returns a script object."),
-
-    JS_FN_HELP("instantiateModule", InstantiateModule, 1, 0,
-"instantiateModule(moduleScript)",
-"  Instantiate a module script graph."),
-
-    JS_FN_HELP("evaluateModule", EvaluateModule, 1, 0,
-"evaluateModule(moduleScript)",
-"  Evaluate a previously instantiated module script graph."),
+"  Parses source text as a module and returns a Module object."),
 
     JS_FN_HELP("setModuleLoadHook", SetModuleLoadHook, 1, 0,
 "setModuleLoadHook(function(path))",
 "  Set the shell specific module load hook to |function|.\n"
 "  This hook is used to load a module graph.  It should be implemented by the\n"
 "  module loader."),
 
     JS_FN_HELP("setModuleResolveHook", SetModuleResolveHook, 1, 0,
@@ -8267,28 +7976,16 @@ static const JSFunctionSpecWithHelp shel
 "  This hook is used to look up a previously loaded module object.  It should\n"
 "  be implemented by the module loader."),
 
     JS_FN_HELP("getModuleLoadPath", GetModuleLoadPath, 0, 0,
 "getModuleLoadPath()",
 "  Return any --module-load-path argument passed to the shell.  Used by the\n"
 "  module loader.\n"),
 
-    JS_FN_HELP("getModuleEnvironmentNames", GetModuleEnvironmentNames, 1, 0,
-"getModuleEnvironmentNames(module)",
-"  Get the list of a module environment's bound names for a specified module.\n"),
-
-    JS_FN_HELP("getModuleEnvironmentValue", GetModuleEnvironmentValue, 2, 0,
-"getModuleEnvironmentValue(module, name)",
-"  Get the value of a bound name in a module environment.\n"),
-
-    JS_FN_HELP("getModuleObject", GetModuleObject, 1, 0,
-"getModuleObject(module)",
-"  Get the internal JS object that holds module metadata for a module script.\n"),
-
 #if defined(JS_BUILD_BINAST)
 
 JS_FN_HELP("parseBin", BinParse, 1, 0,
 "parseBin(arraybuffer)",
 "  Parses a Binary AST, potentially throwing."),
 
 #endif // defined(JS_BUILD_BINAST)
 
--- a/js/src/shell/jsshell.h
+++ b/js/src/shell/jsshell.h
@@ -9,17 +9,16 @@
 
 #include "mozilla/Atomics.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/Variant.h"
 
 #include "jsapi.h"
 
-#include "gc/WeakMap.h"
 #include "js/GCVector.h"
 #include "threading/ConditionVariable.h"
 #include "threading/LockGuard.h"
 #include "threading/Mutex.h"
 #include "threading/Thread.h"
 #include "vm/GeckoProfiler.h"
 #include "vm/Monitor.h"