bug-1579025.js (1205B)
1 // Test that a zone GC collects the selected zones. 2 3 function waitForState(state) { 4 while (gcstate() !== state && gcstate() !== "NotActive") { 5 gcslice(100); 6 } 7 } 8 9 gczeal(0); 10 gc(); 11 12 let z1 = this; 13 let z2 = newGlobal({newCompartment: true}); 14 15 // Initially nothing is being collected. 16 17 assertEq(gcstate(), "NotActive"); 18 assertEq(gcstate(z1), "NoGC"); 19 assertEq(gcstate(z2), "NoGC"); 20 21 // No zones selected => full GC. 22 23 startgc(1); 24 25 // It's non-deterministic whether we see the prepare state or not. 26 waitForState("Mark"); 27 28 assertEq(gcstate(), "Mark"); 29 assertEq(gcstate(z1), "MarkBlackOnly"); 30 assertEq(gcstate(z2), "MarkBlackOnly"); 31 finishgc(); 32 33 // Use of schedulezone() => zone GC. 34 35 schedulezone(z1); 36 startgc(1); 37 waitForState("Mark"); 38 assertEq(gcstate(), "Mark"); 39 assertEq(gcstate(z1), "MarkBlackOnly"); 40 assertEq(gcstate(z2), "NoGC"); 41 finishgc(); 42 43 schedulezone(z2); 44 startgc(1); 45 waitForState("Mark"); 46 assertEq(gcstate(), "Mark"); 47 assertEq(gcstate(z1), "NoGC"); 48 assertEq(gcstate(z2), "MarkBlackOnly"); 49 finishgc(); 50 51 schedulezone(z1); 52 schedulezone(z2); 53 startgc(1); 54 waitForState("Mark"); 55 assertEq(gcstate(), "Mark"); 56 assertEq(gcstate(z1), "MarkBlackOnly"); 57 assertEq(gcstate(z2), "MarkBlackOnly"); 58 finishgc();