summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/asm.js/testFastHeapAccess.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/asm.js/testFastHeapAccess.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/asm.js/testFastHeapAccess.js')
-rw-r--r--js/src/jit-test/tests/asm.js/testFastHeapAccess.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/asm.js/testFastHeapAccess.js b/js/src/jit-test/tests/asm.js/testFastHeapAccess.js
new file mode 100644
index 000000000..09bd89693
--- /dev/null
+++ b/js/src/jit-test/tests/asm.js/testFastHeapAccess.js
@@ -0,0 +1,81 @@
+load(libdir + "asm.js");
+
+var code = asmCompile('glob', 'imp', 'b', USE_ASM + HEAP_IMPORTS + 'function f(i,j) {i=i|0;j=j|0; u32[((i<<2)+32 & 0xffff)>>2] = j } return f');
+var f = asmLink(code, this, null, BUF_64KB);
+for (var i = 0; i < 100; i++)
+ f(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) {i=i|0; return u32[((i<<2)+32 & 0xffff)>>2]|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; u32[(i<<2 & 0xffff)>>2] = j } return f');
+var f = asmLink(code, this, null, BUF_64KB);
+for (var i = 0; i < 100; i++)
+ f(i, 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');
+var f = asmLink(code, this, null, BUF_64KB);
+for (var i = 0; i < 100; i++)
+ assertEq(f(32, 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))|0) + 16 & 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+4], 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))|0) + 16 & 0xffff) >> 2]|0 } return f');
+var f = asmLink(code, this, null, BUF_64KB);
+for (var i = 0; i < 100; i++)
+ assertEq(f(32, 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) + (i32[(((i+(j<<2))|0)+4&0xffff)>>2]|0))|0 } return f');
+var f = asmLink(code, this, null, BUF_64KB);
+var i32 = new Uint32Array(BUF_64KB);
+i32[11] = 3;
+i32[12] = 97;
+assertEq(f(12,8), 100);