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