js/src/jit-test/tests/parallel/bug977853-convert-doubles.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Bug 977853 -- Pared down version of script exhibiting negative
     2 // interaction with convert to doubles optimization. See bug for gory
     3 // details.
     5 if (!getBuildConfiguration().parallelJS)
     6   quit();
     8 load(libdir + "parallelarray-helpers.js")
    10 var numIters = 5;
    11 var golden_output;
    13 function PJS_div4(v, s)
    14 {
    15   return [ v[0]/s, v[1]/s, v[2]/s, v[3]/s ];
    16 }
    18 function PJS_normalized(v)
    19 {
    20   var d = Math.sqrt(v[0] * v[0] + v[1] * v[1] + v[2] * v[2]);
    21   d = d > 0.0 ? d : 1.0;
    22   var result = [ v[0]/d, v[1]/d, v[2]/d, 1.0 ];
    23   return result;
    24 }
    26 // This is the elemental function passed to mapPar
    27 function PJS_displace(p)
    28 {
    29   var position = [p[0], p[1], p[2], 1.0];
    30   var normal = position;
    31   var roughness = 0.025 / 0.35;
    32   normal = PJS_normalized(PJS_div4(normal, roughness));
    33   return null;
    34 }
    35 var NUM_VERTEX_COMPONENTS = 3;
    36 var initPos, nVertices;
    37 var userData = {
    38   nVertices : 25, //2880,
    39   initPos : [],
    40 };
    41 function setup() {
    42   for(var k = 0; k < NUM_VERTEX_COMPONENTS*userData.nVertices; k++) {
    43     userData.initPos[k] = k/1000;
    44   }
    45   nVertices	= userData.nVertices;
    46   initPos		= new Array(nVertices);
    47   for(var i=0, j=0; i<nVertices; i++, j+=NUM_VERTEX_COMPONENTS) {
    48 	initPos[i] = [userData.initPos[j],
    49 				  userData.initPos[j+1],
    50 				  userData.initPos[j+2]];
    51   }
    52 }
    53 function SimulatePJS() {
    54   var curPosAndNor;
    56   // Measure Parallel Execution
    57   assertParallelExecSucceeds(
    58     function(m) { return initPos.mapPar(PJS_displace, m); },
    59     function() { });
    60 }
    61 var start_time, elapsed_parallel = 0, elapsed_sequential = 0;
    62 setup();
    63 SimulatePJS();

mercurial