1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit-test/tests/parallel/Array-reducePar-bail.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,32 @@ 1.4 +load(libdir + "parallelarray-helpers.js"); 1.5 + 1.6 +// Tests that reduce saves its intermediate state correctly by 1.7 +// inducing a bailout in the middle of the reduction. This test may 1.8 +// fail to test what it is intended to test if the wrong number of 1.9 +// worker threads etc are present. It reproduced an existing bug when 1.10 +// used with 8 worker threads. 1.11 + 1.12 +function testReduce() { 1.13 + var aCounter = 0; 1.14 + function sum(a, b) { 1.15 + var r = a + b; 1.16 + if (r == 234) // occurs once per slice 1.17 + aCounter++; 1.18 + return r; 1.19 + } 1.20 + 1.21 + // We use a big array, to make sure that the test runs with 64 slices. 1.22 + var array = build(8 * 4096, function() { return 1; }); 1.23 + var seqResult = array.reduce(sum); 1.24 + var seqCounter = aCounter; 1.25 + 1.26 + aCounter = 0; 1.27 + var parResult = array.reducePar(sum); 1.28 + var parCounter = aCounter; 1.29 + 1.30 + assertEq(true, parCounter >= seqCounter); 1.31 + assertStructuralEq(parResult, seqResult); 1.32 +} 1.33 + 1.34 +if (getBuildConfiguration().parallelJS) 1.35 + testReduce();