Bug 1443555 - Remove bogus assertion to allow getting the module environment even if there was an error evaluating the module r=anba
authorJon Coppeard <jcoppeard@mozilla.com>
Thu, 26 Apr 2018 15:54:00 +0100
changeset 415813 dbf3be36c24fa0f51637e98b7e1d2c397648e508
parent 415812 d351edd71d7478980704c03a3d258bc9e15e6cde
child 415814 cf1e88230672c5ad0235be34695e7687ade52a6b
push id33910
push usershindli@mozilla.com
push dateThu, 26 Apr 2018 21:39:52 +0000
treeherdermozilla-central@63a0e2f626fe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersanba
bugs1443555
milestone61.0a1
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
Bug 1443555 - Remove bogus assertion to allow getting the module environment even if there was an error evaluating the module r=anba
js/src/builtin/ModuleObject.cpp
js/src/jit-test/tests/modules/bug-1443555.js
--- a/js/src/builtin/ModuleObject.cpp
+++ b/js/src/builtin/ModuleObject.cpp
@@ -807,17 +807,18 @@ ModuleObject::initialEnvironment() const
 {
     Value value = getReservedSlot(EnvironmentSlot);
     return value.toObject().as<ModuleEnvironmentObject>();
 }
 
 ModuleEnvironmentObject*
 ModuleObject::environment() const
 {
-    MOZ_ASSERT(!hadEvaluationError());
+    // Note that this it's valid to call this even if there was an error
+    // evaluating the module.
 
     // According to the spec the environment record is created during
     // instantiation, but we create it earlier than that.
     if (status() < MODULE_STATUS_INSTANTIATED)
         return nullptr;
 
     return &initialEnvironment();
 }
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/modules/bug-1443555.js
@@ -0,0 +1,36 @@
+// |jit-test| error: TypeError
+
+"use strict";
+
+setJitCompilerOption("baseline.warmup.trigger", 0);
+
+let moduleRepo = {};
+setModuleResolveHook(function(module, specifier) {
+    if (specifier in moduleRepo)
+        return moduleRepo[specifier];
+    throw "Module '" + specifier + "' not found";
+});
+
+let mainSrc = `
+import A from "A";
+
+const a = A;
+
+function requestAnimationFrame(f) { Promise.resolve().then(f); };
+
+requestAnimationFrame(loopy);
+a = 2;
+function loopy() {
+    A;
+}
+`;
+
+let ASrc = `
+export default 1;
+`;
+
+moduleRepo['A'] = parseModule(ASrc);
+
+let m = parseModule(mainSrc);
+m.declarationInstantiation()
+m.evaluation();