Bug 1148232 - OdinMonkey: Update tests to avoid using legacy syntax. r=luke
authorDan Gohman <sunfish@mozilla.com>
Fri, 27 Mar 2015 10:15:21 -0700
changeset 236259 f41fff953bf1d05c0f3696081f0ec92ccd4c8aa4
parent 236258 768fcbee6319132f1bab327baf9e3371e4bc45ca
child 236260 da24bccfcaf00f48abcccd0c3ce0fd196dfcc056
push id28494
push userphilringnalda@gmail.com
push dateSat, 28 Mar 2015 18:46:06 +0000
treeherdermozilla-central@e16dc56f90d5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs1148232
milestone39.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 1148232 - OdinMonkey: Update tests to avoid using legacy syntax. r=luke
js/src/asmjs/AsmJSValidate.cpp
js/src/jit-test/tests/asm.js/testFastHeapAccess.js
js/src/jit-test/tests/asm.js/testHeapAccess.js
--- a/js/src/asmjs/AsmJSValidate.cpp
+++ b/js/src/asmjs/AsmJSValidate.cpp
@@ -4519,16 +4519,17 @@ CheckArrayAccess(FunctionCompiler &f, Pa
         if (!CheckExpr(f, pointerNode, &pointerDef, &pointerType))
             return false;
 
         f.leaveHeapExpression();
 
         if (!pointerType.isIntish())
             return f.failf(indexExpr, "%s is not a subtype of int", pointerType.toChars());
     } else {
+        // For legacy compatibility, accept Int8/Uint8 accesses with no shift.
         if (TypedArrayShift(*viewType) != 0)
             return f.fail(indexExpr, "index expression isn't shifted; must be an Int8/Uint8 access");
 
         MOZ_ASSERT(mask == -1);
         bool folded = false;
 
         if (indexExpr->isKind(PNK_BITAND))
             folded = FoldMaskedArrayIndex(f, &indexExpr, &mask, needsBoundsCheck);
--- a/js/src/jit-test/tests/asm.js/testFastHeapAccess.js
+++ b/js/src/jit-test/tests/asm.js/testFastHeapAccess.js
@@ -20,28 +20,41 @@ for (var i = 0; i < 100; i++)
 var u32 = new Uint32Array(BUF_64KB);
 for (var i = 0; i < 100; i++)
     assertEq(u32[i], i);
 var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; return u32[(i<<2 & 0xffff)>>2]|0 } return f');
 var f = asmLink(code, this, null, BUF_64KB);
 for (var i = 0; i < 100; i++)
     assertEq(f(i), i);
 
+// For legacy compatibility, test Int8/Uint8 accesses with no shift.
 var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=j|0; u8[i+20 & 0xffff] = j } return f');
 var f = asmLink(code, this, null, BUF_64KB);
 for (var i = 0; i < 100; i++)
     f(i, i);
 var u8 = new Uint8Array(BUF_64KB);
 for (var i = 0; i < 100; i++)
     assertEq(u8[i+20], i);
 var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; return u8[i+20 & 0xffff]|0 } return f');
 var f = asmLink(code, this, null, BUF_64KB);
 for (var i = 0; i < 100; i++)
     assertEq(f(i), i);
 
+var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=j|0; u8[(i+20 & 0xffff)>>0] = j } return f');
+var f = asmLink(code, this, null, BUF_64KB);
+for (var i = 0; i < 100; i++)
+    f(i, i);
+var u8 = new Uint8Array(BUF_64KB);
+for (var i = 0; i < 100; i++)
+    assertEq(u8[i+20], i);
+var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; return u8[(i+20 & 0xffff)>>0]|0 } return f');
+var f = asmLink(code, this, null, BUF_64KB);
+for (var i = 0; i < 100; i++)
+    assertEq(f(i), i);
+
 var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j,k) {i=i|0;j=j|0;k=k|0; i32[(i + (j<<2) & 0xffff) >> 2] = k } return f');
 var f = asmLink(code, this, null, BUF_64KB);
 for (var i = 0; i < 100; i++)
     f(32, i, i);
 var u32 = new Uint32Array(BUF_64KB);
 for (var i = 0; i < 100; i++)
     assertEq(u32[8+i], i);
 var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=j|0; return i32[(i + (j<<2) & 0xffff) >> 2]|0 } return f');
--- a/js/src/jit-test/tests/asm.js/testHeapAccess.js
+++ b/js/src/jit-test/tests/asm.js/testHeapAccess.js
@@ -168,20 +168,25 @@ assertEq(f(3), 0xfffeeee);
 
 var f = asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; return i32[(i<<2)>>2]|0 }; return f'), this, null, i32.buffer);
 assertEq(f(0), 13);
 assertEq(f(1), 0xfffeeee);
 
 var f = asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) {i=i|0; return i32[((i<<2)+4)>>2]|0 }; return f'), this, null, i32.buffer);
 assertEq(f(0), 0xfffeeee);
 
+// For legacy compatibility, test Int8/Uint8 accesses with no shift.
 asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[7&0xffff] = 41 } return f'), this, null, BUF_64KB)();
 assertEq(new Uint8Array(BUF_64KB)[7], 41);
 asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[7&0xffff] = -41 } return f'), this, null, BUF_64KB)();
 assertEq(new Int8Array(BUF_64KB)[7], -41);
+asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u8[(7&0xffff)>>0] = 41 } return f'), this, null, BUF_64KB)();
+assertEq(new Uint8Array(BUF_64KB)[7], 41);
+asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i8[(7&0xffff)>>0] = -41 } return f'), this, null, BUF_64KB)();
+assertEq(new Int8Array(BUF_64KB)[7], -41);
 asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u16[(6&0xffff)>>1] = 0xabc } return f'), this, null, BUF_64KB)();
 assertEq(new Uint16Array(BUF_64KB)[3], 0xabc);
 asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i16[(6&0xffff)>>1] = -0xabc } return f'), this, null, BUF_64KB)();
 assertEq(new Int16Array(BUF_64KB)[3], -0xabc);
 asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { u32[(4&0xffff)>>2] = 0xabcde } return f'), this, null, BUF_64KB)();
 assertEq(new Uint32Array(BUF_64KB)[1], 0xabcde);
 asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { i32[(4&0xffff)>>2] = -0xabcde } return f'), this, null, BUF_64KB)();
 assertEq(new Int32Array(BUF_64KB)[1], -0xabcde);
@@ -192,17 +197,19 @@ assertEq(new Float64Array(BUF_64KB)[1], 
 
 new Float32Array(BUF_64KB)[1] = 1.0;
 assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f32[(4&0xffff)>>2] } return f'), this, null, BUF_64KB)(), 1.0);
 assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'var toFloat32 = glob.Math.fround; function f() { return toFloat32(f32[(4&0xffff)>>2]) } return f'), this, null, BUF_64KB)(), 1.0);
 new Float64Array(BUF_64KB)[1] = 1.3;
 assertEq(asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f() { return +f64[(8&0xffff)>>3] } return f'), this, null, BUF_64KB)(), 1.3);
 
 asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u8[255]; u8[i] } return f');
+// For legacy compatibility, test Int8/Uint8 accesses with no shift.
 asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u8[i&0xff]; u8[255] } return f');
+asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u8[(i&0xff)>>0]; u8[255] } return f');
 asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u32[63]; u32[i>>2] } return f');
 asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u32[i>>2]; u32[63] } return f');
 
 var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u32[64] } return f');
 asmLink(code, this, null, new ArrayBuffer(BUF_MIN));
 
 asmLink(asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i) { i=i|0; u32[12] = i } return f'), this, null, BUF_64KB)(11);
 assertEq(new Int32Array(BUF_64KB)[12], 11);