1*e50d897bSAlex Crichton;;! bulk_memory = true 2*e50d897bSAlex Crichton 39c6884e2SAlex Crichton(module $m 49c6884e2SAlex Crichton (memory (export "mem") 1) 59c6884e2SAlex Crichton 69c6884e2SAlex Crichton (func (export "load") (param i32) (result i32) 79c6884e2SAlex Crichton local.get 0 89c6884e2SAlex Crichton i32.load8_u)) 99c6884e2SAlex Crichton 109c6884e2SAlex Crichton(register "m" $m) 119c6884e2SAlex Crichton 129c6884e2SAlex Crichton(assert_trap 139c6884e2SAlex Crichton (module 149c6884e2SAlex Crichton (memory (import "m" "mem") 1) 159c6884e2SAlex Crichton 169c6884e2SAlex Crichton ;; This is in bounds, and should get written to the memory. 179c6884e2SAlex Crichton (data (i32.const 0) "abc") 189c6884e2SAlex Crichton 199c6884e2SAlex Crichton ;; Partially out of bounds. None of these bytes should get written, and 209c6884e2SAlex Crichton ;; instantiation should trap. 219c6884e2SAlex Crichton (data (i32.const 65530) "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz") 229c6884e2SAlex Crichton ) 239c6884e2SAlex Crichton "out of bounds" 249c6884e2SAlex Crichton) 259c6884e2SAlex Crichton 269c6884e2SAlex Crichton;; The first data segment got written. 279c6884e2SAlex Crichton(assert_return (invoke $m "load" (i32.const 0)) (i32.const 97)) 289c6884e2SAlex Crichton(assert_return (invoke $m "load" (i32.const 1)) (i32.const 98)) 299c6884e2SAlex Crichton(assert_return (invoke $m "load" (i32.const 2)) (i32.const 99)) 309c6884e2SAlex Crichton 319c6884e2SAlex Crichton;; The second did not get partially written. 329c6884e2SAlex Crichton(assert_return (invoke $m "load" (i32.const 65530)) (i32.const 0)) 339c6884e2SAlex Crichton(assert_return (invoke $m "load" (i32.const 65531)) (i32.const 0)) 349c6884e2SAlex Crichton(assert_return (invoke $m "load" (i32.const 65532)) (i32.const 0)) 359c6884e2SAlex Crichton(assert_return (invoke $m "load" (i32.const 65533)) (i32.const 0)) 369c6884e2SAlex Crichton(assert_return (invoke $m "load" (i32.const 65534)) (i32.const 0)) 379c6884e2SAlex Crichton(assert_return (invoke $m "load" (i32.const 65535)) (i32.const 0)) 38