Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | * Test expected state changes during collection. |
michael@0 | 3 | */ |
michael@0 | 4 | |
michael@0 | 5 | if ("gcstate" in this) { |
michael@0 | 6 | assertEq(gcstate(), "none"); |
michael@0 | 7 | |
michael@0 | 8 | /* Non-incremental GC. */ |
michael@0 | 9 | gc(); |
michael@0 | 10 | assertEq(gcstate(), "none"); |
michael@0 | 11 | |
michael@0 | 12 | /* Incremental GC in one slice. */ |
michael@0 | 13 | gcslice(1000000); |
michael@0 | 14 | assertEq(gcstate(), "none"); |
michael@0 | 15 | |
michael@0 | 16 | /* |
michael@0 | 17 | * Incremental GC in multiple slices: if marking takes more than one slice, |
michael@0 | 18 | * we yield before we start sweeping. |
michael@0 | 19 | */ |
michael@0 | 20 | gcslice(1); |
michael@0 | 21 | assertEq(gcstate(), "mark"); |
michael@0 | 22 | gcslice(1000000); |
michael@0 | 23 | assertEq(gcstate(), "mark"); |
michael@0 | 24 | gcslice(1000000); |
michael@0 | 25 | assertEq(gcstate(), "none"); |
michael@0 | 26 | |
michael@0 | 27 | /* Zeal mode 8: Incremental GC in two slices: 1) mark roots 2) finish collection. */ |
michael@0 | 28 | gczeal(8); |
michael@0 | 29 | gcslice(1); |
michael@0 | 30 | assertEq(gcstate(), "mark"); |
michael@0 | 31 | gcslice(1); |
michael@0 | 32 | assertEq(gcstate(), "none"); |
michael@0 | 33 | |
michael@0 | 34 | /* Zeal mode 9: Incremental GC in two slices: 1) mark all 2) new marking and finish. */ |
michael@0 | 35 | gczeal(9); |
michael@0 | 36 | gcslice(1); |
michael@0 | 37 | assertEq(gcstate(), "mark"); |
michael@0 | 38 | gcslice(1); |
michael@0 | 39 | assertEq(gcstate(), "none"); |
michael@0 | 40 | |
michael@0 | 41 | /* Zeal mode 10: Incremental GC in multiple slices (always yeilds before sweeping). */ |
michael@0 | 42 | gczeal(10); |
michael@0 | 43 | gcslice(1000000); |
michael@0 | 44 | assertEq(gcstate(), "sweep"); |
michael@0 | 45 | gcslice(1000000); |
michael@0 | 46 | assertEq(gcstate(), "none"); |
michael@0 | 47 | } |