blob: 55e21a6b151396a18706b87b2b5794918892482f [file] [log] [blame]
--- weak-marking-01.js
+++ weak-marking-01.js
@@ -85,15 +85,35 @@ function deadKeys() {
gc();
assertEq(finalizeCount(), initialCount + 2);
assertEq(nondeterministicGetWeakMapKeys(wm1).length, 0);
}
deadKeys();
+// The weakKeys table has to grow if it encounters enough new unmarked weakmap
+// keys. Trigger this to happen during weakmap marking.
+//
+// There's some trickiness involved in getting it to test the right thing,
+// because if a key is marked before the weakmap, then it won't get entered
+// into the weakKeys table. This chains through multiple weakmap layers to
+// ensure that the objects can't get marked before the weakmaps.
function weakKeysRealloc() {
var wm1 = new WeakMap;
+ var wm2 = new WeakMap;
+ var wm3 = new WeakMap;
var obj1 = {'name': 'obj1'};
- var wm2 = new WeakMap;
+ var obj2 = {'name': 'obj2'};
wm1.set(obj1, wm2);
-
+ wm2.set(obj2, wm3);
+ for (var i = 0; i < 10000; i++) {
+ wm3.set(Object.create(null), wm2);
+ }
+ wm3.set(Object.create(null), makeFinalizeObserver());
+ wm2 = undefined;
+ wm3 = undefined;
+ obj2 = undefined;
+
+ var initialCount = finalizeCount();
+ gc();
+ assertEq(finalizeCount(), initialCount + 1);
}