tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

bug941877.js (3661B)


      1 load(libdir + "asm.js");
      2 
      3 function FunctionBody(f) {
      4    var str = f.toString();
      5    var firstBrace = str.indexOf('{');
      6    var lastBrace = str.lastIndexOf('}');
      7    return str.substr(firstBrace + 1, lastBrace - firstBrace - 1);
      8 }
      9 
     10 var F = (function (stdlib, n, heap) {
     11    var Int16ArrayView = new stdlib.Int16Array(heap);
     12    function f(i0, d1) {
     13        i0 = i0 | 0
     14        d1 = +d1
     15        var d2 = 1.
     16        var i3 = 0
     17        Int16ArrayView[0] = i0
     18        d2 = (.0 / .0)
     19        switch ((i0 + i0) | 0) {
     20            case 0:
     21                d2 = .0
     22                break
     23        };
     24        (((i3 - (0 < 0)) >>> ((.0 < -0) + (.0 > .0))) / 0) >> (0 + (((0 + 0) ^
     25 (9 > 0)) | 0))
     26    }
     27    return f;
     28 });
     29 
     30 var compiled = asmCompile('stdlib', 'n', 'heap', USE_ASM + FunctionBody(F));
     31 asmLink(compiled, this, null, new ArrayBuffer(BUF_MIN))();
     32 
     33 var F = (function(stdlib, n, heap) {
     34    var Float64ArrayView = new stdlib.Float64Array(heap)
     35    function f() {
     36        Float64ArrayView[0] = +(0xffffffff / 0xffffffff >> 0)
     37    }
     38    return f;
     39 });
     40 
     41 var compiled = asmCompile('stdlib', 'n', 'heap', USE_ASM + FunctionBody(F));
     42 asmLink(compiled, this, null, new ArrayBuffer(BUF_MIN))();
     43 
     44 function test0(x)
     45 {
     46   return (x >>> 0) % 10;
     47 }
     48 assertEq(test0(25), 5);
     49 assertEq(test0(24), 4);
     50 assertEq(test0(23), 3);
     51 assertEq(test0(0), 0);
     52 assertEq(test0(4294967295), 5);
     53 
     54 function test1(x)
     55 {
     56   return (x >>> 2) % 10;
     57 }
     58 assertEq(test1(25), 6);
     59 assertEq(test1(24), 6);
     60 assertEq(test1(23), 5);
     61 assertEq(test1(4294967295), 3);
     62 
     63 function test2(x, y)
     64 {
     65   return (x >>> 0) % (y >>> 0);
     66 }
     67 assertEq(test2(25, 3), 1);
     68 assertEq(test2(24, 4), 0);
     69 assertEq(test2(4294967295, 10), 5);
     70 assertEq(test2(23, 0), NaN);
     71 
     72 function test3()
     73 {
     74    function f(x, y)
     75    {
     76        x = x|0;
     77        y = y|0;
     78        var t = 0;
     79        t = (((x|0) % (y|0))|0) > -2;
     80        return t|0;
     81    }
     82    return f;
     83 }
     84 var compiled = asmCompile(USE_ASM + FunctionBody(test3));
     85 var linked = asmLink(compiled);
     86 assertEq(linked(4294967290, 4294967295), 1);
     87 assertEq(linked(4294967290, 4294967295), 1);
     88 
     89 function test4()
     90 {
     91    function f(x, y)
     92    {
     93        x = x|0;
     94        y = y|0;
     95        var t = 0;
     96        t = (((x>>>0) % (y>>>0)) >>> 0) > 0;
     97        return t|0;
     98    }
     99    return f;
    100 }
    101 var compiled = asmCompile(USE_ASM + FunctionBody(test4));
    102 var linked = asmLink(compiled);
    103 assertEq(linked(4294967290, 4294967295), 1);
    104 assertEq(linked(4294967290, 4294967295), 1);
    105 
    106 function test5()
    107 {
    108    function f(x, y)
    109    {
    110        x = x|0;
    111        y = y|0;
    112        var t = 0.;
    113        t = +(((x>>>0) % (y>>>0)) >>> 0) * 1.01;
    114        return +t;
    115    }
    116    return f;
    117 }
    118 var compiled = asmCompile(USE_ASM + FunctionBody(test5));
    119 var linked = asmLink(compiled);
    120 assertEq(linked(4294967290, 4294967295), 4337916962.9);
    121 assertEq(linked(4294967290, 4294967295), 4337916962.9);
    122 
    123 function test6()
    124 {
    125    function f(x, y)
    126    {
    127        x = x|0;
    128        y = y|0;
    129        return ((x>>>1) % (y>>>1))|0;
    130    }
    131    return f;
    132 }
    133 var compiled = asmCompile(USE_ASM + FunctionBody(test6));
    134 var linked = asmLink(compiled);
    135 assertEq(linked(23847, 7), 1);
    136 assertEq(linked(23848, 7), 2);
    137 
    138 function test7()
    139 {
    140    function f(x)
    141    {
    142        x = x|0;
    143        return ((x>>>0) / 8)|0;
    144    }
    145    return f;
    146 }
    147 var compiled = asmCompile(USE_ASM + FunctionBody(test7));
    148 var linked = asmLink(compiled);
    149 assertEq(linked(23847, 7), 2980);
    150 assertEq(linked(23848, 7), 2981);
    151 
    152 function test8()
    153 {
    154    function f(i,j)
    155    {
    156        i=i|0;j=j|0;
    157        return ((i>>>0)/(j>>>0))|0;
    158    }
    159    return f;
    160 }
    161 var compiled = asmCompile(USE_ASM + FunctionBody(test8));
    162 var linked = asmLink(compiled);
    163 assertEq(linked(2147483647, 0), 0);
    164 assertEq(linked(2147483646, 0), 0);