Debian Codegraph @

js/src/jit-test/tests/wasm/spec/memory64/call_indirect.wast.js

raw
1 /* Copyright 2021 Mozilla Foundation
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 // ./test/core/call_indirect.wast
17
18 // ./test/core/call_indirect.wast:3
19 let $0 = instantiate(`(module
20 ;; Auxiliary definitions
21 (type $$proc (func))
22 (type $$out-i32 (func (result i32)))
23 (type $$out-i64 (func (result i64)))
24 (type $$out-f32 (func (result f32)))
25 (type $$out-f64 (func (result f64)))
26 (type $$out-f64-i32 (func (result f64 i32)))
27 (type $$over-i32 (func (param i32) (result i32)))
28 (type $$over-i64 (func (param i64) (result i64)))
29 (type $$over-f32 (func (param f32) (result f32)))
30 (type $$over-f64 (func (param f64) (result f64)))
31 (type $$over-i32-f64 (func (param i32 f64) (result i32 f64)))
32 (type $$swap-i32-i64 (func (param i32 i64) (result i64 i32)))
33 (type $$f32-i32 (func (param f32 i32) (result i32)))
34 (type $$i32-i64 (func (param i32 i64) (result i64)))
35 (type $$f64-f32 (func (param f64 f32) (result f32)))
36 (type $$i64-f64 (func (param i64 f64) (result f64)))
37 (type $$over-i32-duplicate (func (param i32) (result i32)))
38 (type $$over-i64-duplicate (func (param i64) (result i64)))
39 (type $$over-f32-duplicate (func (param f32) (result f32)))
40 (type $$over-f64-duplicate (func (param f64) (result f64)))
41
42 (func $$const-i32 (type $$out-i32) (i32.const 0x132))
43 (func $$const-i64 (type $$out-i64) (i64.const 0x164))
44 (func $$const-f32 (type $$out-f32) (f32.const 0xf32))
45 (func $$const-f64 (type $$out-f64) (f64.const 0xf64))
46 (func $$const-f64-i32 (type $$out-f64-i32) (f64.const 0xf64) (i32.const 32))
47
48 (func $$id-i32 (type $$over-i32) (local.get 0))
49 (func $$id-i64 (type $$over-i64) (local.get 0))
50 (func $$id-f32 (type $$over-f32) (local.get 0))
51 (func $$id-f64 (type $$over-f64) (local.get 0))
52 (func $$id-i32-f64 (type $$over-i32-f64) (local.get 0) (local.get 1))
53 (func $$swap-i32-i64 (type $$swap-i32-i64) (local.get 1) (local.get 0))
54
55 (func $$i32-i64 (type $$i32-i64) (local.get 1))
56 (func $$i64-f64 (type $$i64-f64) (local.get 1))
57 (func $$f32-i32 (type $$f32-i32) (local.get 1))
58 (func $$f64-f32 (type $$f64-f32) (local.get 1))
59
60 (func $$over-i32-duplicate (type $$over-i32-duplicate) (local.get 0))
61 (func $$over-i64-duplicate (type $$over-i64-duplicate) (local.get 0))
62 (func $$over-f32-duplicate (type $$over-f32-duplicate) (local.get 0))
63 (func $$over-f64-duplicate (type $$over-f64-duplicate) (local.get 0))
64
65 (table funcref
66 (elem
67 $$const-i32 $$const-i64 $$const-f32 $$const-f64 ;; 0..3
68 $$id-i32 $$id-i64 $$id-f32 $$id-f64 ;; 4..7
69 $$f32-i32 $$i32-i64 $$f64-f32 $$i64-f64 ;; 9..11
70 $$fac-i64 $$fib-i64 $$even $$odd ;; 12..15
71 $$runaway $$mutual-runaway1 $$mutual-runaway2 ;; 16..18
72 $$over-i32-duplicate $$over-i64-duplicate ;; 19..20
73 $$over-f32-duplicate $$over-f64-duplicate ;; 21..22
74 $$fac-i32 $$fac-f32 $$fac-f64 ;; 23..25
75 $$fib-i32 $$fib-f32 $$fib-f64 ;; 26..28
76 $$const-f64-i32 $$id-i32-f64 $$swap-i32-i64 ;; 29..31
77 )
78 )
79
80 (table $$t64 i64 funcref
81 (elem $$const-i32)
82 )
83
84 ;; Syntax
85
86 (func
87 (call_indirect (i32.const 0))
88 (call_indirect $$t64 (i64.const 0))
89 (call_indirect (param i64) (i64.const 0) (i32.const 0))
90 (call_indirect (param i64) (param) (param f64 i32 i64)
91 (i64.const 0) (f64.const 0) (i32.const 0) (i64.const 0) (i32.const 0)
92 )
93 (call_indirect (result) (i32.const 0))
94 (drop (i32.eqz (call_indirect (result i32) (i32.const 0))))
95 (drop (i32.eqz (call_indirect (result i32) (result) (i32.const 0))))
96 (drop (i32.eqz
97 (call_indirect (param i64) (result i32) (i64.const 0) (i32.const 0))
98 ))
99 (drop (i32.eqz
100 (call_indirect
101 (param) (param i64) (param) (param f64 i32 i64) (param) (param)
102 (result) (result i32) (result) (result)
103 (i64.const 0) (f64.const 0) (i32.const 0) (i64.const 0) (i32.const 0)
104 )
105 ))
106 (drop (i64.eqz
107 (call_indirect (type $$over-i64) (param i64) (result i64)
108 (i64.const 0) (i32.const 0)
109 )
110 ))
111 )
112
113 ;; Typing
114
115 (func (export "type-i32") (result i32)
116 (call_indirect (type $$out-i32) (i32.const 0))
117 )
118 (func (export "type-i32-t64") (result i32)
119 (call_indirect $$t64 (type $$out-i32) (i64.const 0))
120 )
121 (func (export "type-i64") (result i64)
122 (call_indirect (type $$out-i64) (i32.const 1))
123 )
124 (func (export "type-f32") (result f32)
125 (call_indirect (type $$out-f32) (i32.const 2))
126 )
127 (func (export "type-f64") (result f64)
128 (call_indirect (type $$out-f64) (i32.const 3))
129 )
130 (func (export "type-f64-i32") (result f64 i32)
131 (call_indirect (type $$out-f64-i32) (i32.const 29))
132 )
133
134 (func (export "type-index") (result i64)
135 (call_indirect (type $$over-i64) (i64.const 100) (i32.const 5))
136 )
137
138 (func (export "type-first-i32") (result i32)
139 (call_indirect (type $$over-i32) (i32.const 32) (i32.const 4))
140 )
141 (func (export "type-first-i64") (result i64)
142 (call_indirect (type $$over-i64) (i64.const 64) (i32.const 5))
143 )
144 (func (export "type-first-f32") (result f32)
145 (call_indirect (type $$over-f32) (f32.const 1.32) (i32.const 6))
146 )
147 (func (export "type-first-f64") (result f64)
148 (call_indirect (type $$over-f64) (f64.const 1.64) (i32.const 7))
149 )
150
151 (func (export "type-second-i32") (result i32)
152 (call_indirect (type $$f32-i32) (f32.const 32.1) (i32.const 32) (i32.const 8))
153 )
154 (func (export "type-second-i64") (result i64)
155 (call_indirect (type $$i32-i64) (i32.const 32) (i64.const 64) (i32.const 9))
156 )
157 (func (export "type-second-f32") (result f32)
158 (call_indirect (type $$f64-f32) (f64.const 64) (f32.const 32) (i32.const 10))
159 )
160 (func (export "type-second-f64") (result f64)
161 (call_indirect (type $$i64-f64) (i64.const 64) (f64.const 64.1) (i32.const 11))
162 )
163
164 (func (export "type-all-f64-i32") (result f64 i32)
165 (call_indirect (type $$out-f64-i32) (i32.const 29))
166 )
167 (func (export "type-all-i32-f64") (result i32 f64)
168 (call_indirect (type $$over-i32-f64)
169 (i32.const 1) (f64.const 2) (i32.const 30)
170 )
171 )
172 (func (export "type-all-i32-i64") (result i64 i32)
173 (call_indirect (type $$swap-i32-i64)
174 (i32.const 1) (i64.const 2) (i32.const 31)
175 )
176 )
177
178 ;; Dispatch
179
180 (func (export "dispatch") (param i32 i64) (result i64)
181 (call_indirect (type $$over-i64) (local.get 1) (local.get 0))
182 )
183
184 (func (export "dispatch-structural-i64") (param i32) (result i64)
185 (call_indirect (type $$over-i64-duplicate) (i64.const 9) (local.get 0))
186 )
187 (func (export "dispatch-structural-i32") (param i32) (result i32)
188 (call_indirect (type $$over-i32-duplicate) (i32.const 9) (local.get 0))
189 )
190 (func (export "dispatch-structural-f32") (param i32) (result f32)
191 (call_indirect (type $$over-f32-duplicate) (f32.const 9.0) (local.get 0))
192 )
193 (func (export "dispatch-structural-f64") (param i32) (result f64)
194 (call_indirect (type $$over-f64-duplicate) (f64.const 9.0) (local.get 0))
195 )
196
197 ;; Recursion
198
199 (func $$fac-i64 (export "fac-i64") (type $$over-i64)
200 (if (result i64) (i64.eqz (local.get 0))
201 (then (i64.const 1))
202 (else
203 (i64.mul
204 (local.get 0)
205 (call_indirect (type $$over-i64)
206 (i64.sub (local.get 0) (i64.const 1))
207 (i32.const 12)
208 )
209 )
210 )
211 )
212 )
213
214 (func $$fib-i64 (export "fib-i64") (type $$over-i64)
215 (if (result i64) (i64.le_u (local.get 0) (i64.const 1))
216 (then (i64.const 1))
217 (else
218 (i64.add
219 (call_indirect (type $$over-i64)
220 (i64.sub (local.get 0) (i64.const 2))
221 (i32.const 13)
222 )
223 (call_indirect (type $$over-i64)
224 (i64.sub (local.get 0) (i64.const 1))
225 (i32.const 13)
226 )
227 )
228 )
229 )
230 )
231
232 (func $$fac-i32 (export "fac-i32") (type $$over-i32)
233 (if (result i32) (i32.eqz (local.get 0))
234 (then (i32.const 1))
235 (else
236 (i32.mul
237 (local.get 0)
238 (call_indirect (type $$over-i32)
239 (i32.sub (local.get 0) (i32.const 1))
240 (i32.const 23)
241 )
242 )
243 )
244 )
245 )
246
247 (func $$fac-f32 (export "fac-f32") (type $$over-f32)
248 (if (result f32) (f32.eq (local.get 0) (f32.const 0.0))
249 (then (f32.const 1.0))
250 (else
251 (f32.mul
252 (local.get 0)
253 (call_indirect (type $$over-f32)
254 (f32.sub (local.get 0) (f32.const 1.0))
255 (i32.const 24)
256 )
257 )
258 )
259 )
260 )
261
262 (func $$fac-f64 (export "fac-f64") (type $$over-f64)
263 (if (result f64) (f64.eq (local.get 0) (f64.const 0.0))
264 (then (f64.const 1.0))
265 (else
266 (f64.mul
267 (local.get 0)
268 (call_indirect (type $$over-f64)
269 (f64.sub (local.get 0) (f64.const 1.0))
270 (i32.const 25)
271 )
272 )
273 )
274 )
275 )
276
277 (func $$fib-i32 (export "fib-i32") (type $$over-i32)
278 (if (result i32) (i32.le_u (local.get 0) (i32.const 1))
279 (then (i32.const 1))
280 (else
281 (i32.add
282 (call_indirect (type $$over-i32)
283 (i32.sub (local.get 0) (i32.const 2))
284 (i32.const 26)
285 )
286 (call_indirect (type $$over-i32)
287 (i32.sub (local.get 0) (i32.const 1))
288 (i32.const 26)
289 )
290 )
291 )
292 )
293 )
294
295 (func $$fib-f32 (export "fib-f32") (type $$over-f32)
296 (if (result f32) (f32.le (local.get 0) (f32.const 1.0))
297 (then (f32.const 1.0))
298 (else
299 (f32.add
300 (call_indirect (type $$over-f32)
301 (f32.sub (local.get 0) (f32.const 2.0))
302 (i32.const 27)
303 )
304 (call_indirect (type $$over-f32)
305 (f32.sub (local.get 0) (f32.const 1.0))
306 (i32.const 27)
307 )
308 )
309 )
310 )
311 )
312
313 (func $$fib-f64 (export "fib-f64") (type $$over-f64)
314 (if (result f64) (f64.le (local.get 0) (f64.const 1.0))
315 (then (f64.const 1.0))
316 (else
317 (f64.add
318 (call_indirect (type $$over-f64)
319 (f64.sub (local.get 0) (f64.const 2.0))
320 (i32.const 28)
321 )
322 (call_indirect (type $$over-f64)
323 (f64.sub (local.get 0) (f64.const 1.0))
324 (i32.const 28)
325 )
326 )
327 )
328 )
329 )
330
331 (func $$even (export "even") (param i32) (result i32)
332 (if (result i32) (i32.eqz (local.get 0))
333 (then (i32.const 44))
334 (else
335 (call_indirect (type $$over-i32)
336 (i32.sub (local.get 0) (i32.const 1))
337 (i32.const 15)
338 )
339 )
340 )
341 )
342 (func $$odd (export "odd") (param i32) (result i32)
343 (if (result i32) (i32.eqz (local.get 0))
344 (then (i32.const 99))
345 (else
346 (call_indirect (type $$over-i32)
347 (i32.sub (local.get 0) (i32.const 1))
348 (i32.const 14)
349 )
350 )
351 )
352 )
353
354 ;; Stack exhaustion
355
356 ;; Implementations are required to have every call consume some abstract
357 ;; resource towards exhausting some abstract finite limit, such that
358 ;; infinitely recursive test cases reliably trap in finite time. This is
359 ;; because otherwise applications could come to depend on it on those
360 ;; implementations and be incompatible with implementations that don't do
361 ;; it (or don't do it under the same circumstances).
362
363 (func $$runaway (export "runaway") (call_indirect (type $$proc) (i32.const 16)))
364
365 (func $$mutual-runaway1 (export "mutual-runaway") (call_indirect (type $$proc) (i32.const 18)))
366 (func $$mutual-runaway2 (call_indirect (type $$proc) (i32.const 17)))
367
368 ;; As parameter of control constructs and instructions
369
370 (memory 1)
371
372 (func (export "as-select-first") (result i32)
373 (select (call_indirect (type $$out-i32) (i32.const 0)) (i32.const 2) (i32.const 3))
374 )
375 (func (export "as-select-mid") (result i32)
376 (select (i32.const 2) (call_indirect (type $$out-i32) (i32.const 0)) (i32.const 3))
377 )
378 (func (export "as-select-last") (result i32)
379 (select (i32.const 2) (i32.const 3) (call_indirect (type $$out-i32) (i32.const 0)))
380 )
381
382 (func (export "as-if-condition") (result i32)
383 (if (result i32) (call_indirect (type $$out-i32) (i32.const 0)) (then (i32.const 1)) (else (i32.const 2)))
384 )
385
386 (func (export "as-br_if-first") (result i64)
387 (block (result i64) (br_if 0 (call_indirect (type $$out-i64) (i32.const 1)) (i32.const 2)))
388 )
389 (func (export "as-br_if-last") (result i32)
390 (block (result i32) (br_if 0 (i32.const 2) (call_indirect (type $$out-i32) (i32.const 0))))
391 )
392
393 (func (export "as-br_table-first") (result f32)
394 (block (result f32) (call_indirect (type $$out-f32) (i32.const 2)) (i32.const 2) (br_table 0 0))
395 )
396 (func (export "as-br_table-last") (result i32)
397 (block (result i32) (i32.const 2) (call_indirect (type $$out-i32) (i32.const 0)) (br_table 0 0))
398 )
399
400 (func (export "as-store-first")
401 (call_indirect (type $$out-i32) (i32.const 0)) (i32.const 1) (i32.store)
402 )
403 (func (export "as-store-last")
404 (i32.const 10) (call_indirect (type $$out-f64) (i32.const 3)) (f64.store)
405 )
406
407 (func (export "as-memory.grow-value") (result i32)
408 (memory.grow (call_indirect (type $$out-i32) (i32.const 0)))
409 )
410 (func (export "as-return-value") (result i32)
411 (call_indirect (type $$over-i32) (i32.const 1) (i32.const 4)) (return)
412 )
413 (func (export "as-drop-operand")
414 (call_indirect (type $$over-i64) (i64.const 1) (i32.const 5)) (drop)
415 )
416 (func (export "as-br-value") (result f32)
417 (block (result f32) (br 0 (call_indirect (type $$over-f32) (f32.const 1) (i32.const 6))))
418 )
419 (func (export "as-local.set-value") (result f64)
420 (local f64) (local.set 0 (call_indirect (type $$over-f64) (f64.const 1) (i32.const 7))) (local.get 0)
421 )
422 (func (export "as-local.tee-value") (result f64)
423 (local f64) (local.tee 0 (call_indirect (type $$over-f64) (f64.const 1) (i32.const 7)))
424 )
425 (global $$a (mut f64) (f64.const 10.0))
426 (func (export "as-global.set-value") (result f64)
427 (global.set $$a (call_indirect (type $$over-f64) (f64.const 1.0) (i32.const 7)))
428 (global.get $$a)
429 )
430
431 (func (export "as-load-operand") (result i32)
432 (i32.load (call_indirect (type $$out-i32) (i32.const 0)))
433 )
434
435 (func (export "as-unary-operand") (result f32)
436 (block (result f32)
437 (f32.sqrt
438 (call_indirect (type $$over-f32) (f32.const 0x0p+0) (i32.const 6))
439 )
440 )
441 )
442
443 (func (export "as-binary-left") (result i32)
444 (block (result i32)
445 (i32.add
446 (call_indirect (type $$over-i32) (i32.const 1) (i32.const 4))
447 (i32.const 10)
448 )
449 )
450 )
451 (func (export "as-binary-right") (result i32)
452 (block (result i32)
453 (i32.sub
454 (i32.const 10)
455 (call_indirect (type $$over-i32) (i32.const 1) (i32.const 4))
456 )
457 )
458 )
459
460 (func (export "as-test-operand") (result i32)
461 (block (result i32)
462 (i32.eqz
463 (call_indirect (type $$over-i32) (i32.const 1) (i32.const 4))
464 )
465 )
466 )
467
468 (func (export "as-compare-left") (result i32)
469 (block (result i32)
470 (i32.le_u
471 (call_indirect (type $$over-i32) (i32.const 1) (i32.const 4))
472 (i32.const 10)
473 )
474 )
475 )
476 (func (export "as-compare-right") (result i32)
477 (block (result i32)
478 (i32.ne
479 (i32.const 10)
480 (call_indirect (type $$over-i32) (i32.const 1) (i32.const 4))
481 )
482 )
483 )
484
485 (func (export "as-convert-operand") (result i64)
486 (block (result i64)
487 (i64.extend_i32_s
488 (call_indirect (type $$over-i32) (i32.const 1) (i32.const 4))
489 )
490 )
491 )
492
493 )`);
494
495 // ./test/core/call_indirect.wast:479
496 assert_return(() => invoke($0, `type-i32`, []), [value("i32", 306)]);
497
498 // ./test/core/call_indirect.wast:480
499 assert_return(() => invoke($0, `type-i64`, []), [value("i64", 356n)]);
500
501 // ./test/core/call_indirect.wast:481
502 assert_return(() => invoke($0, `type-f32`, []), [value("f32", 3890)]);
503
504 // ./test/core/call_indirect.wast:482
505 assert_return(() => invoke($0, `type-f64`, []), [value("f64", 3940)]);
506
507 // ./test/core/call_indirect.wast:483
508 assert_return(() => invoke($0, `type-f64-i32`, []), [value("f64", 3940), value("i32", 32)]);
509
510 // ./test/core/call_indirect.wast:485
511 assert_return(() => invoke($0, `type-i32-t64`, []), [value("i32", 306)]);
512
513 // ./test/core/call_indirect.wast:487
514 assert_return(() => invoke($0, `type-index`, []), [value("i64", 100n)]);
515
516 // ./test/core/call_indirect.wast:489
517 assert_return(() => invoke($0, `type-first-i32`, []), [value("i32", 32)]);
518
519 // ./test/core/call_indirect.wast:490
520 assert_return(() => invoke($0, `type-first-i64`, []), [value("i64", 64n)]);
521
522 // ./test/core/call_indirect.wast:491
523 assert_return(() => invoke($0, `type-first-f32`, []), [value("f32", 1.32)]);
524
525 // ./test/core/call_indirect.wast:492
526 assert_return(() => invoke($0, `type-first-f64`, []), [value("f64", 1.64)]);
527
528 // ./test/core/call_indirect.wast:494
529 assert_return(() => invoke($0, `type-second-i32`, []), [value("i32", 32)]);
530
531 // ./test/core/call_indirect.wast:495
532 assert_return(() => invoke($0, `type-second-i64`, []), [value("i64", 64n)]);
533
534 // ./test/core/call_indirect.wast:496
535 assert_return(() => invoke($0, `type-second-f32`, []), [value("f32", 32)]);
536
537 // ./test/core/call_indirect.wast:497
538 assert_return(() => invoke($0, `type-second-f64`, []), [value("f64", 64.1)]);
539
540 // ./test/core/call_indirect.wast:499
541 assert_return(() => invoke($0, `type-all-f64-i32`, []), [value("f64", 3940), value("i32", 32)]);
542
543 // ./test/core/call_indirect.wast:500
544 assert_return(() => invoke($0, `type-all-i32-f64`, []), [value("i32", 1), value("f64", 2)]);
545
546 // ./test/core/call_indirect.wast:501
547 assert_return(() => invoke($0, `type-all-i32-i64`, []), [value("i64", 2n), value("i32", 1)]);
548
549 // ./test/core/call_indirect.wast:503
550 assert_return(() => invoke($0, `dispatch`, [5, 2n]), [value("i64", 2n)]);
551
552 // ./test/core/call_indirect.wast:504
553 assert_return(() => invoke($0, `dispatch`, [5, 5n]), [value("i64", 5n)]);
554
555 // ./test/core/call_indirect.wast:505
556 assert_return(() => invoke($0, `dispatch`, [12, 5n]), [value("i64", 120n)]);
557
558 // ./test/core/call_indirect.wast:506
559 assert_return(() => invoke($0, `dispatch`, [13, 5n]), [value("i64", 8n)]);
560
561 // ./test/core/call_indirect.wast:507
562 assert_return(() => invoke($0, `dispatch`, [20, 2n]), [value("i64", 2n)]);
563
564 // ./test/core/call_indirect.wast:508
565 assert_trap(() => invoke($0, `dispatch`, [0, 2n]), `indirect call type mismatch`);
566
567 // ./test/core/call_indirect.wast:509
568 assert_trap(() => invoke($0, `dispatch`, [15, 2n]), `indirect call type mismatch`);
569
570 // ./test/core/call_indirect.wast:510
571 assert_trap(() => invoke($0, `dispatch`, [32, 2n]), `undefined element`);
572
573 // ./test/core/call_indirect.wast:511
574 assert_trap(() => invoke($0, `dispatch`, [-1, 2n]), `undefined element`);
575
576 // ./test/core/call_indirect.wast:512
577 assert_trap(() => invoke($0, `dispatch`, [1213432423, 2n]), `undefined element`);
578
579 // ./test/core/call_indirect.wast:514
580 assert_return(() => invoke($0, `dispatch-structural-i64`, [5]), [value("i64", 9n)]);
581
582 // ./test/core/call_indirect.wast:515
583 assert_return(() => invoke($0, `dispatch-structural-i64`, [12]), [value("i64", 362880n)]);
584
585 // ./test/core/call_indirect.wast:516
586 assert_return(() => invoke($0, `dispatch-structural-i64`, [13]), [value("i64", 55n)]);
587
588 // ./test/core/call_indirect.wast:517
589 assert_return(() => invoke($0, `dispatch-structural-i64`, [20]), [value("i64", 9n)]);
590
591 // ./test/core/call_indirect.wast:518
592 assert_trap(() => invoke($0, `dispatch-structural-i64`, [11]), `indirect call type mismatch`);
593
594 // ./test/core/call_indirect.wast:519
595 assert_trap(() => invoke($0, `dispatch-structural-i64`, [22]), `indirect call type mismatch`);
596
597 // ./test/core/call_indirect.wast:521
598 assert_return(() => invoke($0, `dispatch-structural-i32`, [4]), [value("i32", 9)]);
599
600 // ./test/core/call_indirect.wast:522
601 assert_return(() => invoke($0, `dispatch-structural-i32`, [23]), [value("i32", 362880)]);
602
603 // ./test/core/call_indirect.wast:523
604 assert_return(() => invoke($0, `dispatch-structural-i32`, [26]), [value("i32", 55)]);
605
606 // ./test/core/call_indirect.wast:524
607 assert_return(() => invoke($0, `dispatch-structural-i32`, [19]), [value("i32", 9)]);
608
609 // ./test/core/call_indirect.wast:525
610 assert_trap(() => invoke($0, `dispatch-structural-i32`, [9]), `indirect call type mismatch`);
611
612 // ./test/core/call_indirect.wast:526
613 assert_trap(() => invoke($0, `dispatch-structural-i32`, [21]), `indirect call type mismatch`);
614
615 // ./test/core/call_indirect.wast:528
616 assert_return(() => invoke($0, `dispatch-structural-f32`, [6]), [value("f32", 9)]);
617
618 // ./test/core/call_indirect.wast:529
619 assert_return(() => invoke($0, `dispatch-structural-f32`, [24]), [value("f32", 362880)]);
620
621 // ./test/core/call_indirect.wast:530
622 assert_return(() => invoke($0, `dispatch-structural-f32`, [27]), [value("f32", 55)]);
623
624 // ./test/core/call_indirect.wast:531
625 assert_return(() => invoke($0, `dispatch-structural-f32`, [21]), [value("f32", 9)]);
626
627 // ./test/core/call_indirect.wast:532
628 assert_trap(() => invoke($0, `dispatch-structural-f32`, [8]), `indirect call type mismatch`);
629
630 // ./test/core/call_indirect.wast:533
631 assert_trap(() => invoke($0, `dispatch-structural-f32`, [19]), `indirect call type mismatch`);
632
633 // ./test/core/call_indirect.wast:535
634 assert_return(() => invoke($0, `dispatch-structural-f64`, [7]), [value("f64", 9)]);
635
636 // ./test/core/call_indirect.wast:536
637 assert_return(() => invoke($0, `dispatch-structural-f64`, [25]), [value("f64", 362880)]);
638
639 // ./test/core/call_indirect.wast:537
640 assert_return(() => invoke($0, `dispatch-structural-f64`, [28]), [value("f64", 55)]);
641
642 // ./test/core/call_indirect.wast:538
643 assert_return(() => invoke($0, `dispatch-structural-f64`, [22]), [value("f64", 9)]);
644
645 // ./test/core/call_indirect.wast:539
646 assert_trap(() => invoke($0, `dispatch-structural-f64`, [10]), `indirect call type mismatch`);
647
648 // ./test/core/call_indirect.wast:540
649 assert_trap(() => invoke($0, `dispatch-structural-f64`, [18]), `indirect call type mismatch`);
650
651 // ./test/core/call_indirect.wast:542
652 assert_return(() => invoke($0, `fac-i64`, [0n]), [value("i64", 1n)]);
653
654 // ./test/core/call_indirect.wast:543
655 assert_return(() => invoke($0, `fac-i64`, [1n]), [value("i64", 1n)]);
656
657 // ./test/core/call_indirect.wast:544
658 assert_return(() => invoke($0, `fac-i64`, [5n]), [value("i64", 120n)]);
659
660 // ./test/core/call_indirect.wast:545
661 assert_return(() => invoke($0, `fac-i64`, [25n]), [value("i64", 7034535277573963776n)]);
662
663 // ./test/core/call_indirect.wast:547
664 assert_return(() => invoke($0, `fac-i32`, [0]), [value("i32", 1)]);
665
666 // ./test/core/call_indirect.wast:548
667 assert_return(() => invoke($0, `fac-i32`, [1]), [value("i32", 1)]);
668
669 // ./test/core/call_indirect.wast:549
670 assert_return(() => invoke($0, `fac-i32`, [5]), [value("i32", 120)]);
671
672 // ./test/core/call_indirect.wast:550
673 assert_return(() => invoke($0, `fac-i32`, [10]), [value("i32", 3628800)]);
674
675 // ./test/core/call_indirect.wast:552
676 assert_return(() => invoke($0, `fac-f32`, [value("f32", 0)]), [value("f32", 1)]);
677
678 // ./test/core/call_indirect.wast:553
679 assert_return(() => invoke($0, `fac-f32`, [value("f32", 1)]), [value("f32", 1)]);
680
681 // ./test/core/call_indirect.wast:554
682 assert_return(() => invoke($0, `fac-f32`, [value("f32", 5)]), [value("f32", 120)]);
683
684 // ./test/core/call_indirect.wast:555
685 assert_return(() => invoke($0, `fac-f32`, [value("f32", 10)]), [value("f32", 3628800)]);
686
687 // ./test/core/call_indirect.wast:557
688 assert_return(() => invoke($0, `fac-f64`, [value("f64", 0)]), [value("f64", 1)]);
689
690 // ./test/core/call_indirect.wast:558
691 assert_return(() => invoke($0, `fac-f64`, [value("f64", 1)]), [value("f64", 1)]);
692
693 // ./test/core/call_indirect.wast:559
694 assert_return(() => invoke($0, `fac-f64`, [value("f64", 5)]), [value("f64", 120)]);
695
696 // ./test/core/call_indirect.wast:560
697 assert_return(() => invoke($0, `fac-f64`, [value("f64", 10)]), [value("f64", 3628800)]);
698
699 // ./test/core/call_indirect.wast:562
700 assert_return(() => invoke($0, `fib-i64`, [0n]), [value("i64", 1n)]);
701
702 // ./test/core/call_indirect.wast:563
703 assert_return(() => invoke($0, `fib-i64`, [1n]), [value("i64", 1n)]);
704
705 // ./test/core/call_indirect.wast:564
706 assert_return(() => invoke($0, `fib-i64`, [2n]), [value("i64", 2n)]);
707
708 // ./test/core/call_indirect.wast:565
709 assert_return(() => invoke($0, `fib-i64`, [5n]), [value("i64", 8n)]);
710
711 // ./test/core/call_indirect.wast:566
712 assert_return(() => invoke($0, `fib-i64`, [20n]), [value("i64", 10946n)]);
713
714 // ./test/core/call_indirect.wast:568
715 assert_return(() => invoke($0, `fib-i32`, [0]), [value("i32", 1)]);
716
717 // ./test/core/call_indirect.wast:569
718 assert_return(() => invoke($0, `fib-i32`, [1]), [value("i32", 1)]);
719
720 // ./test/core/call_indirect.wast:570
721 assert_return(() => invoke($0, `fib-i32`, [2]), [value("i32", 2)]);
722
723 // ./test/core/call_indirect.wast:571
724 assert_return(() => invoke($0, `fib-i32`, [5]), [value("i32", 8)]);
725
726 // ./test/core/call_indirect.wast:572
727 assert_return(() => invoke($0, `fib-i32`, [20]), [value("i32", 10946)]);
728
729 // ./test/core/call_indirect.wast:574
730 assert_return(() => invoke($0, `fib-f32`, [value("f32", 0)]), [value("f32", 1)]);
731
732 // ./test/core/call_indirect.wast:575
733 assert_return(() => invoke($0, `fib-f32`, [value("f32", 1)]), [value("f32", 1)]);
734
735 // ./test/core/call_indirect.wast:576
736 assert_return(() => invoke($0, `fib-f32`, [value("f32", 2)]), [value("f32", 2)]);
737
738 // ./test/core/call_indirect.wast:577
739 assert_return(() => invoke($0, `fib-f32`, [value("f32", 5)]), [value("f32", 8)]);
740
741 // ./test/core/call_indirect.wast:578
742 assert_return(() => invoke($0, `fib-f32`, [value("f32", 20)]), [value("f32", 10946)]);
743
744 // ./test/core/call_indirect.wast:580
745 assert_return(() => invoke($0, `fib-f64`, [value("f64", 0)]), [value("f64", 1)]);
746
747 // ./test/core/call_indirect.wast:581
748 assert_return(() => invoke($0, `fib-f64`, [value("f64", 1)]), [value("f64", 1)]);
749
750 // ./test/core/call_indirect.wast:582
751 assert_return(() => invoke($0, `fib-f64`, [value("f64", 2)]), [value("f64", 2)]);
752
753 // ./test/core/call_indirect.wast:583
754 assert_return(() => invoke($0, `fib-f64`, [value("f64", 5)]), [value("f64", 8)]);
755
756 // ./test/core/call_indirect.wast:584
757 assert_return(() => invoke($0, `fib-f64`, [value("f64", 20)]), [value("f64", 10946)]);
758
759 // ./test/core/call_indirect.wast:586
760 assert_return(() => invoke($0, `even`, [0]), [value("i32", 44)]);
761
762 // ./test/core/call_indirect.wast:587
763 assert_return(() => invoke($0, `even`, [1]), [value("i32", 99)]);
764
765 // ./test/core/call_indirect.wast:588
766 assert_return(() => invoke($0, `even`, [100]), [value("i32", 44)]);
767
768 // ./test/core/call_indirect.wast:589
769 assert_return(() => invoke($0, `even`, [77]), [value("i32", 99)]);
770
771 // ./test/core/call_indirect.wast:590
772 assert_return(() => invoke($0, `odd`, [0]), [value("i32", 99)]);
773
774 // ./test/core/call_indirect.wast:591
775 assert_return(() => invoke($0, `odd`, [1]), [value("i32", 44)]);
776
777 // ./test/core/call_indirect.wast:592
778 assert_return(() => invoke($0, `odd`, [200]), [value("i32", 99)]);
779
780 // ./test/core/call_indirect.wast:593
781 assert_return(() => invoke($0, `odd`, [77]), [value("i32", 44)]);
782
783 // ./test/core/call_indirect.wast:595
784 assert_exhaustion(() => invoke($0, `runaway`, []), `call stack exhausted`);
785
786 // ./test/core/call_indirect.wast:596
787 assert_exhaustion(() => invoke($0, `mutual-runaway`, []), `call stack exhausted`);
788
789 // ./test/core/call_indirect.wast:598
790 assert_return(() => invoke($0, `as-select-first`, []), [value("i32", 306)]);
791
792 // ./test/core/call_indirect.wast:599
793 assert_return(() => invoke($0, `as-select-mid`, []), [value("i32", 2)]);
794
795 // ./test/core/call_indirect.wast:600
796 assert_return(() => invoke($0, `as-select-last`, []), [value("i32", 2)]);
797
798 // ./test/core/call_indirect.wast:602
799 assert_return(() => invoke($0, `as-if-condition`, []), [value("i32", 1)]);
800
801 // ./test/core/call_indirect.wast:604
802 assert_return(() => invoke($0, `as-br_if-first`, []), [value("i64", 356n)]);
803
804 // ./test/core/call_indirect.wast:605
805 assert_return(() => invoke($0, `as-br_if-last`, []), [value("i32", 2)]);
806
807 // ./test/core/call_indirect.wast:607
808 assert_return(() => invoke($0, `as-br_table-first`, []), [value("f32", 3890)]);
809
810 // ./test/core/call_indirect.wast:608
811 assert_return(() => invoke($0, `as-br_table-last`, []), [value("i32", 2)]);
812
813 // ./test/core/call_indirect.wast:610
814 assert_return(() => invoke($0, `as-store-first`, []), []);
815
816 // ./test/core/call_indirect.wast:611
817 assert_return(() => invoke($0, `as-store-last`, []), []);
818
819 // ./test/core/call_indirect.wast:613
820 assert_return(() => invoke($0, `as-memory.grow-value`, []), [value("i32", 1)]);
821
822 // ./test/core/call_indirect.wast:614
823 assert_return(() => invoke($0, `as-return-value`, []), [value("i32", 1)]);
824
825 // ./test/core/call_indirect.wast:615
826 assert_return(() => invoke($0, `as-drop-operand`, []), []);
827
828 // ./test/core/call_indirect.wast:616
829 assert_return(() => invoke($0, `as-br-value`, []), [value("f32", 1)]);
830
831 // ./test/core/call_indirect.wast:617
832 assert_return(() => invoke($0, `as-local.set-value`, []), [value("f64", 1)]);
833
834 // ./test/core/call_indirect.wast:618
835 assert_return(() => invoke($0, `as-local.tee-value`, []), [value("f64", 1)]);
836
837 // ./test/core/call_indirect.wast:619
838 assert_return(() => invoke($0, `as-global.set-value`, []), [value("f64", 1)]);
839
840 // ./test/core/call_indirect.wast:620
841 assert_return(() => invoke($0, `as-load-operand`, []), [value("i32", 1)]);
842
843 // ./test/core/call_indirect.wast:622
844 assert_return(() => invoke($0, `as-unary-operand`, []), [value("f32", 0)]);
845
846 // ./test/core/call_indirect.wast:623
847 assert_return(() => invoke($0, `as-binary-left`, []), [value("i32", 11)]);
848
849 // ./test/core/call_indirect.wast:624
850 assert_return(() => invoke($0, `as-binary-right`, []), [value("i32", 9)]);
851
852 // ./test/core/call_indirect.wast:625
853 assert_return(() => invoke($0, `as-test-operand`, []), [value("i32", 0)]);
854
855 // ./test/core/call_indirect.wast:626
856 assert_return(() => invoke($0, `as-compare-left`, []), [value("i32", 1)]);
857
858 // ./test/core/call_indirect.wast:627
859 assert_return(() => invoke($0, `as-compare-right`, []), [value("i32", 1)]);
860
861 // ./test/core/call_indirect.wast:628
862 assert_return(() => invoke($0, `as-convert-operand`, []), [value("i64", 1n)]);
863
864 // ./test/core/call_indirect.wast:633
865 let $1 = instantiate(`(module
866 (type $$ii-i (func (param i32 i32) (result i32)))
867
868 (table $$t1 funcref (elem $$f $$g))
869 (table $$t2 funcref (elem $$h $$i $$j))
870 (table $$t3 4 funcref)
871 (elem (table $$t3) (i32.const 0) func $$g $$h)
872 (elem (table $$t3) (i32.const 3) func $$z)
873
874 (func $$f (type $$ii-i) (i32.add (local.get 0) (local.get 1)))
875 (func $$g (type $$ii-i) (i32.sub (local.get 0) (local.get 1)))
876 (func $$h (type $$ii-i) (i32.mul (local.get 0) (local.get 1)))
877 (func $$i (type $$ii-i) (i32.div_u (local.get 0) (local.get 1)))
878 (func $$j (type $$ii-i) (i32.rem_u (local.get 0) (local.get 1)))
879 (func $$z)
880
881 (func (export "call-1") (param i32 i32 i32) (result i32)
882 (call_indirect $$t1 (type $$ii-i) (local.get 0) (local.get 1) (local.get 2))
883 )
884 (func (export "call-2") (param i32 i32 i32) (result i32)
885 (call_indirect $$t2 (type $$ii-i) (local.get 0) (local.get 1) (local.get 2))
886 )
887 (func (export "call-3") (param i32 i32 i32) (result i32)
888 (call_indirect $$t3 (type $$ii-i) (local.get 0) (local.get 1) (local.get 2))
889 )
890 )`);
891
892 // ./test/core/call_indirect.wast:660
893 assert_return(() => invoke($1, `call-1`, [2, 3, 0]), [value("i32", 5)]);
894
895 // ./test/core/call_indirect.wast:661
896 assert_return(() => invoke($1, `call-1`, [2, 3, 1]), [value("i32", -1)]);
897
898 // ./test/core/call_indirect.wast:662
899 assert_trap(() => invoke($1, `call-1`, [2, 3, 2]), `undefined element`);
900
901 // ./test/core/call_indirect.wast:664
902 assert_return(() => invoke($1, `call-2`, [2, 3, 0]), [value("i32", 6)]);
903
904 // ./test/core/call_indirect.wast:665
905 assert_return(() => invoke($1, `call-2`, [2, 3, 1]), [value("i32", 0)]);
906
907 // ./test/core/call_indirect.wast:666
908 assert_return(() => invoke($1, `call-2`, [2, 3, 2]), [value("i32", 2)]);
909
910 // ./test/core/call_indirect.wast:667
911 assert_trap(() => invoke($1, `call-2`, [2, 3, 3]), `undefined element`);
912
913 // ./test/core/call_indirect.wast:669
914 assert_return(() => invoke($1, `call-3`, [2, 3, 0]), [value("i32", -1)]);
915
916 // ./test/core/call_indirect.wast:670
917 assert_return(() => invoke($1, `call-3`, [2, 3, 1]), [value("i32", 6)]);
918
919 // ./test/core/call_indirect.wast:671
920 assert_trap(() => invoke($1, `call-3`, [2, 3, 2]), `uninitialized element`);
921
922 // ./test/core/call_indirect.wast:672
923 assert_trap(() => invoke($1, `call-3`, [2, 3, 3]), `indirect call type mismatch`);
924
925 // ./test/core/call_indirect.wast:673
926 assert_trap(() => invoke($1, `call-3`, [2, 3, 4]), `undefined element`);
927
928 // ./test/core/call_indirect.wast:678
929 assert_malformed(
930 () => instantiate(`(type $$sig (func (param i32) (result i32))) (table 0 funcref) (func (result i32) (call_indirect (type $$sig) (result i32) (param i32) (i32.const 0) (i32.const 0) ) ) `),
931 `unexpected token`,
932 );
933
934 // ./test/core/call_indirect.wast:690
935 assert_malformed(
936 () => instantiate(`(type $$sig (func (param i32) (result i32))) (table 0 funcref) (func (result i32) (call_indirect (param i32) (type $$sig) (result i32) (i32.const 0) (i32.const 0) ) ) `),
937 `unexpected token`,
938 );
939
940 // ./test/core/call_indirect.wast:702
941 assert_malformed(
942 () => instantiate(`(type $$sig (func (param i32) (result i32))) (table 0 funcref) (func (result i32) (call_indirect (param i32) (result i32) (type $$sig) (i32.const 0) (i32.const 0) ) ) `),
943 `unexpected token`,
944 );
945
946 // ./test/core/call_indirect.wast:714
947 assert_malformed(
948 () => instantiate(`(type $$sig (func (param i32) (result i32))) (table 0 funcref) (func (result i32) (call_indirect (result i32) (type $$sig) (param i32) (i32.const 0) (i32.const 0) ) ) `),
949 `unexpected token`,
950 );
951
952 // ./test/core/call_indirect.wast:726
953 assert_malformed(
954 () => instantiate(`(type $$sig (func (param i32) (result i32))) (table 0 funcref) (func (result i32) (call_indirect (result i32) (param i32) (type $$sig) (i32.const 0) (i32.const 0) ) ) `),
955 `unexpected token`,
956 );
957
958 // ./test/core/call_indirect.wast:738
959 assert_malformed(
960 () => instantiate(`(table 0 funcref) (func (result i32) (call_indirect (result i32) (param i32) (i32.const 0) (i32.const 0)) ) `),
961 `unexpected token`,
962 );
963
964 // ./test/core/call_indirect.wast:748
965 assert_malformed(
966 () => instantiate(`(table 0 funcref) (func (call_indirect (param $$x i32) (i32.const 0) (i32.const 0))) `),
967 `unexpected token`,
968 );
969
970 // ./test/core/call_indirect.wast:755
971 assert_malformed(
972 () => instantiate(`(type $$sig (func)) (table 0 funcref) (func (result i32) (call_indirect (type $$sig) (result i32) (i32.const 0)) ) `),
973 `inline function type`,
974 );
975
976 // ./test/core/call_indirect.wast:765
977 assert_malformed(
978 () => instantiate(`(type $$sig (func (param i32) (result i32))) (table 0 funcref) (func (result i32) (call_indirect (type $$sig) (result i32) (i32.const 0)) ) `),
979 `inline function type`,
980 );
981
982 // ./test/core/call_indirect.wast:775
983 assert_malformed(
984 () => instantiate(`(type $$sig (func (param i32) (result i32))) (table 0 funcref) (func (call_indirect (type $$sig) (param i32) (i32.const 0) (i32.const 0)) ) `),
985 `inline function type`,
986 );
987
988 // ./test/core/call_indirect.wast:785
989 assert_malformed(
990 () => instantiate(`(type $$sig (func (param i32 i32) (result i32))) (table 0 funcref) (func (result i32) (call_indirect (type $$sig) (param i32) (result i32) (i32.const 0) (i32.const 0) ) ) `),
991 `inline function type`,
992 );
993
994 // ./test/core/call_indirect.wast:800
995 assert_invalid(
996 () => instantiate(`(module
997 (type (func))
998 (func $$no-table (call_indirect (type 0) (i32.const 0)))
999 )`),
1000 `unknown table`,
1001 );
1002
1003 // ./test/core/call_indirect.wast:808
1004 assert_invalid(
1005 () => instantiate(`(module
1006 (type (func))
1007 (table 0 funcref)
1008 (func $$type-void-vs-num (i32.eqz (call_indirect (type 0) (i32.const 0))))
1009 )`),
1010 `type mismatch`,
1011 );
1012
1013 // ./test/core/call_indirect.wast:816
1014 assert_invalid(
1015 () => instantiate(`(module
1016 (type (func (result i64)))
1017 (table 0 funcref)
1018 (func $$type-num-vs-num (i32.eqz (call_indirect (type 0) (i32.const 0))))
1019 )`),
1020 `type mismatch`,
1021 );
1022
1023 // ./test/core/call_indirect.wast:825
1024 assert_invalid(
1025 () => instantiate(`(module
1026 (type (func (param i32)))
1027 (table 0 funcref)
1028 (func $$arity-0-vs-1 (call_indirect (type 0) (i32.const 0)))
1029 )`),
1030 `type mismatch`,
1031 );
1032
1033 // ./test/core/call_indirect.wast:833
1034 assert_invalid(
1035 () => instantiate(`(module
1036 (type (func (param f64 i32)))
1037 (table 0 funcref)
1038 (func $$arity-0-vs-2 (call_indirect (type 0) (i32.const 0)))
1039 )`),
1040 `type mismatch`,
1041 );
1042
1043 // ./test/core/call_indirect.wast:841
1044 assert_invalid(
1045 () => instantiate(`(module
1046 (type (func))
1047 (table 0 funcref)
1048 (func $$arity-1-vs-0 (call_indirect (type 0) (i32.const 1) (i32.const 0)))
1049 )`),
1050 `type mismatch`,
1051 );
1052
1053 // ./test/core/call_indirect.wast:849
1054 assert_invalid(
1055 () => instantiate(`(module
1056 (type (func))
1057 (table 0 funcref)
1058 (func $$arity-2-vs-0
1059 (call_indirect (type 0) (f64.const 2) (i32.const 1) (i32.const 0))
1060 )
1061 )`),
1062 `type mismatch`,
1063 );
1064
1065 // ./test/core/call_indirect.wast:860
1066 assert_invalid(
1067 () => instantiate(`(module
1068 (type (func (param i32)))
1069 (table 0 funcref)
1070 (func $$type-func-void-vs-i32 (call_indirect (type 0) (i32.const 1) (nop)))
1071 )`),
1072 `type mismatch`,
1073 );
1074
1075 // ./test/core/call_indirect.wast:868
1076 assert_invalid(
1077 () => instantiate(`(module
1078 (type (func (param i32)))
1079 (table 0 funcref)
1080 (func $$type-func-num-vs-i32 (call_indirect (type 0) (i32.const 0) (i64.const 1)))
1081 )`),
1082 `type mismatch`,
1083 );
1084
1085 // ./test/core/call_indirect.wast:877
1086 assert_invalid(
1087 () => instantiate(`(module
1088 (type (func (param i32 i32)))
1089 (table 0 funcref)
1090 (func $$type-first-void-vs-num
1091 (call_indirect (type 0) (nop) (i32.const 1) (i32.const 0))
1092 )
1093 )`),
1094 `type mismatch`,
1095 );
1096
1097 // ./test/core/call_indirect.wast:887
1098 assert_invalid(
1099 () => instantiate(`(module
1100 (type (func (param i32 i32)))
1101 (table 0 funcref)
1102 (func $$type-second-void-vs-num
1103 (call_indirect (type 0) (i32.const 1) (nop) (i32.const 0))
1104 )
1105 )`),
1106 `type mismatch`,
1107 );
1108
1109 // ./test/core/call_indirect.wast:897
1110 assert_invalid(
1111 () => instantiate(`(module
1112 (type (func (param i32 f64)))
1113 (table 0 funcref)
1114 (func $$type-first-num-vs-num
1115 (call_indirect (type 0) (f64.const 1) (i32.const 1) (i32.const 0))
1116 )
1117 )`),
1118 `type mismatch`,
1119 );
1120
1121 // ./test/core/call_indirect.wast:907
1122 assert_invalid(
1123 () => instantiate(`(module
1124 (type (func (param f64 i32)))
1125 (table 0 funcref)
1126 (func $$type-second-num-vs-num
1127 (call_indirect (type 0) (i32.const 1) (f64.const 1) (i32.const 0))
1128 )
1129 )`),
1130 `type mismatch`,
1131 );
1132
1133 // ./test/core/call_indirect.wast:918
1134 assert_invalid(
1135 () => instantiate(`(module
1136 (func $$f (param i32))
1137 (type $$sig (func (param i32)))
1138 (table funcref (elem $$f))
1139 (func $$type-first-empty-in-block
1140 (block
1141 (call_indirect (type $$sig) (i32.const 0))
1142 )
1143 )
1144 )`),
1145 `type mismatch`,
1146 );
1147
1148 // ./test/core/call_indirect.wast:931
1149 assert_invalid(
1150 () => instantiate(`(module
1151 (func $$f (param i32 i32))
1152 (type $$sig (func (param i32 i32)))
1153 (table funcref (elem $$f))
1154 (func $$type-second-empty-in-block
1155 (block
1156 (call_indirect (type $$sig) (i32.const 0) (i32.const 0))
1157 )
1158 )
1159 )`),
1160 `type mismatch`,
1161 );
1162
1163 // ./test/core/call_indirect.wast:944
1164 assert_invalid(
1165 () => instantiate(`(module
1166 (func $$f (param i32))
1167 (type $$sig (func (param i32)))
1168 (table funcref (elem $$f))
1169 (func $$type-first-empty-in-loop
1170 (loop
1171 (call_indirect (type $$sig) (i32.const 0))
1172 )
1173 )
1174 )`),
1175 `type mismatch`,
1176 );
1177
1178 // ./test/core/call_indirect.wast:957
1179 assert_invalid(
1180 () => instantiate(`(module
1181 (func $$f (param i32 i32))
1182 (type $$sig (func (param i32 i32)))
1183 (table funcref (elem $$f))
1184 (func $$type-second-empty-in-loop
1185 (loop
1186 (call_indirect (type $$sig) (i32.const 0) (i32.const 0))
1187 )
1188 )
1189 )`),
1190 `type mismatch`,
1191 );
1192
1193 // ./test/core/call_indirect.wast:970
1194 assert_invalid(
1195 () => instantiate(`(module
1196 (func $$f (param i32))
1197 (type $$sig (func (param i32)))
1198 (table funcref (elem $$f))
1199 (func $$type-first-empty-in-then
1200 (i32.const 0) (i32.const 0)
1201 (if
1202 (then
1203 (call_indirect (type $$sig) (i32.const 0))
1204 )
1205 )
1206 )
1207 )`),
1208 `type mismatch`,
1209 );
1210
1211 // ./test/core/call_indirect.wast:986
1212 assert_invalid(
1213 () => instantiate(`(module
1214 (func $$f (param i32 i32))
1215 (type $$sig (func (param i32 i32)))
1216 (table funcref (elem $$f))
1217 (func $$type-second-empty-in-then
1218 (i32.const 0) (i32.const 0)
1219 (if
1220 (then
1221 (call_indirect (type $$sig) (i32.const 0) (i32.const 0))
1222 )
1223 )
1224 )
1225 )`),
1226 `type mismatch`,
1227 );
1228
1229 // ./test/core/call_indirect.wast:1006
1230 assert_invalid(
1231 () => instantiate(`(module
1232 (table 0 funcref)
1233 (func $$unbound-type (call_indirect (type 1) (i32.const 0)))
1234 )`),
1235 `unknown type`,
1236 );
1237
1238 // ./test/core/call_indirect.wast:1013
1239 assert_invalid(
1240 () => instantiate(`(module
1241 (table 0 funcref)
1242 (func $$large-type (call_indirect (type 1012321300) (i32.const 0)))
1243 )`),
1244 `unknown type`,
1245 );
1246
1247 // ./test/core/call_indirect.wast:1024
1248 assert_invalid(
1249 () => instantiate(`(module (table funcref (elem 0 0)))`),
1250 `unknown function`,
1251 );
1252
1253 // ./test/core/call_indirect.wast:1034
1254 let $2 = instantiate(`(module
1255 (table 1 funcref)
1256 (func unreachable call_indirect)
1257 (func unreachable call_indirect nop)
1258 (func unreachable call_indirect call_indirect)
1259 (func unreachable call_indirect (call_indirect))
1260 (func unreachable call_indirect call_indirect call_indirect)
1261 (func unreachable call_indirect (result))
1262 (func unreachable call_indirect (result) (result))
1263 (func unreachable call_indirect (result) (result) call_indirect)
1264 (func unreachable call_indirect (result) (result) call_indirect (result))
1265 (func (result i32) unreachable call_indirect select)
1266 (func (result i32) unreachable call_indirect select call_indirect)
1267 )`);