1 ;; Syntactic types (validation time)
6 (type $t1 (func (param f32 f32) (result f32)))
7 (type $t2 (func (param $x f32) (param $y f32) (result f32)))
9 (func $f1 (param $r (ref $t1)) (call $f2 (local.get $r)))
10 (func $f2 (param $r (ref $t2)) (call $f1 (local.get $r)))
17 (type $s0 (func (param i32) (result f32)))
18 (type $s1 (func (param i32 (ref $s0)) (result (ref $s0))))
19 (type $s2 (func (param i32 (ref $s0)) (result (ref $s0))))
20 (type $t1 (func (param (ref $s1)) (result (ref $s2))))
21 (type $t2 (func (param (ref $s2)) (result (ref $s1))))
23 (func $f1 (param $r (ref $t1)) (call $f2 (local.get $r)))
24 (func $f2 (param $r (ref $t2)) (call $f1 (local.get $r)))
31 (type $t1 (func (param i32 (ref $t1))))
32 (type $t2 (func (param i32 (ref $t2))))
34 (func $f1 (param $r (ref $t1)) (call $f2 (local.get $r)))
35 (func $f2 (param $r (ref $t2)) (call $f1 (local.get $r)))
39 ;; Isomorphic recursive types.
42 (type $t1 (func (param i32 (ref $t1))))
43 (type $t2 (func (param i32 (ref $t3))))
44 (type $t3 (func (param i32 (ref $t2))))
46 (func $f1 (param $r (ref $t1))
47 (call $f2 (local.get $r))
48 (call $f3 (local.get $r))
50 (func $f2 (param $r (ref $t2))
51 (call $f1 (local.get $r))
52 (call $f3 (local.get $r))
54 (func $f3 (param $r (ref $t3))
55 (call $f1 (local.get $r))
56 (call $f2 (local.get $r))
61 (type $t1 (func (param i32 (ref $t3))))
62 (type $t2 (func (param i32 (ref $t1))))
63 (type $t3 (func (param i32 (ref $t2))))
65 (func $f1 (param $r (ref $t1))
66 (call $f2 (local.get $r))
67 (call $f3 (local.get $r))
69 (func $f2 (param $r (ref $t2))
70 (call $f1 (local.get $r))
71 (call $f3 (local.get $r))
73 (func $f3 (param $r (ref $t3))
74 (call $f1 (local.get $r))
75 (call $f2 (local.get $r))
80 (type $t1 (func (param i32 (ref $u1))))
81 (type $u1 (func (param f32 (ref $t1))))
83 (type $t2 (func (param i32 (ref $u3))))
84 (type $u2 (func (param f32 (ref $t3))))
85 (type $t3 (func (param i32 (ref $u2))))
86 (type $u3 (func (param f32 (ref $t2))))
88 (func $f1 (param $r (ref $t1))
89 (call $f2 (local.get $r))
90 (call $f3 (local.get $r))
92 (func $f2 (param $r (ref $t2))
93 (call $f1 (local.get $r))
94 (call $f3 (local.get $r))
96 (func $f3 (param $r (ref $t3))
97 (call $f1 (local.get $r))
98 (call $f2 (local.get $r))
103 ;; Semantic types (run time)
108 (type $t1 (func (param f32 f32)))
109 (type $t2 (func (param $x f32) (param $y f32)))
111 (func $f1 (type $t1))
112 (func $f2 (type $t2))
113 (table funcref (elem $f1 $f2))
116 (call_indirect (type $t1) (f32.const 1) (f32.const 2) (i32.const 1))
117 (call_indirect (type $t2) (f32.const 1) (f32.const 2) (i32.const 0))
120 (assert_return (invoke "run"))
126 (type $s0 (func (param i32)))
127 (type $s1 (func (param i32 (ref $s0))))
128 (type $s2 (func (param i32 (ref $s0))))
129 (type $t1 (func (param (ref $s1))))
130 (type $t2 (func (param (ref $s2))))
132 (func $s1 (type $s1))
133 (func $s2 (type $s2))
134 (func $f1 (type $t1))
135 (func $f2 (type $t2))
136 (table funcref (elem $f1 $f2 $s1 $s2))
139 (call_indirect (type $t1) (ref.func $s1) (i32.const 0))
140 (call_indirect (type $t1) (ref.func $s1) (i32.const 1))
141 (call_indirect (type $t1) (ref.func $s2) (i32.const 0))
142 (call_indirect (type $t1) (ref.func $s2) (i32.const 1))
143 (call_indirect (type $t2) (ref.func $s1) (i32.const 0))
144 (call_indirect (type $t2) (ref.func $s1) (i32.const 1))
145 (call_indirect (type $t2) (ref.func $s2) (i32.const 0))
146 (call_indirect (type $t2) (ref.func $s2) (i32.const 1))
149 (assert_return (invoke "run"))
155 (type $t1 (func (param i32 (ref $t1))))
156 (type $t2 (func (param i32 (ref $t2))))
158 (func $f1 (type $t1))
159 (func $f2 (type $t2))
160 (table funcref (elem $f1 $f2))
163 (call_indirect (type $t1) (i32.const 1) (ref.func $f1) (i32.const 0))
164 (call_indirect (type $t1) (i32.const 1) (ref.func $f1) (i32.const 1))
165 (call_indirect (type $t1) (i32.const 1) (ref.func $f2) (i32.const 0))
166 (call_indirect (type $t1) (i32.const 1) (ref.func $f2) (i32.const 1))
167 (call_indirect (type $t2) (i32.const 1) (ref.func $f1) (i32.const 0))
168 (call_indirect (type $t2) (i32.const 1) (ref.func $f1) (i32.const 1))
169 (call_indirect (type $t2) (i32.const 1) (ref.func $f2) (i32.const 0))
170 (call_indirect (type $t2) (i32.const 1) (ref.func $f2) (i32.const 1))
173 (assert_return (invoke "run"))
176 ;; Isomorphic recursive types.
179 (type $t1 (func (param i32 (ref $t1))))
180 (type $t2 (func (param i32 (ref $t3))))
181 (type $t3 (func (param i32 (ref $t2))))
183 (func $f1 (type $t1))
184 (func $f2 (type $t2))
185 (func $f3 (type $t3))
186 (table funcref (elem $f1 $f2 $f3))
189 (call_indirect (type $t1) (i32.const 1) (ref.func $f1) (i32.const 0))
190 (call_indirect (type $t1) (i32.const 1) (ref.func $f1) (i32.const 1))
191 (call_indirect (type $t1) (i32.const 1) (ref.func $f1) (i32.const 2))
192 (call_indirect (type $t1) (i32.const 1) (ref.func $f2) (i32.const 0))
193 (call_indirect (type $t1) (i32.const 1) (ref.func $f2) (i32.const 1))
194 (call_indirect (type $t1) (i32.const 1) (ref.func $f2) (i32.const 2))
195 (call_indirect (type $t1) (i32.const 1) (ref.func $f3) (i32.const 0))
196 (call_indirect (type $t1) (i32.const 1) (ref.func $f3) (i32.const 1))
197 (call_indirect (type $t1) (i32.const 1) (ref.func $f3) (i32.const 2))
198 (call_indirect (type $t2) (i32.const 1) (ref.func $f1) (i32.const 0))
199 (call_indirect (type $t2) (i32.const 1) (ref.func $f1) (i32.const 1))
200 (call_indirect (type $t2) (i32.const 1) (ref.func $f1) (i32.const 2))
201 (call_indirect (type $t2) (i32.const 1) (ref.func $f2) (i32.const 0))
202 (call_indirect (type $t2) (i32.const 1) (ref.func $f2) (i32.const 1))
203 (call_indirect (type $t2) (i32.const 1) (ref.func $f2) (i32.const 2))
204 (call_indirect (type $t2) (i32.const 1) (ref.func $f3) (i32.const 0))
205 (call_indirect (type $t2) (i32.const 1) (ref.func $f3) (i32.const 1))
206 (call_indirect (type $t2) (i32.const 1) (ref.func $f3) (i32.const 2))
207 (call_indirect (type $t3) (i32.const 1) (ref.func $f1) (i32.const 0))
208 (call_indirect (type $t3) (i32.const 1) (ref.func $f1) (i32.const 1))
209 (call_indirect (type $t3) (i32.const 1) (ref.func $f1) (i32.const 2))
210 (call_indirect (type $t3) (i32.const 1) (ref.func $f2) (i32.const 0))
211 (call_indirect (type $t3) (i32.const 1) (ref.func $f2) (i32.const 1))
212 (call_indirect (type $t3) (i32.const 1) (ref.func $f2) (i32.const 2))
213 (call_indirect (type $t3) (i32.const 1) (ref.func $f3) (i32.const 0))
214 (call_indirect (type $t3) (i32.const 1) (ref.func $f3) (i32.const 1))
215 (call_indirect (type $t3) (i32.const 1) (ref.func $f3) (i32.const 2))
218 (assert_return (invoke "run"))
221 (type $t1 (func (param i32 (ref $t3))))
222 (type $t2 (func (param i32 (ref $t1))))
223 (type $t3 (func (param i32 (ref $t2))))
225 (func $f1 (type $t1))
226 (func $f2 (type $t2))
227 (func $f3 (type $t3))
228 (table funcref (elem $f1 $f2 $f3))
231 (call_indirect (type $t1) (i32.const 1) (ref.func $f1) (i32.const 0))
232 (call_indirect (type $t1) (i32.const 1) (ref.func $f1) (i32.const 1))
233 (call_indirect (type $t1) (i32.const 1) (ref.func $f1) (i32.const 2))
234 (call_indirect (type $t1) (i32.const 1) (ref.func $f2) (i32.const 0))
235 (call_indirect (type $t1) (i32.const 1) (ref.func $f2) (i32.const 1))
236 (call_indirect (type $t1) (i32.const 1) (ref.func $f2) (i32.const 2))
237 (call_indirect (type $t1) (i32.const 1) (ref.func $f3) (i32.const 0))
238 (call_indirect (type $t1) (i32.const 1) (ref.func $f3) (i32.const 1))
239 (call_indirect (type $t1) (i32.const 1) (ref.func $f3) (i32.const 2))
240 (call_indirect (type $t2) (i32.const 1) (ref.func $f1) (i32.const 0))
241 (call_indirect (type $t2) (i32.const 1) (ref.func $f1) (i32.const 1))
242 (call_indirect (type $t2) (i32.const 1) (ref.func $f1) (i32.const 2))
243 (call_indirect (type $t2) (i32.const 1) (ref.func $f2) (i32.const 0))
244 (call_indirect (type $t2) (i32.const 1) (ref.func $f2) (i32.const 1))
245 (call_indirect (type $t2) (i32.const 1) (ref.func $f2) (i32.const 2))
246 (call_indirect (type $t2) (i32.const 1) (ref.func $f3) (i32.const 0))
247 (call_indirect (type $t2) (i32.const 1) (ref.func $f3) (i32.const 1))
248 (call_indirect (type $t2) (i32.const 1) (ref.func $f3) (i32.const 2))
249 (call_indirect (type $t3) (i32.const 1) (ref.func $f1) (i32.const 0))
250 (call_indirect (type $t3) (i32.const 1) (ref.func $f1) (i32.const 1))
251 (call_indirect (type $t3) (i32.const 1) (ref.func $f1) (i32.const 2))
252 (call_indirect (type $t3) (i32.const 1) (ref.func $f2) (i32.const 0))
253 (call_indirect (type $t3) (i32.const 1) (ref.func $f2) (i32.const 1))
254 (call_indirect (type $t3) (i32.const 1) (ref.func $f2) (i32.const 2))
255 (call_indirect (type $t3) (i32.const 1) (ref.func $f3) (i32.const 0))
256 (call_indirect (type $t3) (i32.const 1) (ref.func $f3) (i32.const 1))
257 (call_indirect (type $t3) (i32.const 1) (ref.func $f3) (i32.const 2))
260 (assert_return (invoke "run"))
263 (type $t1 (func (param i32 (ref $u1))))
264 (type $u1 (func (param f32 (ref $t1))))
266 (type $t2 (func (param i32 (ref $u3))))
267 (type $u2 (func (param f32 (ref $t3))))
268 (type $t3 (func (param i32 (ref $u2))))
269 (type $u3 (func (param f32 (ref $t2))))
271 (func $f1 (type $t1))
272 (func $f2 (type $t2))
273 (func $f3 (type $t3))
274 (func $g1 (type $u1))
275 (func $g2 (type $u2))
276 (func $g3 (type $u3))
277 (table funcref (elem $f1 $f2 $f3 $g1 $g2 $g3))
280 (call_indirect (type $t1) (i32.const 1) (ref.func $g1) (i32.const 0))
281 (call_indirect (type $t1) (i32.const 1) (ref.func $g1) (i32.const 1))
282 (call_indirect (type $t1) (i32.const 1) (ref.func $g1) (i32.const 2))
283 (call_indirect (type $t1) (i32.const 1) (ref.func $g2) (i32.const 0))
284 (call_indirect (type $t1) (i32.const 1) (ref.func $g2) (i32.const 1))
285 (call_indirect (type $t1) (i32.const 1) (ref.func $g2) (i32.const 2))
286 (call_indirect (type $t1) (i32.const 1) (ref.func $g3) (i32.const 0))
287 (call_indirect (type $t1) (i32.const 1) (ref.func $g3) (i32.const 1))
288 (call_indirect (type $t1) (i32.const 1) (ref.func $g3) (i32.const 2))
289 (call_indirect (type $t2) (i32.const 1) (ref.func $g1) (i32.const 0))
290 (call_indirect (type $t2) (i32.const 1) (ref.func $g1) (i32.const 1))
291 (call_indirect (type $t2) (i32.const 1) (ref.func $g1) (i32.const 2))
292 (call_indirect (type $t2) (i32.const 1) (ref.func $g2) (i32.const 0))
293 (call_indirect (type $t2) (i32.const 1) (ref.func $g2) (i32.const 1))
294 (call_indirect (type $t2) (i32.const 1) (ref.func $g2) (i32.const 2))
295 (call_indirect (type $t2) (i32.const 1) (ref.func $g3) (i32.const 0))
296 (call_indirect (type $t2) (i32.const 1) (ref.func $g3) (i32.const 1))
297 (call_indirect (type $t2) (i32.const 1) (ref.func $g3) (i32.const 2))
298 (call_indirect (type $t3) (i32.const 1) (ref.func $g1) (i32.const 0))
299 (call_indirect (type $t3) (i32.const 1) (ref.func $g1) (i32.const 1))
300 (call_indirect (type $t3) (i32.const 1) (ref.func $g1) (i32.const 2))
301 (call_indirect (type $t3) (i32.const 1) (ref.func $g2) (i32.const 0))
302 (call_indirect (type $t3) (i32.const 1) (ref.func $g2) (i32.const 1))
303 (call_indirect (type $t3) (i32.const 1) (ref.func $g2) (i32.const 2))
304 (call_indirect (type $t3) (i32.const 1) (ref.func $g3) (i32.const 0))
305 (call_indirect (type $t3) (i32.const 1) (ref.func $g3) (i32.const 1))
306 (call_indirect (type $t3) (i32.const 1) (ref.func $g3) (i32.const 2))
309 (assert_return (invoke "run"))
312 ;; Semantic types (link time)
317 (type $t1 (func (param f32 f32) (result f32)))
318 (func (export "f") (param (ref $t1)))
322 (type $t2 (func (param $x f32) (param $y f32) (result f32)))
323 (func (import "M" "f") (param (ref $t2)))
330 (type $s0 (func (param i32) (result f32)))
331 (type $s1 (func (param i32 (ref $s0)) (result (ref $s0))))
332 (type $s2 (func (param i32 (ref $s0)) (result (ref $s0))))
333 (type $t1 (func (param (ref $s1)) (result (ref $s2))))
334 (type $t2 (func (param (ref $s2)) (result (ref $s1))))
335 (func (export "f1") (param (ref $t1)))
336 (func (export "f2") (param (ref $t1)))
340 (type $s0 (func (param i32) (result f32)))
341 (type $s1 (func (param i32 (ref $s0)) (result (ref $s0))))
342 (type $s2 (func (param i32 (ref $s0)) (result (ref $s0))))
343 (type $t1 (func (param (ref $s1)) (result (ref $s2))))
344 (type $t2 (func (param (ref $s2)) (result (ref $s1))))
345 (func (import "M" "f1") (param (ref $t1)))
346 (func (import "M" "f1") (param (ref $t2)))
347 (func (import "M" "f2") (param (ref $t1)))
348 (func (import "M" "f2") (param (ref $t1)))
355 (type $t1 (func (param i32 (ref $t1))))
356 (func (export "f") (param (ref $t1)))
360 (type $t2 (func (param i32 (ref $t2))))
361 (func (import "M" "f") (param (ref $t2)))
365 ;; Isomorphic recursive types.
368 (type $t1 (func (param i32 (ref $t1))))
369 (type $t2 (func (param i32 (ref $t3))))
370 (type $t3 (func (param i32 (ref $t2))))
371 (func (export "f1") (param (ref $t1)))
372 (func (export "f2") (param (ref $t2)))
373 (func (export "f3") (param (ref $t3)))
377 (type $t1 (func (param i32 (ref $t1))))
378 (type $t2 (func (param i32 (ref $t3))))
379 (type $t3 (func (param i32 (ref $t2))))
380 (func (import "M" "f1") (param (ref $t1)))
381 (func (import "M" "f1") (param (ref $t2)))
382 (func (import "M" "f1") (param (ref $t3)))
383 (func (import "M" "f2") (param (ref $t1)))
384 (func (import "M" "f2") (param (ref $t2)))
385 (func (import "M" "f2") (param (ref $t3)))
386 (func (import "M" "f3") (param (ref $t1)))
387 (func (import "M" "f3") (param (ref $t2)))
388 (func (import "M" "f3") (param (ref $t3)))
392 (type $t1 (func (param i32 (ref $t3))))
393 (type $t2 (func (param i32 (ref $t1))))
394 (type $t3 (func (param i32 (ref $t2))))
395 (func (export "f1") (param (ref $t1)))
396 (func (export "f2") (param (ref $t2)))
397 (func (export "f3") (param (ref $t3)))
401 (type $t1 (func (param i32 (ref $t3))))
402 (type $t2 (func (param i32 (ref $t1))))
403 (type $t3 (func (param i32 (ref $t2))))
404 (func (import "M" "f1") (param (ref $t1)))
405 (func (import "M" "f1") (param (ref $t2)))
406 (func (import "M" "f1") (param (ref $t3)))
407 (func (import "M" "f2") (param (ref $t1)))
408 (func (import "M" "f2") (param (ref $t2)))
409 (func (import "M" "f2") (param (ref $t3)))
410 (func (import "M" "f3") (param (ref $t1)))
411 (func (import "M" "f3") (param (ref $t2)))
412 (func (import "M" "f3") (param (ref $t3)))
416 (type $t1 (func (param i32 (ref $u1))))
417 (type $u1 (func (param f32 (ref $t1))))
419 (type $t2 (func (param i32 (ref $u3))))
420 (type $u2 (func (param f32 (ref $t3))))
421 (type $t3 (func (param i32 (ref $u2))))
422 (type $u3 (func (param f32 (ref $t2))))
424 (func (export "f1") (param (ref $t1)))
425 (func (export "f2") (param (ref $t2)))
426 (func (export "f3") (param (ref $t3)))
430 (type $t1 (func (param i32 (ref $u1))))
431 (type $u1 (func (param f32 (ref $t1))))
433 (type $t2 (func (param i32 (ref $u3))))
434 (type $u2 (func (param f32 (ref $t3))))
435 (type $t3 (func (param i32 (ref $u2))))
436 (type $u3 (func (param f32 (ref $t2))))
438 (func (import "M" "f1") (param (ref $t1)))
439 (func (import "M" "f1") (param (ref $t2)))
440 (func (import "M" "f1") (param (ref $t3)))
441 (func (import "M" "f2") (param (ref $t1)))
442 (func (import "M" "f2") (param (ref $t2)))
443 (func (import "M" "f2") (param (ref $t3)))
444 (func (import "M" "f3") (param (ref $t1)))
445 (func (import "M" "f3") (param (ref $t2)))
446 (func (import "M" "f3") (param (ref $t3)))