File: many_table_gets_lead_to_gc.wast

package info (click to toggle)
rust-wasmtime 28.0.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 54,116 kB
  • sloc: ansic: 4,071; sh: 567; javascript: 548; cpp: 280; asm: 175; ml: 96; makefile: 55
file content (37 lines) | stat: -rw-r--r-- 1,093 bytes parent folder | download | duplicates (2)
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
;;! reference_types = true

(module
  (table $t 1 externref)

  (func (export "init") (param externref)
    (table.set $t (i32.const 0) (local.get 0))
  )

  (func (export "get-many-externrefs") (param $i i32)
    (loop $continue
      ;; Exit when our loop counter `$i` reaches zero.
      (if (i32.eqz (local.get $i))
        (then (return))
      )

      ;; Get an `externref` out of the table. This could cause the
      ;; `VMExternRefActivationsTable`'s bump region to reach full capacity,
      ;; which triggers a GC.
      ;;
      ;; Set the table element back into the table, just so that the element is
      ;; still considered live at the time of the `table.get`, it ends up in the
      ;; stack map, and we poke more of our GC bits.
      (table.set $t (i32.const 0) (table.get $t (i32.const 0)))

      ;; Decrement our loop counter `$i`.
      (local.set $i (i32.sub (local.get $i) (i32.const 1)))

      ;; Continue to the next loop iteration.
      (br $continue)
    )
    unreachable
  )
)

(invoke "init" (ref.extern 1))
(invoke "get-many-externrefs" (i32.const 8192))