Bug 1016951: Fix asm.js/bug941877.js test so that it contains valid asm.js code; r=sunfish
authorBenjamin Bouvier <benj@benj.me>
Mon, 02 Jun 2014 18:03:10 +0200
changeset 205403 e808372ebbd4710c0603d4fb185494822859e381
parent 205402 61567a7e3d66c4b6b7f3fffe309bf01d03e3cf69
child 205404 2766dd9e3873aefc05fed6219474d2ae41b571e6
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssunfish
bugs1016951, 941877
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1016951: Fix asm.js/bug941877.js test so that it contains valid asm.js code; r=sunfish
js/src/jit-test/tests/asm.js/bug941877.js
--- a/js/src/jit-test/tests/asm.js/bug941877.js
+++ b/js/src/jit-test/tests/asm.js/bug941877.js
@@ -1,35 +1,50 @@
-(function(stdlib, n, heap) {
-    "use asm"
+load(libdir + "asm.js");
+
+function FunctionBody(f) {
+    var str = f.toString();
+    var firstBrace = str.indexOf('{');
+    var lastBrace = str.lastIndexOf('}');
+    return str.substr(firstBrace + 1, lastBrace - firstBrace - 1);
+}
+
+var F = (function (stdlib, n, heap) {
     var Int16ArrayView = new stdlib.Int16Array(heap);
     function f(i0, d1) {
         i0 = i0 | 0
         d1 = +d1
         var d2 = 1.
         var i3 = 0
         Int16ArrayView[0] = i0
         d2 = (.0 / .0)
         switch ((i0 + i0) | 0) {
             case 0:
                 d2 = .0
                 break
         };
         (((i3 - (0 < 0)) >>> ((.0 < -0) + (.0 > .0))) / 0) >> (0 + (((0 + 0) ^
 (9 > 0)) | 0))
     }
-})(this, null, new ArrayBuffer(4096));
+    return f;
+});
 
-(function(stdlib, n, heap) {
-    "use asm"
+var compiled = asmCompile('stdlib', 'n', 'heap', USE_ASM + FunctionBody(F));
+asmLink(compiled, this, null, new ArrayBuffer(4096))();
+
+var F = (function(stdlib, n, heap) {
     var Float64ArrayView = new stdlib.Float64Array(heap)
     function f() {
         Float64ArrayView[0] = +(0xffffffff / 0xffffffff >> 0)
     }
-})(this, null, new ArrayBuffer(4096));
+    return f;
+});
+
+var compiled = asmCompile('stdlib', 'n', 'heap', USE_ASM + FunctionBody(F));
+asmLink(compiled, this, null, new ArrayBuffer(4096))();
 
 function test0(x)
 {
    return (x >>> 0) % 10;
 }
 assertEq(test0(25), 5);
 assertEq(test0(24), 4);
 assertEq(test0(23), 3);
@@ -51,93 +66,99 @@ function test2(x, y)
 }
 assertEq(test2(25, 3), 1);
 assertEq(test2(24, 4), 0);
 assertEq(test2(4294967295, 10), 5);
 assertEq(test2(23, 0), NaN);
 
 function test3()
 {
-    "use asm";
     function f(x, y)
     {
         x = x|0;
         y = y|0;
         var t = 0;
-        t = (x % y) > -2;
+        t = (((x|0) % (y|0))|0) > -2;
         return t|0;
     }
     return f;
 }
-assertEq(test3()(4294967290, 4294967295), 1);
-assertEq(test3()(4294967290, 4294967295), 1);
+var compiled = asmCompile(USE_ASM + FunctionBody(test3));
+var linked = asmLink(compiled);
+assertEq(linked(4294967290, 4294967295), 1);
+assertEq(linked(4294967290, 4294967295), 1);
 
 function test4()
 {
-    "use asm";
     function f(x, y)
     {
         x = x|0;
         y = y|0;
         var t = 0;
-        t = ((x>>>0) % (y>>>0)) > -2;
+        t = (((x>>>0) % (y>>>0)) >>> 0) > 0;
         return t|0;
     }
     return f;
 }
-assertEq(test4()(4294967290, 4294967295), 1);
-assertEq(test4()(4294967290, 4294967295), 1);
+var compiled = asmCompile(USE_ASM + FunctionBody(test4));
+var linked = asmLink(compiled);
+assertEq(linked(4294967290, 4294967295), 1);
+assertEq(linked(4294967290, 4294967295), 1);
 
 function test5()
 {
-    "use asm";
     function f(x, y)
     {
         x = x|0;
         y = y|0;
-        var t = 0;
-        t = ((x>>>0) % (y>>>0)) * 1.01;
+        var t = 0.;
+        t = +(((x>>>0) % (y>>>0)) >>> 0) * 1.01;
         return +t;
     }
     return f;
 }
-assertEq(test5()(4294967290, 4294967295), 4337916962.9);
-assertEq(test5()(4294967290, 4294967295), 4337916962.9);
+var compiled = asmCompile(USE_ASM + FunctionBody(test5));
+var linked = asmLink(compiled);
+assertEq(linked(4294967290, 4294967295), 4337916962.9);
+assertEq(linked(4294967290, 4294967295), 4337916962.9);
 
 function test6()
 {
-    "use asm";
     function f(x, y)
     {
         x = x|0;
         y = y|0;
         return ((x>>>1) % (y>>>1))|0;
     }
     return f;
 }
-assertEq(test6()(23847, 7), 1);
-assertEq(test6()(23848, 7), 2);
+var compiled = asmCompile(USE_ASM + FunctionBody(test6));
+var linked = asmLink(compiled);
+assertEq(linked(23847, 7), 1);
+assertEq(linked(23848, 7), 2);
 
 function test7()
 {
-    "use asm";
     function f(x)
     {
         x = x|0;
         return ((x>>>0) / 8)|0;
     }
     return f;
 }
-assertEq(test7()(23847, 7), 2980);
-assertEq(test7()(23848, 7), 2981);
+var compiled = asmCompile(USE_ASM + FunctionBody(test7));
+var linked = asmLink(compiled);
+assertEq(linked(23847, 7), 2980);
+assertEq(linked(23848, 7), 2981);
 
 function test8()
 {
-    "use asm";
     function f(i,j)
     {
         i=i|0;j=j|0;
         return ((i>>>0)/(j>>>0))|0;
     }
     return f;
 }
-assertEq(test8()(2147483647, 0), 0);
-assertEq(test8()(2147483646, 0), 0);
+var compiled = asmCompile(USE_ASM + FunctionBody(test8));
+var linked = asmLink(compiled);
+assertEq(linked(2147483647, 0), 0);
+assertEq(linked(2147483646, 0), 0);