bug-1994871.js (1326B)
1 // Check that atom marking bitmap state and mark color is as expected and 2 // AtomMarkingRuntime::refineZoneBitmapsForCollectedZones works with gray 3 // symbols. 4 5 gczeal(0); 6 7 // We'll track the state of a symbol in two zones, |this| and |other|. 8 let s = Symbol(); 9 addMarkObservers([s]); 10 let other = newGlobal({newCompartment: true}); 11 12 // Iniitally we expect the symbol to be marked black in |this| and not marked 13 // in |other|. 14 gc(); 15 let index = getAtomMarkIndex(s); 16 assertEq(getAtomMarkColor(this, index), 'black'); 17 assertEq(getAtomMarkColor(other, index), 'white'); 18 assertEq(getMarks()[0], 'black'); 19 20 // Referencing the symbol in |other| marks it in that zone. 21 other.s = s; 22 assertEq(getAtomMarkColor(other, index), 'black'); 23 24 // Replace existing references with a gray reference from |this| and remove 25 // the reference from |other|. We now expect the mark color to be gray in 26 // *both* zones. 27 grayRoot().push(s); 28 other.s = undefined; 29 s = undefined; 30 gc(); 31 assertEq(getAtomMarkColor(this, index), 'gray'); 32 assertEq(getAtomMarkColor(other, index), 'gray'); 33 assertEq(getMarks()[0], 'gray'); 34 35 // Removing the final reference results in the mark color going to white. 36 grayRoot().length = 0; 37 gc(); 38 assertEq(getAtomMarkColor(this, index), 'white'); 39 assertEq(getAtomMarkColor(other, index), 'white'); 40 assertEq(getMarks()[0], 'dead');