summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/trap-exit-stack-alignment.js
blob: 2d953e04a948a5f34502530385fd4d83183dc3e5 (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
// Function with high register pressure to force spills without function calls
// even on ARM64, and with a trap exit.
let func = wasmEvalText(`(module
    (func
        (param i32)
        (result i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local i32)
        (local.set 2 (i32.add (local.get 0 i32.const 4)))
        (local.set 3 (i32.add (local.get 0 i32.const 5)))
        (local.set 4 (i32.add (local.get 0 i32.const 6)))
        (local.set 5 (i32.add (local.get 0 i32.const 7)))
        (local.set 6 (i32.add (local.get 0 i32.const 8)))
        (local.set 7 (i32.add (local.get 0 i32.const 9)))
        (local.set 8 (i32.add (local.get 0 i32.const 10)))
        (local.set 9 (i32.add (local.get 0 i32.const 11)))
        (local.set 10 (i32.add (local.get 0 i32.const 12)))
        (local.set 11 (i32.add (local.get 0 i32.const 13)))
        (local.set 12 (i32.add (local.get 0 i32.const 14)))
        (local.set 13 (i32.add (local.get 0 i32.const 15)))
        (local.set 14 (i32.add (local.get 0 i32.const 16)))
        (local.set 15 (i32.add (local.get 0 i32.const 17)))
        (local.set 16 (i32.add (local.get 0 i32.const 18)))
        (local.set 17 (i32.add (local.get 0 i32.const 19)))
        (local.set 18 (i32.add (local.get 0 i32.const 20)))
        (local.set 19 (i32.add (local.get 0 i32.const 21)))
        (local.set 20 (i32.add (local.get 0 i32.const 22)))
        (local.set 21 (i32.add (local.get 0 i32.const 23)))
        (local.set 22 (i32.add (local.get 0 i32.const 24)))
        (local.set 23 (i32.add (local.get 0 i32.const 25)))
        (local.set 24 (i32.add (local.get 0 i32.const 26)))
        (local.set 25 (i32.add (local.get 0 i32.const 27)))
        (local.set 26 (i32.add (local.get 0 i32.const 28)))
        (local.set 7 (i32.div_s (local.get 0) (local.get 0)))
        local.get 0
        local.get 1
        local.get 2
        local.get 3
        local.get 4
        local.get 5
        local.get 6
        local.get 7
        local.get 8
        local.get 9
        local.get 10
        local.get 11
        local.get 12
        local.get 13
        local.get 14
        local.get 15
        local.get 16
        local.get 17
        local.get 18
        local.get 19
        local.get 20
        local.get 21
        local.get 22
        local.get 23
        local.get 24
        local.get 25
        local.get 26
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
        i32.add
    )
    (export "" (func 0))
)`).exports[""];
assertEq(func(1), 417);
assertEq(func(2), 442);
let ex;
try {
  func(0);
} catch (e) {
  ex = e;
}
assertEq(ex instanceof WebAssembly.RuntimeError, true);