js/src/jit-test/tests/parallel/Array-reducePar-bail.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 load(libdir + "parallelarray-helpers.js");
michael@0 2
michael@0 3 // Tests that reduce saves its intermediate state correctly by
michael@0 4 // inducing a bailout in the middle of the reduction. This test may
michael@0 5 // fail to test what it is intended to test if the wrong number of
michael@0 6 // worker threads etc are present. It reproduced an existing bug when
michael@0 7 // used with 8 worker threads.
michael@0 8
michael@0 9 function testReduce() {
michael@0 10 var aCounter = 0;
michael@0 11 function sum(a, b) {
michael@0 12 var r = a + b;
michael@0 13 if (r == 234) // occurs once per slice
michael@0 14 aCounter++;
michael@0 15 return r;
michael@0 16 }
michael@0 17
michael@0 18 // We use a big array, to make sure that the test runs with 64 slices.
michael@0 19 var array = build(8 * 4096, function() { return 1; });
michael@0 20 var seqResult = array.reduce(sum);
michael@0 21 var seqCounter = aCounter;
michael@0 22
michael@0 23 aCounter = 0;
michael@0 24 var parResult = array.reducePar(sum);
michael@0 25 var parCounter = aCounter;
michael@0 26
michael@0 27 assertEq(true, parCounter >= seqCounter);
michael@0 28 assertStructuralEq(parResult, seqResult);
michael@0 29 }
michael@0 30
michael@0 31 if (getBuildConfiguration().parallelJS)
michael@0 32 testReduce();

mercurial