Skip to content

Commit 20dc91f

Browse files
authored
[test] Exporting random globals does not interfere with memories (WebAssembly#1753)
1 parent 2285497 commit 20dc91f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/core/memory.wast

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,28 @@
240240
"(import \"\" \"\" (memory $foo 1))"
241241
"(import \"\" \"\" (memory $foo 1))")
242242
"duplicate memory")
243+
244+
;; Test that exporting random globals does not change a memory's semantics.
245+
246+
(module
247+
(memory (export "memory") 1 1)
248+
249+
;; These should not change the behavior of memory accesses.
250+
(global (export "__data_end") i32 (i32.const 10000))
251+
(global (export "__stack_top") i32 (i32.const 10000))
252+
(global (export "__heap_base") i32 (i32.const 10000))
253+
254+
(func (export "load") (param i32) (result i32)
255+
(i32.load8_u (local.get 0))
256+
)
257+
)
258+
259+
;; None of these memory accesses should trap.
260+
(assert_return (invoke "load" (i32.const 0)) (i32.const 0))
261+
(assert_return (invoke "load" (i32.const 10000)) (i32.const 0))
262+
(assert_return (invoke "load" (i32.const 20000)) (i32.const 0))
263+
(assert_return (invoke "load" (i32.const 30000)) (i32.const 0))
264+
(assert_return (invoke "load" (i32.const 40000)) (i32.const 0))
265+
(assert_return (invoke "load" (i32.const 50000)) (i32.const 0))
266+
(assert_return (invoke "load" (i32.const 60000)) (i32.const 0))
267+
(assert_return (invoke "load" (i32.const 65535)) (i32.const 0))

0 commit comments

Comments
 (0)