Files
wasmtime/tests/misc_testsuite/memory-copy.wast
Alex Crichton 9c6884e28d Update the spec reference testsuite submodule (#3450)
* Update the spec reference testsuite submodule

This commit brings in recent updates to the spec test suite. Most of the
changes here were already fixed in `wasmparser` with some tweaks to
esoteric modules, but Wasmtime also gets a bug fix where where import
matching for the size of tables/memories is based on the current runtime
size of the table/memory rather than the original type of the
table/memory. This means that during type matching the actual value is
consulted for its size rather than using the minimum size listed in its
type.

* Fix now-missing directories in build script
2021-10-13 16:14:12 -05:00

125 lines
2.4 KiB
Plaintext

(module
(memory 1 1)
(data 0 (i32.const 1000) "hello")
(data 0 (i32.const 2000) "olleh")
(func $is_char (param i32 i32) (result i32)
local.get 0
i32.load8_u
local.get 1
i32.eq)
(func (export "is hello?") (param i32) (result i32)
local.get 0
i32.const 104 ;; 'h'
call $is_char
local.get 0
i32.const 1
i32.add
i32.const 101 ;; 'e'
call $is_char
local.get 0
i32.const 2
i32.add
i32.const 108 ;; 'l'
call $is_char
local.get 0
i32.const 3
i32.add
i32.const 108 ;; 'l'
call $is_char
local.get 0
i32.const 4
i32.add
i32.const 111 ;; 'o'
call $is_char
i32.and
i32.and
i32.and
i32.and
)
(func (export "is olleh?") (param i32) (result i32)
local.get 0
i32.const 111 ;; 'o'
call $is_char
local.get 0
i32.const 1
i32.add
i32.const 108 ;; 'l'
call $is_char
local.get 0
i32.const 2
i32.add
i32.const 108 ;; 'l'
call $is_char
local.get 0
i32.const 3
i32.add
i32.const 101 ;; 'e'
call $is_char
local.get 0
i32.const 4
i32.add
i32.const 104 ;; 'h'
call $is_char
i32.and
i32.and
i32.and
i32.and
)
(func (export "memory.copy") (param i32 i32 i32)
local.get 0
local.get 1
local.get 2
memory.copy))
;; Our memory has our initial data in the right places.
(assert_return
(invoke "is hello?" (i32.const 1000))
(i32.const 1))
(assert_return
(invoke "is olleh?" (i32.const 2000))
(i32.const 1))
;; Non-overlapping memory copy with dst < src.
(invoke "memory.copy" (i32.const 500) (i32.const 1000) (i32.const 5))
(assert_return
(invoke "is hello?" (i32.const 500))
(i32.const 1))
;; Non-overlapping memory copy with dst > src.
(invoke "memory.copy" (i32.const 1500) (i32.const 1000) (i32.const 5))
(assert_return
(invoke "is hello?" (i32.const 1500))
(i32.const 1))
;; Overlapping memory copy with dst < src.
(invoke "memory.copy" (i32.const 1998) (i32.const 2000) (i32.const 5))
(assert_return
(invoke "is olleh?" (i32.const 1998))
(i32.const 1))
;; Overlapping memory copy with dst > src.
(invoke "memory.copy" (i32.const 2000) (i32.const 1998) (i32.const 5))
(assert_return
(invoke "is olleh?" (i32.const 2000))
(i32.const 1))
;; Overlapping memory copy with dst = src.
(invoke "memory.copy" (i32.const 2000) (i32.const 2000) (i32.const 5))
(assert_return
(invoke "is olleh?" (i32.const 2000))
(i32.const 1))