Bug 1499140 - Add OOM tests for shell dynamic module import and fix bugs r=jandem
authorJon Coppeard <jcoppeard@mozilla.com>
Mon, 22 Oct 2018 11:28:17 +0100
changeset 490636 a836d54d21da033ae12512de20e68b21454df06b
parent 490635 84f29739c1da074c184d5e21e73b59d083a0e29d
child 490637 9ae36cdd861ec0f77b8e10a854866d565c7c40fe
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersjandem
bugs1499140
milestone64.0a1
Bug 1499140 - Add OOM tests for shell dynamic module import and fix bugs r=jandem
js/src/builtin/Module.js
js/src/jit-test/tests/modules/dynamic-import-oom.js
--- a/js/src/builtin/Module.js
+++ b/js/src/builtin/Module.js
@@ -294,26 +294,27 @@ function ModuleInstantiate()
     let stack = [];
 
     // Steps 4-5
     try {
         InnerModuleInstantiation(module, stack, 0);
     } catch (error) {
         for (let i = 0; i < stack.length; i++) {
             let m = stack[i];
-            assert(m.status === MODULE_STATUS_INSTANTIATING,
-                   "Expected instantiating status during failed instantiation");
-            HandleModuleInstantiationFailure(m);
+            if (m.status === MODULE_STATUS_INSTANTIATING) {
+                HandleModuleInstantiationFailure(m);
+            }
         }
 
         // Handle OOM when appending to the stack or over-recursion errors.
-        if (stack.length === 0)
+        if (stack.length === 0 && module.status === MODULE_STATUS_INSTANTIATING) {
             HandleModuleInstantiationFailure(module);
+        }
 
-        assert(module.status === MODULE_STATUS_UNINSTANTIATED,
+        assert(module.status !== MODULE_STATUS_INSTANTIATING,
                "Expected uninstantiated status after failed instantiation");
 
         throw error;
     }
 
     // Step 6
     assert(module.status === MODULE_STATUS_INSTANTIATED ||
            module.status === MODULE_STATUS_EVALUATED ||
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/modules/dynamic-import-oom.js
@@ -0,0 +1,4 @@
+// |jit-test| skip-if: !('oomTest' in this)
+
+oomTest(() => import("module1.js"));
+oomTest(() => import("cyclicImport1.js"));