blob: 4f8e34982817fd0c1b88295c88c35069d6d95f4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
(module
(import "spectest" "print" (func $print (param i32)))
(memory 1)
(data (i32.const 0) "abcdefghijklmnopqrstuvwxyz")
(func (export "good") (param $i i32)
(call $print (i32.load8_u offset=0 (get_local $i))) ;; 97 'a'
(call $print (i32.load8_u offset=1 (get_local $i))) ;; 98 'b'
(call $print (i32.load8_u offset=2 (get_local $i))) ;; 99 'c'
(call $print (i32.load8_u offset=25 (get_local $i))) ;; 122 'z'
(call $print (i32.load16_u offset=0 (get_local $i))) ;; 25185 'ab'
(call $print (i32.load16_u align=1 (get_local $i))) ;; 25185 'ab'
(call $print (i32.load16_u offset=1 align=1 (get_local $i))) ;; 25442 'bc'
(call $print (i32.load16_u offset=2 (get_local $i))) ;; 25699 'cd'
(call $print (i32.load16_u offset=25 align=1 (get_local $i))) ;; 122 'z\0'
(call $print (i32.load offset=0 (get_local $i))) ;; 1684234849 'abcd'
(call $print (i32.load offset=1 align=1 (get_local $i))) ;; 1701077858 'bcde'
(call $print (i32.load offset=2 align=2 (get_local $i))) ;; 1717920867 'cdef'
(call $print (i32.load offset=25 align=1 (get_local $i))) ;; 122 'z\0\0\0'
)
(func (export "bad") (param $i i32)
(drop (i32.load offset=4294967295 (get_local $i)))
)
)
(invoke "good" (i32.const 0))
(invoke "good" (i32.const 65507))
(assert_trap (invoke "good" (i32.const 65508)) "out of bounds memory access")
(assert_trap (invoke "bad" (i32.const 0)) "out of bounds memory access")
(assert_trap (invoke "bad" (i32.const 1)) "out of bounds memory access")
|