bug-1578462.js (1511B)
1 // |jit-test| skip-if: !hasFunction["gczeal"] 2 3 // Check that incoming CCW edges are marked gray in a zone GC if the 4 // source is gray. 5 6 // Set up a new compartment with a gray object wrapper to this 7 // compartment. 8 function createOtherCompartment() { 9 let t = {}; 10 addMarkObservers([t]); 11 let g = newGlobal({newCompartment: true}); 12 g.t = t; 13 g.eval(`grayRoot().push(t);`); 14 g.t = null; 15 t = null; 16 return g; 17 } 18 19 function startGCMarking() { 20 startgc(1); 21 while (gcstate() === "Prepare" || gcstate() === "MarkRoots") { 22 gcslice(1); 23 } 24 } 25 26 gczeal(0); 27 28 let g = createOtherCompartment(); 29 30 // The target should be gray in a full GC... 31 gc(); 32 assertEq(getMarks()[0], "gray"); 33 34 // and subsequently gray in a zone GC of only this compartment. 35 gc(this); 36 assertEq(getMarks()[0], "gray"); 37 38 // If a barrier marks the gray wrapper black after the start of the 39 // GC, the target ends up black. 40 schedulezone(this); 41 startGCMarking() 42 assertEq(getMarks()[0], "unmarked"); 43 g.eval(`grayRoot()`); // Barrier marks gray roots black. 44 assertEq(getMarks()[0], "black"); 45 finishgc(); 46 47 // A full collection resets the wrapper to gray. 48 gc(); 49 assertEq(getMarks()[0], "gray"); 50 51 // If a barrier marks the gray wrapper black after the target has 52 // already been marked gray, the target ends up black. 53 gczeal(25); // Yield during gray marking. 54 schedulezone(this); 55 startGCMarking(); 56 assertEq(getMarks()[0], "gray"); 57 g.eval(`grayRoot()`); // Barrier marks gray roots black. 58 assertEq(getMarks()[0], "black"); 59 finishgc();