blob: c38f84409351c70d21ea980cdc0797f04d0155bd (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
;; RUN: wasm-merge %s first %s.second second --rename-export-conflicts -all -S -o - | filecheck %s
;; Test that we fuse imports to exports across modules.
;;
;; We test functions and memories here, and not every possible entity in a
;; comprehensive way, since they all go through the same code path. (But we test
;; two to at least verify we differentiate them.)
;;
;; We also test importing memories and tags from another file than the
;; first one, which was initially broken.
(module
;; The first two imports here will be resolved to direct calls into the
;; second module's merged contents.
(import "second" "foo" (func $other.foo))
(import "second" "bar" (func $other.bar))
(import "second" "mem" (memory $other.mem 1))
;; This import will remain unresolved.
;; CHECK: (type $0 (func))
;; CHECK: (type $1 (func (result i32)))
;; CHECK: (import "third" "missing" (func $other.missing (type $0)))
(import "third" "missing" (func $other.missing))
;; CHECK: (memory $first.mem 2)
;; CHECK: (memory $second.mem 2)
;; CHECK: (tag $exn (param))
;; CHECK: (export "foo" (func $first.foo))
;; CHECK: (export "bar" (func $bar))
;; CHECK: (export "keepalive" (func $keepalive))
;; CHECK: (export "mem" (memory $first.mem))
;; CHECK: (export "exn" (tag $exn))
;; CHECK: (export "mem_5" (memory $second.mem))
;; CHECK: (export "foo_6" (func $second.foo))
;; CHECK: (export "bar_7" (func $bar_6))
;; CHECK: (export "keepalive2" (func $keepalive2))
;; CHECK: (export "keepalive3" (func $keepalive3))
;; CHECK: (func $first.foo (type $0)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 1)
;; CHECK-NEXT: )
;; CHECK-NEXT: (call $second.foo)
;; CHECK-NEXT: )
(func $first.foo (export "foo")
(drop
(i32.const 1)
)
(call $other.foo)
)
;; CHECK: (func $bar (type $0)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 2)
;; CHECK-NEXT: )
;; CHECK-NEXT: (call $bar_6)
;; CHECK-NEXT: (call $other.missing)
;; CHECK-NEXT: )
(func $bar (export "bar")
(drop
(i32.const 2)
)
(call $other.bar)
(call $other.missing)
)
;; CHECK: (func $keepalive (type $1) (result i32)
;; CHECK-NEXT: (i32.load $second.mem
;; CHECK-NEXT: (i32.const 10)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
(func $keepalive (export "keepalive") (result i32)
;; Load from the memory imported from the second module.
(i32.load $other.mem
(i32.const 10)
)
)
(memory $first.mem 2)
(export "mem" (memory $first.mem))
(tag $exn (export "exn"))
)
;; CHECK: (func $second.foo (type $0)
;; CHECK-NEXT: (call $first.foo)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 3)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK: (func $bar_6 (type $0)
;; CHECK-NEXT: (call $bar)
;; CHECK-NEXT: (drop
;; CHECK-NEXT: (i32.const 4)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK: (func $keepalive2 (type $1) (result i32)
;; CHECK-NEXT: (i32.load $first.mem
;; CHECK-NEXT: (i32.const 10)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK: (func $keepalive3 (type $0)
;; CHECK-NEXT: (throw $exn)
;; CHECK-NEXT: )
|