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 | // |jit-test| slow; |
michael@0 | 2 | load(libdir + "parallelarray-helpers.js"); |
michael@0 | 3 | |
michael@0 | 4 | // The MathCache has 4096 entries, so ensure we overwrite at least one |
michael@0 | 5 | // entry by using > 4096 distinct inputs. |
michael@0 | 6 | |
michael@0 | 7 | var len = 5000; |
michael@0 | 8 | var iters = 100; |
michael@0 | 9 | |
michael@0 | 10 | // The problem we are trying to expose (Bugzilla 901000) is |
michael@0 | 11 | // a data-race on the MathCache; such a bug is inherently |
michael@0 | 12 | // non-deterministic. On a 4 core Mac laptop: |
michael@0 | 13 | // |
michael@0 | 14 | // len == 10000 iters==1 replicates the problem on 2/10 runs, |
michael@0 | 15 | // len == 10000 iters==2 replicates the problem on 3/10 runs, |
michael@0 | 16 | // len == 10000 iters==5 replicates the problem on 6/10 runs, |
michael@0 | 17 | // len == 10000 iters==10 replicates the problem on 9/10 runs. |
michael@0 | 18 | // |
michael@0 | 19 | // len == 5000 iters==1 replicates the problem on 1/10 runs, |
michael@0 | 20 | // len == 5000 iters==2 replicates the problem on 4/10 runs, |
michael@0 | 21 | // len == 5000 iters==5 replicates the problem on 5/10 runs, |
michael@0 | 22 | // len == 5000 iters==10 replicates the problem on 9/10 runs. |
michael@0 | 23 | // |
michael@0 | 24 | // len == 2000 iters==1 replicates the problem on 0/10 runs, |
michael@0 | 25 | // len == 2000 iters==2 replicates the problem on 0/10 runs, |
michael@0 | 26 | // len == 2000 iters==5 replicates the problem on 0/10 runs, |
michael@0 | 27 | // len == 2000 iters==10 replicates the problem on 3/10 runs |
michael@0 | 28 | |
michael@0 | 29 | function check(fill) { |
michael@0 | 30 | var seq = Array.build(len, fill); |
michael@0 | 31 | for (var i = 0; i < iters; i++) { |
michael@0 | 32 | var par = Array.buildPar(len, fill); |
michael@0 | 33 | assertStructuralEq(par, seq); |
michael@0 | 34 | } |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | function checkAbs(a) { check(function (i) { return Math.abs(a[i]); }); } |
michael@0 | 38 | function checkAcos(a) { check(function (i) { return Math.acos(a[i]); }); } |
michael@0 | 39 | function checkAsin(a) { check(function (i) { return Math.asin(a[i]); }); } |
michael@0 | 40 | function checkAtan(a) { check(function (i) { return Math.atan(a[i]); }); } |
michael@0 | 41 | function checkAtan2(a) { check(function (i) { return Math.atan2(a[i]); }); } |
michael@0 | 42 | function checkCeil(a) { check(function (i) { return Math.ceil(a[i]); }); } |
michael@0 | 43 | function checkCos(a) { check(function (i) { return Math.cos(a[i]); }); } |
michael@0 | 44 | function checkExp(a) { check(function (i) { return Math.exp(a[i]); }); } |
michael@0 | 45 | function checkFloor(a) { check(function (i) { return Math.floor(a[i]); }); } |
michael@0 | 46 | function checkLog(a) { check(function (i) { return Math.log(a[i]); }); } |
michael@0 | 47 | function checkRound(a) { check(function (i) { return Math.round(a[i]); }); } |
michael@0 | 48 | function checkSin(a) { check(function (i) { return Math.sin(a[i]); }); } |
michael@0 | 49 | function checkSqrt(a) { check(function (i) { return Math.sqrt(a[i]); }); } |
michael@0 | 50 | function checkTan(a) { check(function (i) { return Math.tan(a[i]); }); } |
michael@0 | 51 | |
michael@0 | 52 | function callVariousUnaryMathFunctions() { |
michael@0 | 53 | // We might want to consider making this test adopt seedrandom.js |
michael@0 | 54 | // and call Math.seedrandom("seed") here ... |
michael@0 | 55 | // function fill(i) { return (2*Math.random())-1; } |
michael@0 | 56 | // function fill(i) { return (20*Math.random())-10; } |
michael@0 | 57 | // |
michael@0 | 58 | // ... but its easiest to just drop the pseudo-random input entirely. |
michael@0 | 59 | function fill(i) { return 10/i; } |
michael@0 | 60 | var input = Array.build(len, fill); |
michael@0 | 61 | |
michael@0 | 62 | checkAbs(input); //print("abs"); |
michael@0 | 63 | checkAcos(input); //print("acos"); |
michael@0 | 64 | checkAsin(input); //print("asin"); |
michael@0 | 65 | checkAtan(input); //print("atan"); |
michael@0 | 66 | |
michael@0 | 67 | checkAtan2(input); //print("atan2"); |
michael@0 | 68 | checkCeil(input); //print("ceil"); |
michael@0 | 69 | checkCos(input); //print("cos"); |
michael@0 | 70 | checkExp(input); //print("exp"); |
michael@0 | 71 | |
michael@0 | 72 | checkFloor(input); //print("floor"); |
michael@0 | 73 | checkLog(input); //print("log"); |
michael@0 | 74 | checkRound(input); //print("round"); |
michael@0 | 75 | checkSin(input); //print("sin"); |
michael@0 | 76 | |
michael@0 | 77 | checkSqrt(input); //print("sqrt"); |
michael@0 | 78 | checkTan(input); //print("tan"); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | if (getBuildConfiguration().parallelJS) |
michael@0 | 82 | callVariousUnaryMathFunctions(); |