weakmap-nursery-value.js (1041B)
1 // Bug 1715471 2 3 // This test relies on triggering GC at precise points. GC zeal modes 4 // interfere with this. 5 gczeal(0); 6 7 // This test requires enqueueMark, which is only available in a debugging 8 // build. 9 if (!this.enqueueMark) quit(0); 10 11 var wm = new WeakMap(); 12 13 // Force materialization of the map struct. Otherwise it would be allocated 14 // black during the incremental GC when we do wm.set. 15 wm.set({}, {}); 16 17 var tenuredKey = Object.create(null); 18 gc(); // Tenure the WeakMap and key. 19 20 // Enter the GC, since otherwise the minor GC at the beginning would tenure our 21 // value before it had a chance to be entered into the ephemeron edge list. 22 startgc(1); 23 while (gcstate() === "Prepare") gcslice(1); 24 25 // Create a WeakMap entry with a value in the nursery. 26 var nurseryValue = Object.create(null); 27 wm.set(tenuredKey, nurseryValue); 28 29 // We want to mark the weakmap first, before the key or value are marked, so 30 // that the tenuredKey -> nurseryValue edge will be added to the ephemeron edge 31 // table. 32 enqueueMark(wm); 33 34 gcslice(1000); 35 minorgc();