File: partial-return.wast

package info (click to toggle)
binaryen 120-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,284 kB
  • sloc: cpp: 189,449; javascript: 62,189; ansic: 14,087; python: 5,379; pascal: 441; sh: 77; makefile: 30; asm: 27
file content (33 lines) | stat: -rw-r--r-- 872 bytes parent folder | download
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
(module
  (import "import" "import" (func $import))

  (memory 256 256)
  (data (i32.const 10) "_________________")

  (export "test1" (func $test1))
  (export "memory" (memory $0))

  (func $test1
    ;; A safe store, should alter memory
    (i32.store8 (i32.const 12) (i32.const 115))

    ;; Load the value we just saved, and return because of its value. (This way
    ;; we could not see the return must execute without ctor-eval. At least, not
    ;; without store-load forwarding.)
    (if
      (i32.load8_u
        (i32.const 12)
      )
      (then
        (return)
      )
    )

    ;; This is unsafe to call, and would stop evalling here. But we exit due to
    ;; the return before anyhow, so it doesn't matter.
    (call $import)

    ;; A safe store that we never reach because of the return before us.
    (i32.store8 (i32.const 13) (i32.const 115))
  )
)