summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/grow-memory.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/wasm/grow-memory.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/wasm/grow-memory.js')
-rw-r--r--js/src/jit-test/tests/wasm/grow-memory.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/grow-memory.js b/js/src/jit-test/tests/wasm/grow-memory.js
new file mode 100644
index 000000000..53dcfcc84
--- /dev/null
+++ b/js/src/jit-test/tests/wasm/grow-memory.js
@@ -0,0 +1,47 @@
+load(libdir + "wasm.js");
+
+function linearModule(min, max, ops) {
+ var opsText = ops.map(function (op) {
+ if (op[0] == "CM") {
+ res = `(if i32 (i32.ne (current_memory) (i32.const ${op[1]}))
+ (i32.load offset=10 (i32.const 4294967295))
+ (i32.const 0))`
+ } else if (op[0] == "GM") {
+ res = `(if i32 (i32.ne (grow_memory (i32.const ${op[1]})) (i32.const ${op[2]}))
+ (i32.load offset=10 (i32.const 4294967295))
+ (i32.const 0))`
+ } else if (op[0] == "L") {
+ var type = op[1];
+ var ext = op[2];
+ var off = op[3];
+ var loc = op[4]
+ var align = 0;
+ res = `(${type}.load${ext} offset=${off} (i32.const ${op[4]}))`;
+ } else if (op[0] == "S") {
+ var type = op[1];
+ var ext = op[2];
+ var off = op[3];
+ var loc = op[4]
+ var align = 0;
+ res = `(${type}.store${ext} offset=${off} (i32.const ${op[4]}) (i32.const 42))`;
+ }
+ return res;
+ }).join("\n")
+
+ let text =
+ `(module
+ (memory ${min} ${max})
+ ` + (min != 0 ? `(data (i32.const 0) "\\00\\01\\02\\03\\04\\05\\06\\07\\08\\09\\0a\\0b\\0c\\0d\\0e\\0f")
+ (data (i32.const 16) "\\f0\\f1\\f2\\f3\\f4\\f5\\f6\\f7\\f8\\f9\\fa\\fb\\fc\\fd\\fe\\ff")`
+ : "") +
+ `
+ (func (result i32)
+ (drop ` + opsText + `)
+ (current_memory)
+ ) (export "run" 0))`;
+
+ return text;
+}
+
+// Just grow some memory
+wasmFullPass(linearModule(3,5, [["CM", 3]]), 3);