Debian Codegraph @

js/src/jit-test/tests/wasm/tail-calls/litmus15.js

raw
1 // On systems with up to four register arguments, this alternately grows and then shrinks
2 // the stack frame across tail call boundaries. All functions are in the same
3 // module.
4
5 var ins = wasmEvalText(`
6 (module
7 (type $ty0 (func (result i32)))
8 (type $ty1 (func (param i32) (result i32)))
9 (type $ty2 (func (param i32 i32) (result i32)))
10 (type $ty3 (func (param i32 i32 i32) (result i32)))
11 (type $ty4 (func (param i32 i32 i32 i32) (result i32)))
12 (type $ty5 (func (param i32 i32 i32 i32 i32) (result i32)))
13 (type $ty6 (func (param i32 i32 i32 i32 i32 i32) (result i32)))
14 (type $ty7 (func (param i32 i32 i32 i32 i32 i32 i32) (result i32)))
15 (type $ty8 (func (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32)))
16 (type $ty9 (func (param i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32)))
17
18 (table $t 10 10 funcref)
19 (elem (table $t) (i32.const 0) func $f $g $h $i $j $k $l $m $n $o)
20
21 (global $glob (mut i32) (i32.const ${TailCallIterations}))
22
23 (func $o (param i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32)
24 (if (result i32) (i32.eqz (global.get $glob))
25 (then
26 (i32.or (i32.const 512)
27 (i32.or (local.get 0)
28 (i32.or (local.get 1)
29 (i32.or (local.get 2)
30 (i32.or (local.get 3)
31 (i32.or (local.get 4)
32 (i32.or (local.get 5)
33 (i32.or (local.get 6)
34 (i32.or (local.get 7) (local.get 8)))))))))))
35 (else
36 (block (result i32)
37 (global.set $glob (i32.sub (global.get $glob) (i32.const 1)))
38 (return_call_indirect (type $ty0) (i32.const 0))))))
39
40 (func $n (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32)
41 (return_call_indirect (type $ty9) (i32.const 256) (local.get 0) (local.get 1) (local.get 2) (local.get 3) (local.get 4) (local.get 5) (local.get 6) (local.get 7) (i32.const 9)))
42
43 (func $m (param i32 i32 i32 i32 i32 i32 i32) (result i32)
44 (return_call_indirect (type $ty8) (i32.const 128) (local.get 0) (local.get 1) (local.get 2) (local.get 3) (local.get 4) (local.get 5) (local.get 6) (i32.const 8)))
45
46 (func $l (param i32 i32 i32 i32 i32 i32) (result i32)
47 (return_call_indirect (type $ty7) (i32.const 64) (local.get 0) (local.get 1) (local.get 2) (local.get 3) (local.get 4) (local.get 5) (i32.const 7)))
48
49 (func $k (param i32 i32 i32 i32 i32) (result i32)
50 (return_call_indirect (type $ty6) (i32.const 32) (local.get 0) (local.get 1) (local.get 2) (local.get 3) (local.get 4) (i32.const 6)))
51
52 (func $j (param i32 i32 i32 i32) (result i32)
53 (return_call_indirect (type $ty5) (i32.const 16) (local.get 0) (local.get 1) (local.get 2) (local.get 3) (i32.const 5)))
54
55 (func $i (param i32 i32 i32) (result i32)
56 (return_call_indirect (type $ty4) (i32.const 8) (local.get 0) (local.get 1) (local.get 2) (i32.const 4)))
57
58 (func $h (param i32 i32) (result i32)
59 (return_call_indirect (type $ty3) (i32.const 4) (local.get 0) (local.get 1) (i32.const 3)))
60
61 (func $g (param i32) (result i32)
62 (return_call_indirect (type $ty2) (i32.const 2) (local.get 0) (i32.const 2)))
63
64 (func $f (export "f") (result i32)
65 (return_call_indirect (type $ty1) (i32.const 1) (i32.const 1))))`);
66
67 assertEq(ins.exports.f(), 1023);
68 print("OK")
69
70