summaryrefslogtreecommitdiff
path: root/test/lit/wasm-split/passive.wast
blob: a72dcada53f121dd3725992e62c0ba78211e039b (plain)
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
50
51
52
53
54
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.

;; RUN: wasm-split %s --split-funcs=second-in-table -g -o1 %t.1.wasm -o2 %t.2.wasm -all
;; RUN: wasm-dis %t.1.wasm | filecheck %s --check-prefix PRIMARY
;; RUN: wasm-dis %t.2.wasm | filecheck %s --check-prefix SECONDARY

(module
 (type $func-array (array (mut funcref)))

 ;; PRIMARY:      (type $0 (func))

 ;; PRIMARY:      (import "placeholder" "0" (func $placeholder_0))

 ;; PRIMARY:      (table $table 3 funcref)
 (table $table 3 funcref)

 ;; Workaround for https://github.com/WebAssembly/binaryen/issues/6572 - we
 ;; error without an active segment.
 (elem (i32.const 0))

 ;; PRIMARY:      (elem $0 (i32.const 0) $placeholder_0)

 ;; PRIMARY:      (elem $passive func $in-table $1)
 (elem $passive func $in-table $second-in-table)

 ;; PRIMARY:      (export "table" (table $table))

 ;; PRIMARY:      (func $in-table
 ;; PRIMARY-NEXT:  (nop)
 ;; PRIMARY-NEXT: )
 (func $in-table
  ;; This is in a passive segment, but it is in the main module so we need no
  ;; special handling.
 )

 ;; SECONDARY:      (type $0 (func))

 ;; SECONDARY:      (import "primary" "table" (table $table 3 funcref))

 ;; SECONDARY:      (elem $0 (i32.const 0) $second-in-table)

 ;; SECONDARY:      (func $second-in-table
 ;; SECONDARY-NEXT:  (nop)
 ;; SECONDARY-NEXT: )
 (func $second-in-table
  ;; This is in a passive segment, and it is in the secondary module, so we will
  ;; handle it by adding a trampoline from the segment as a new function "$1".
 )
)
;; PRIMARY:      (func $1
;; PRIMARY-NEXT:  (call_indirect (type $0)
;; PRIMARY-NEXT:   (i32.const 0)
;; PRIMARY-NEXT:  )
;; PRIMARY-NEXT: )