File: partial-return.wast

package info (click to toggle)
binaryen 108-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 35,424 kB
  • sloc: cpp: 151,487; javascript: 62,522; ansic: 13,124; python: 5,260; pascal: 441; sh: 75; asm: 27; makefile: 8
file content (31 lines) | stat: -rw-r--r-- 843 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
(module
  (import "import" "import" (func $import))

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

  (export "test1" $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)
      )
      (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))
  )
)