Bug 1593329 - Split up FinalizationGroup tests r=sfink
☠☠ backed out by 92e49cf89327 ☠ ☠
authorJon Coppeard <jcoppeard@mozilla.com>
Fri, 08 Nov 2019 10:43:26 +0000
changeset 501249 6daf24d641d942350626455dfc754ff8c18885c7
parent 501248 382341353d0d989eb1bbb660329e380f90036e71
child 501250 50b2bb645118f2650abfc9f40d409114e57746bd
push id100089
push userjcoppeard@mozilla.com
push dateFri, 08 Nov 2019 10:45:22 +0000
treeherderautoland@6daf24d641d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1593329
milestone72.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 1593329 - Split up FinalizationGroup tests r=sfink Differential Revision: https://phabricator.services.mozilla.com/D52196
js/src/jit-test/tests/gc/finalizationGroup-ccw.js
js/src/jit-test/tests/gc/finalizationGroup-oom1.js
js/src/jit-test/tests/gc/finalizationGroup-oom2.js
js/src/jit-test/tests/gc/finalizationGroup-oom3.js
js/src/jit-test/tests/gc/finalizationGroup.js
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/gc/finalizationGroup-ccw.js
@@ -0,0 +1,50 @@
+// |jit-test| --enable-weak-refs
+
+// Test combinations of arguments in different compartments.
+
+let holdings = [];
+let group = new FinalizationGroup(iterator => {
+    for (const holding of iterator) {
+        holdings.push(holding);
+    }
+});
+
+function ccwToObject() {
+    return evalcx('({})', newGlobal({newCompartment: true}));
+}
+
+function ccwToGroup() {
+    let global = newGlobal({newCompartment: true});
+    global.holdings = holdings;
+    return global.eval(
+        `new FinalizationGroup(iterator => holdings.push(...iterator))`);
+}
+
+function incrementalGC() {
+    startgc(1);
+    while (gcstate() !== "NotActive") {
+        gcslice(1000);
+    }
+}
+
+for (let w of [false, true]) {
+    for (let x of [false, true]) {
+        for (let y of [false, true]) {
+            for (let z of [false, true]) {
+                let g = w ? ccwToGroup(w) : group;
+                let target = x ? ccwToObject() : {};
+                let holding = y ? ccwToObject() : {};
+                let token = z ? ccwToObject() : {};
+                g.register(target, holding, token);
+                g.unregister(token);
+                g.register(target, holding, token);
+                target = undefined;
+                incrementalGC();
+                holdings.length = 0; // Clear, don't replace.
+                g.cleanupSome();
+                assertEq(holdings.length, 1);
+                assertEq(holdings[0], holding);
+            }
+        }
+    }
+}
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/gc/finalizationGroup-oom1.js
@@ -0,0 +1,8 @@
+// |jit-test| --enable-weak-refs; skip-if: !('oomTest' in this)
+
+// Don't test prototype initialization etc.
+new FinalizationGroup(x => 0);
+
+oomTest(() => {
+    new FinalizationGroup(x => 0);
+});
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/gc/finalizationGroup-oom2.js
@@ -0,0 +1,4 @@
+// |jit-test| --enable-weak-refs; skip-if: !('oomTest' in this)
+let group = new FinalizationGroup(x => 0);
+let token = {};
+oomTest(() => group.register({}, 1, token));
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/gc/finalizationGroup-oom3.js
@@ -0,0 +1,4 @@
+// |jit-test| --enable-weak-refs; skip-if: !('oomTest' in this)
+let group = new FinalizationGroup(x => 0);
+group.register({}, 1, {});
+oomTest(() => group.unregister(token));
--- a/js/src/jit-test/tests/gc/finalizationGroup.js
+++ b/js/src/jit-test/tests/gc/finalizationGroup.js
@@ -154,25 +154,16 @@ group.register({}, 4, token2);
 group.unregister(token);
 gc();
 drainJobQueue();
 assertEq(holdings.length, 2);
 holdings = holdings.sort((a, b) => a - b);
 assertEq(holdings[0], 2);
 assertEq(holdings[1], 4);
 
-// OOM test.
-if ('oomTest' in this) {
-    oomTest(() => new FinalizationGroup(x => 0));
-
-    let token = {};
-    oomTest(() => group.register({}, 1, token));
-    oomTest(() => group.unregister(token));
-}
-
 // Watch object in another global.
 let other = newGlobal({newCompartment: true});
 holdings = [];
 group.register(evalcx('({})', other), 1);
 gc();
 drainJobQueue();
 assertEq(holdings.length, 1);
 assertEq(holdings[0], 1);
@@ -252,50 +243,8 @@ assertEq(holdings[2], 3);
 
 // Test trying to call cleanupSome in callback.
 let g6 = new FinalizationGroup(x => {
     assertThrowsTypeError(() => g6.cleanupSome());
 });
 g6.register({}, 1);
 gc();
 drainJobQueue();
-
-// Test combinations of arguments in different compartments.
-function ccwToObject() {
-    return evalcx('({})', newGlobal({newCompartment: true}));
-}
-function ccwToGroup() {
-    let global = newGlobal({newCompartment: true});
-    global.holdings = holdings;
-    return global.eval(`
-      new FinalizationGroup(iterator => {
-        for (const holding of iterator) {
-          holdings.push(holding);
-        }
-      })`);
-}
-function incrementalGC() {
-    startgc(1);
-    while (gcstate() !== "NotActive") {
-        gcslice(1000);
-    }
-}
-for (let w of [false, true]) {
-    for (let x of [false, true]) {
-        for (let y of [false, true]) {
-            for (let z of [false, true]) {
-                let g = w ? ccwToGroup(w) : group;
-                let target = x ? ccwToObject() : {};
-                let holding = y ? ccwToObject() : {};
-                let token = z ? ccwToObject() : {};
-                g.register(target, holding, token);
-                g.unregister(token);
-                g.register(target, holding, token);
-                target = undefined;
-                incrementalGC();
-                holdings.length = 0; // Clear, don't replace.
-                g.cleanupSome();
-                assertEq(holdings.length, 1);
-                assertEq(holdings[0], holding);
-            }
-        }
-    }
-}