diff options
author | Alon Zakai <alonzakai@gmail.com> | 2019-04-03 17:49:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-03 17:49:47 -0700 |
commit | 773759f7842611bbe3e30f7b9d4cd24350291976 (patch) | |
tree | a2ac1d3b7e1850b3827b087f671c6182b39429b2 /test/spec/memory.wast | |
parent | 02198da745469104cb6ced60b37efa8d8a7f4464 (diff) | |
download | binaryen-773759f7842611bbe3e30f7b9d4cd24350291976.tar.gz binaryen-773759f7842611bbe3e30f7b9d4cd24350291976.tar.bz2 binaryen-773759f7842611bbe3e30f7b9d4cd24350291976.zip |
Update test/spec/memory.wast to latest upstream (#1801)
Minus multi-memory which we don't support yet.
Improve validator.
Fix some minor validation issues in our tests.
Diffstat (limited to 'test/spec/memory.wast')
-rw-r--r-- | test/spec/memory.wast | 195 |
1 files changed, 38 insertions, 157 deletions
diff --git a/test/spec/memory.wast b/test/spec/memory.wast index bb0226ed2..5f926339b 100644 --- a/test/spec/memory.wast +++ b/test/spec/memory.wast @@ -1,66 +1,39 @@ ;; Test memory section structure + (module (memory 0 0)) (module (memory 0 1)) (module (memory 1 256)) (module (memory 0 65536)) -(module (memory 0 0) (data (i32.const 0))) -(module (memory 0 0) (data (i32.const 0) "")) -(module (memory 1 1) (data (i32.const 0) "a")) -(module (memory 1 2) (data (i32.const 0) "a") (data (i32.const 65535) "b")) -(module (memory 1 2) - (data (i32.const 0) "a") (data (i32.const 1) "b") (data (i32.const 2) "c") -) - -(module (memory (data)) (func (export "memsize") (result i32) (current_memory))) -(assert_return (invoke "memsize") (i32.const 0)) -(module (memory (data "")) (func (export "memsize") (result i32) (current_memory))) -(assert_return (invoke "memsize") (i32.const 0)) -(module (memory (data "x")) (func (export "memsize") (result i32) (current_memory))) -(assert_return (invoke "memsize") (i32.const 1)) (assert_invalid (module (data (i32.const 0))) "unknown memory") (assert_invalid (module (data (i32.const 0) "")) "unknown memory") (assert_invalid (module (data (i32.const 0) "x")) "unknown memory") (assert_invalid - (module (memory 1) (data (i64.const 0))) - "type mismatch" -) -(assert_invalid - (module (memory 1) (data (i32.ctz (i32.const 0)))) - "constant expression required" + (module (func (drop (f32.load (i32.const 0))))) + "unknown memory" ) (assert_invalid - (module (memory 1) (data (nop))) - "constant expression required" + (module (func (f32.store (f32.const 0) (i32.const 0)))) + "unknown memory" ) - (assert_invalid - (module (memory 1 0)) - "memory size minimum must not be greater than maximum" + (module (func (drop (i32.load8_s (i32.const 0))))) + "unknown memory" ) (assert_invalid - (module (memory 0 0) (data (i32.const 0) "a")) - "data segment does not fit" + (module (func (i32.store8 (i32.const 0) (i32.const 0)))) + "unknown memory" ) (assert_invalid - (module (memory 1 2) (data (i32.const 0) "a") (data (i32.const 98304) "b")) - "data segment does not fit" -) -(assert_invalid - (module (memory 1 2) (data (i32.const 0) "abc") (data (i32.const 0) "def")) - "data segment not disjoint and ordered" -) -(assert_invalid - (module (memory 1 2) (data (i32.const 3) "ab") (data (i32.const 0) "de")) - "data segment not disjoint and ordered" + (module (func (drop (memory.grow (i32.const 0))))) + "unknown memory" ) + + (assert_invalid - (module - (memory 1 2) - (data (i32.const 0) "a") (data (i32.const 2) "b") (data (i32.const 1) "c") - ) - "data segment not disjoint and ordered" + (module (memory 1 0)) + "size minimum must not be greater than maximum" ) (assert_invalid (module (memory 65537)) @@ -87,70 +60,6 @@ "memory size must be at most 65536 pages (4GiB)" ) -;; Test alignment annotation rules -(module (memory 0) (func (drop (i32.load8_u align=1 (i32.const 0))))) -(module (memory 0) (func (drop (i32.load16_u align=2 (i32.const 0))))) -(module (memory 0) (func (drop (i32.load align=4 (i32.const 0))))) -(module (memory 0) (func (drop (f32.load align=4 (i32.const 0))))) - -(assert_invalid - (module (memory 0) (func (drop (i64.load align=0 (i32.const 0))))) - "alignment must be a power of two" -) -(assert_invalid - (module (memory 0) (func (drop (i64.load align=3 (i32.const 0))))) - "alignment must be a power of two" -) -(assert_invalid - (module (memory 0) (func (drop (i64.load align=5 (i32.const 0))))) - "alignment must be a power of two" -) -(assert_invalid - (module (memory 0) (func (drop (i64.load align=6 (i32.const 0))))) - "alignment must be a power of two" -) -(assert_invalid - (module (memory 0) (func (drop (i64.load align=7 (i32.const 0))))) - "alignment must be a power of two" -) - -(assert_invalid - (module (memory 0) (func (drop (i64.load align=16 (i32.const 0))))) - "alignment must not be larger than natural" -) -(assert_invalid - (module (memory 0) (func (drop (i64.load align=32 (i32.const 0))))) - "alignment must not be larger than natural" -) -(assert_invalid - (module (memory 0) (func (drop (i32.load align=8 (i32.const 0))))) - "alignment must not be larger than natural" -) -(assert_invalid - (module (memory 0) (func (drop (i32.load16_u align=4 (i32.const 0))))) - "alignment must not be larger than natural" -) -(assert_invalid - (module (memory 0) (func (drop (i32.load8_u align=2 (i32.const 0))))) - "alignment must not be larger than natural" -) -(assert_invalid - (module (memory 0) (func (i32.store8 align=2 (i32.const 0) (i32.const 0)))) - "alignment must not be larger than natural" -) -(assert_invalid - (module (memory 0) (func (i32.load16_u align=4 (i32.const 0)))) - "alignment must not be larger than natural" -) -(assert_invalid - (module (memory 0) (func (i32.load8_u align=2 (i32.const 0)))) - "alignment must not be larger than natural" -) -(assert_invalid - (module (memory 0) (func (i32.store8 align=2 (i32.const 0) (i32.const 0)))) - "alignment must not be larger than natural" -) - (module (memory 1) (data (i32.const 0) "ABC\a7D") (data (i32.const 20) "WASM") @@ -181,54 +90,6 @@ ) ) - ;; Aligned read/write - (func (export "aligned") (result i32) - (local i32 i32 i32) - (local.set 0 (i32.const 10)) - (block - (loop - (if - (i32.eq (local.get 0) (i32.const 0)) - (br 2) - ) - (local.set 2 (i32.mul (local.get 0) (i32.const 4))) - (i32.store (local.get 2) (local.get 0)) - (local.set 1 (i32.load (local.get 2))) - (if - (i32.ne (local.get 0) (local.get 1)) - (return (i32.const 0)) - ) - (local.set 0 (i32.sub (local.get 0) (i32.const 1))) - (br 0) - ) - ) - (i32.const 1) - ) - - ;; Unaligned read/write - (func (export "unaligned") (result i32) - (local i32 f64 f64) - (local.set 0 (i32.const 10)) - (block - (loop - (if - (i32.eq (local.get 0) (i32.const 0)) - (br 2) - ) - (local.set 2 (f64.convert_i32_s (local.get 0))) - (f64.store align=1 (local.get 0) (local.get 2)) - (local.set 1 (f64.load align=1 (local.get 0))) - (if - (f64.ne (local.get 2) (local.get 1)) - (return (i32.const 0)) - ) - (local.set 0 (i32.sub (local.get 0) (i32.const 1))) - (br 0) - ) - ) - (i32.const 1) - ) - ;; Memory cast (func (export "cast") (result f64) (i64.store (i32.const 8) (i64.const -12345)) @@ -237,7 +98,7 @@ (f64.load (i32.const 8)) (f64.reinterpret_i64 (i64.const -12345)) ) - (return (f64.const 0)) + (then (return (f64.const 0))) ) (i64.store align=1 (i32.const 9) (i64.const 0)) (i32.store16 align=1 (i32.const 15) (i32.const 16453)) @@ -288,8 +149,6 @@ ) (assert_return (invoke "data") (i32.const 1)) -(assert_return (invoke "aligned") (i32.const 1)) -(assert_return (invoke "unaligned") (i32.const 1)) (assert_return (invoke "cast") (f64.const 42.0)) (assert_return (invoke "i32_load8_s" (i32.const -1)) (i32.const -1)) @@ -302,6 +161,15 @@ (assert_return (invoke "i32_load16_s" (i32.const 20000)) (i32.const 20000)) (assert_return (invoke "i32_load16_u" (i32.const 40000)) (i32.const 40000)) +(assert_return (invoke "i32_load8_s" (i32.const 0xfedc6543)) (i32.const 0x43)) +(assert_return (invoke "i32_load8_s" (i32.const 0x3456cdef)) (i32.const 0xffffffef)) +(assert_return (invoke "i32_load8_u" (i32.const 0xfedc6543)) (i32.const 0x43)) +(assert_return (invoke "i32_load8_u" (i32.const 0x3456cdef)) (i32.const 0xef)) +(assert_return (invoke "i32_load16_s" (i32.const 0xfedc6543)) (i32.const 0x6543)) +(assert_return (invoke "i32_load16_s" (i32.const 0x3456cdef)) (i32.const 0xffffcdef)) +(assert_return (invoke "i32_load16_u" (i32.const 0xfedc6543)) (i32.const 0x6543)) +(assert_return (invoke "i32_load16_u" (i32.const 0x3456cdef)) (i32.const 0xcdef)) + (assert_return (invoke "i64_load8_s" (i64.const -1)) (i64.const -1)) (assert_return (invoke "i64_load8_u" (i64.const -1)) (i64.const 255)) (assert_return (invoke "i64_load16_s" (i64.const -1)) (i64.const -1)) @@ -315,3 +183,16 @@ (assert_return (invoke "i64_load16_u" (i64.const 40000)) (i64.const 40000)) (assert_return (invoke "i64_load32_s" (i64.const 20000)) (i64.const 20000)) (assert_return (invoke "i64_load32_u" (i64.const 40000)) (i64.const 40000)) + +(assert_return (invoke "i64_load8_s" (i64.const 0xfedcba9856346543)) (i64.const 0x43)) +(assert_return (invoke "i64_load8_s" (i64.const 0x3456436598bacdef)) (i64.const 0xffffffffffffffef)) +(assert_return (invoke "i64_load8_u" (i64.const 0xfedcba9856346543)) (i64.const 0x43)) +(assert_return (invoke "i64_load8_u" (i64.const 0x3456436598bacdef)) (i64.const 0xef)) +(assert_return (invoke "i64_load16_s" (i64.const 0xfedcba9856346543)) (i64.const 0x6543)) +(assert_return (invoke "i64_load16_s" (i64.const 0x3456436598bacdef)) (i64.const 0xffffffffffffcdef)) +(assert_return (invoke "i64_load16_u" (i64.const 0xfedcba9856346543)) (i64.const 0x6543)) +(assert_return (invoke "i64_load16_u" (i64.const 0x3456436598bacdef)) (i64.const 0xcdef)) +(assert_return (invoke "i64_load32_s" (i64.const 0xfedcba9856346543)) (i64.const 0x56346543)) +(assert_return (invoke "i64_load32_s" (i64.const 0x3456436598bacdef)) (i64.const 0xffffffff98bacdef)) +(assert_return (invoke "i64_load32_u" (i64.const 0xfedcba9856346543)) (i64.const 0x56346543)) +(assert_return (invoke "i64_load32_u" (i64.const 0x3456436598bacdef)) (i64.const 0x98bacdef)) |