diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/jit-test/tests/asm.js/testFastHeapAccess.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/asm.js/testFastHeapAccess.js')
-rw-r--r-- | js/src/jit-test/tests/asm.js/testFastHeapAccess.js | 81 |
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 0000000000..09bd89693f --- /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); |