michael@0: // |jit-test| slow; michael@0: load(libdir + "parallelarray-helpers.js"); michael@0: michael@0: // The MathCache has 4096 entries, so ensure we overwrite at least one michael@0: // entry by using > 4096 distinct inputs. michael@0: michael@0: var len = 5000; michael@0: var iters = 100; michael@0: michael@0: // The problem we are trying to expose (Bugzilla 901000) is michael@0: // a data-race on the MathCache; such a bug is inherently michael@0: // non-deterministic. On a 4 core Mac laptop: michael@0: // michael@0: // len == 10000 iters==1 replicates the problem on 2/10 runs, michael@0: // len == 10000 iters==2 replicates the problem on 3/10 runs, michael@0: // len == 10000 iters==5 replicates the problem on 6/10 runs, michael@0: // len == 10000 iters==10 replicates the problem on 9/10 runs. michael@0: // michael@0: // len == 5000 iters==1 replicates the problem on 1/10 runs, michael@0: // len == 5000 iters==2 replicates the problem on 4/10 runs, michael@0: // len == 5000 iters==5 replicates the problem on 5/10 runs, michael@0: // len == 5000 iters==10 replicates the problem on 9/10 runs. michael@0: // michael@0: // len == 2000 iters==1 replicates the problem on 0/10 runs, michael@0: // len == 2000 iters==2 replicates the problem on 0/10 runs, michael@0: // len == 2000 iters==5 replicates the problem on 0/10 runs, michael@0: // len == 2000 iters==10 replicates the problem on 3/10 runs michael@0: michael@0: function check(fill) { michael@0: var seq = Array.build(len, fill); michael@0: for (var i = 0; i < iters; i++) { michael@0: var par = Array.buildPar(len, fill); michael@0: assertStructuralEq(par, seq); michael@0: } michael@0: } michael@0: michael@0: function checkAbs(a) { check(function (i) { return Math.abs(a[i]); }); } michael@0: function checkAcos(a) { check(function (i) { return Math.acos(a[i]); }); } michael@0: function checkAsin(a) { check(function (i) { return Math.asin(a[i]); }); } michael@0: function checkAtan(a) { check(function (i) { return Math.atan(a[i]); }); } michael@0: function checkAtan2(a) { check(function (i) { return Math.atan2(a[i]); }); } michael@0: function checkCeil(a) { check(function (i) { return Math.ceil(a[i]); }); } michael@0: function checkCos(a) { check(function (i) { return Math.cos(a[i]); }); } michael@0: function checkExp(a) { check(function (i) { return Math.exp(a[i]); }); } michael@0: function checkFloor(a) { check(function (i) { return Math.floor(a[i]); }); } michael@0: function checkLog(a) { check(function (i) { return Math.log(a[i]); }); } michael@0: function checkRound(a) { check(function (i) { return Math.round(a[i]); }); } michael@0: function checkSin(a) { check(function (i) { return Math.sin(a[i]); }); } michael@0: function checkSqrt(a) { check(function (i) { return Math.sqrt(a[i]); }); } michael@0: function checkTan(a) { check(function (i) { return Math.tan(a[i]); }); } michael@0: michael@0: function callVariousUnaryMathFunctions() { michael@0: // We might want to consider making this test adopt seedrandom.js michael@0: // and call Math.seedrandom("seed") here ... michael@0: // function fill(i) { return (2*Math.random())-1; } michael@0: // function fill(i) { return (20*Math.random())-10; } michael@0: // michael@0: // ... but its easiest to just drop the pseudo-random input entirely. michael@0: function fill(i) { return 10/i; } michael@0: var input = Array.build(len, fill); michael@0: michael@0: checkAbs(input); //print("abs"); michael@0: checkAcos(input); //print("acos"); michael@0: checkAsin(input); //print("asin"); michael@0: checkAtan(input); //print("atan"); michael@0: michael@0: checkAtan2(input); //print("atan2"); michael@0: checkCeil(input); //print("ceil"); michael@0: checkCos(input); //print("cos"); michael@0: checkExp(input); //print("exp"); michael@0: michael@0: checkFloor(input); //print("floor"); michael@0: checkLog(input); //print("log"); michael@0: checkRound(input); //print("round"); michael@0: checkSin(input); //print("sin"); michael@0: michael@0: checkSqrt(input); //print("sqrt"); michael@0: checkTan(input); //print("tan"); michael@0: } michael@0: michael@0: if (getBuildConfiguration().parallelJS) michael@0: callVariousUnaryMathFunctions();