diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/asm.js/testSIMD-bitcasts.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-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/testSIMD-bitcasts.js')
-rw-r--r-- | js/src/jit-test/tests/asm.js/testSIMD-bitcasts.js | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/asm.js/testSIMD-bitcasts.js b/js/src/jit-test/tests/asm.js/testSIMD-bitcasts.js new file mode 100644 index 000000000..c5a5fb2bc --- /dev/null +++ b/js/src/jit-test/tests/asm.js/testSIMD-bitcasts.js @@ -0,0 +1,84 @@ +load(libdir + "asm.js"); +load(libdir + "simd.js"); +load(libdir + "asserts.js"); + +// Set to true to see more JS debugging spew. +const DEBUG = false; + +if (!isSimdAvailable()) { + DEBUG && print("won't run tests as simd extensions aren't activated yet"); + quit(0); +} + +// Test all bit-casts and normal loads and stores. +var heap = new ArrayBuffer(BUF_MIN); +var asU8 = new Uint8Array(heap); +var allTypes = [ + "Int8x16", + "Int16x8", + "Int32x4", + "Uint8x16", + "Uint16x8", + "Uint32x4", + "Float32x4" +]; + +// Generate a load bit-cast store test function that performs: +// +// function f(a, b) { +// vec = src.load(H, a); +// cast = dst.fromĀ«srcĀ»Bits(vec); +// store(H, b, cast); +// } +// +// Here, `H` is the heap provided by `heap`. +function test_func(src, dst) { + text = ` + "use asm"; + var src = glob.SIMD.${src}; + var dst = glob.SIMD.${dst}; + var ld = src.load; + var st = dst.store; + var bc = dst.from${src}Bits; + + var H = new glob.Uint8Array(heap); + + function f(a, b) { + a = a|0; + b = b|0; + + st(H, b, bc(ld(H, a))); + } + + return f; + `; + return asmLink(asmCompile('glob', 'ffi', 'heap', text), this, null, heap); +} + +function assertBuf16(a, b) { + for (let i=0; i < 16; i++) { + assertEq(asU8[a+i], asU8[b+i]); + } +} + +for (let src of allTypes) { + for (let dst of allTypes) { + // Skip identity conversions. + if (src == dst) continue; + + print(src, dst); + let f = test_func(src, dst); + // Initialize with pseudo-random data. + for (let i = 0; i < 64; i++) { + asU8[i] = (i + 17) * 97; + } + + // Aligned load/store. + f(0, 16); + assertBuf16(0, 16); + + // Unaligned access. + f(1, 27); + assertBuf16(1, 27); + } +} |