File: no-mixup-stack-maps.wast

package info (click to toggle)
rust-wasmtime 26.0.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 48,492 kB
  • sloc: ansic: 4,003; sh: 561; javascript: 542; cpp: 254; asm: 175; ml: 96; makefile: 55
file content (49 lines) | stat: -rw-r--r-- 1,149 bytes parent folder | download | duplicates (3)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(module
  (global $g (mut externref) (ref.null extern))

  ;; This function will have a stack map, notably one that's a bit
  ;; different than the one below.
  (func $has_a_stack_map
      (local externref)
      global.get $g
      local.tee 0
      global.set $g

      local.get 0
      global.set $g
      ref.null extern
      global.set $g
  )

  ;; This function also has a stack map, but it's only applicable after
  ;; the call to the `$gc` import, so when we gc during that we shouldn't
  ;; accidentally read the previous function's stack maps and use that
  ;; for our own.
  (func (export "run") (result i32)
      call $gc

      ref.null extern
      global.set $g
      i32.const 0
  )

  (func (export "init") (param externref)
      local.get 0
      global.set $g
  )

  ;; A small function which when run triggers a gc in wasmtime
  (func $gc
    (local $i i32)
    i32.const 10000
    local.set $i
    (loop $continue
      (global.set $g (global.get $g))
      (local.tee $i (i32.sub (local.get $i) (i32.const 1)))
      br_if $continue
    )
  )
)

(invoke "init" (ref.extern 1))
(assert_return (invoke "run") (i32.const 0))