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/testCloning.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/testCloning.js')
-rw-r--r-- | js/src/jit-test/tests/asm.js/testCloning.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/asm.js/testCloning.js b/js/src/jit-test/tests/asm.js/testCloning.js new file mode 100644 index 000000000..e84f34303 --- /dev/null +++ b/js/src/jit-test/tests/asm.js/testCloning.js @@ -0,0 +1,50 @@ +load(libdir + "asm.js"); + +setCachingEnabled(true); + +var code = asmCompile(USE_ASM + "function g() { return 42 } return g"); +assertEq(asmLink(code)(), 42); +assertEq(asmLink(code)(), 42); + +var code = evaluate("(function() { " + USE_ASM + " function g() { return 43 } return g})", {fileName: null}); +assertEq(asmLink(code)(), 43); +assertEq(asmLink(code)(), 43); + +var code = asmCompile('glob', 'ffis', 'buf', USE_ASM + 'var i32=new glob.Int32Array(buf); function g() { return i32[0]|0 } return g'); +var i32_1 = new Int32Array(BUF_MIN/4); +i32_1[0] = 42; +var i32_2 = new Int32Array(BUF_MIN/4); +i32_2[0] = 13; +assertEq(asmLink(code, this, null, i32_1.buffer)(), 42); +assertEq(asmLink(code, this, null, i32_2.buffer)(), 13); +var i32_3 = new Int32Array(4097); +assertAsmLinkFail(code, this, null, i32_3.buffer); + +var code = asmCompile('glob', 'ffis', USE_ASM + 'var ffi=ffis.ffi; function g(n) { n=n|0; var i=0; for(; (i|0)<(n|0); i=(i+1)|0) ffi() } return g'); +var calls1 = 0, calls2 = 0; +function ffi1() { calls1++ } +function ffi2() { calls2++ } +asmLink(code, null, {ffi:ffi1})(100000); +assertEq(calls1, 100000); +assertEq(calls2, 0); +calls1 = 0; +asmLink(code, null, {ffi:ffi2})(50000); +assertEq(calls1, 0); +assertEq(calls2, 50000); + +var code = asmCompile(USE_ASM + 'var g = 0; function h() { g=(g+1)|0; return g|0 } return h'); +var h1 = code(); +assertEq(h1(), 1); +assertEq(h1(), 2); +var h2 = code(); +assertEq(h2(), 1); +assertEq(h1(), 3); +assertEq(h2(), 2); +assertEq(h1(), 4); + +var code = asmCompile(USE_ASM + "return {}"); +var h1 = code(); +var h2 = code(); +assertEq(h1 === h2, false); +assertEq(Object.keys(h1).length, 0); +assertEq(Object.keys(h2).length, 0); |