| 1 |
// Bug 1316181 |
| 2 |
|
| 3 |
// There are locals with different values here to ensure that the |
| 4 |
// local.get at the end picks up the right one even if the stack might |
| 5 |
// have become unbalanced by a failure to adjust SP along the branch |
| 6 |
// edge. The logic is that we use SP-relative addressing, and if the |
| 7 |
// actual SP is not what the compiler thinks it is we will read |
| 8 |
// something other than the expected value. |
| 9 |
|
| 10 |
var o = wasmEvalText( |
| 11 |
`(module |
| 12 |
(func (result i32) |
| 13 |
(local $v0 i32) |
| 14 |
(local $v1 i32) |
| 15 |
(local $v2 i32) |
| 16 |
(local $v3 i32) |
| 17 |
(local $v4 i32) |
| 18 |
(local $v5 i32) |
| 19 |
(local $v6 i32) |
| 20 |
(local $v7 i32) |
| 21 |
(local $res i32) |
| 22 |
(local.set $v0 (i32.const 0xDEADBEEF)) |
| 23 |
(local.set $v1 (i32.const 0xFDEADBEE)) |
| 24 |
(local.set $v2 (i32.const 0xEFDEADBE)) |
| 25 |
(local.set $v3 (i32.const 0xEEFDEADB)) |
| 26 |
(local.set $v4 (i32.const 0xBEEFDEAD)) |
| 27 |
(local.set $v5 (i32.const 0xDBEEFDEA)) |
| 28 |
(local.set $v6 (i32.const 0xADBEEFDE)) |
| 29 |
(local.set $v7 (i32.const 0xEADBEEFD)) |
| 30 |
(block $b |
| 31 |
(local.set $res |
| 32 |
(i32.add |
| 33 |
(i32.add (i32.const 1) (i32.const 2)) |
| 34 |
(i32.add |
| 35 |
(i32.add (i32.const 3) (i32.const 4)) |
| 36 |
(i32.add |
| 37 |
(i32.add (i32.const 5) (i32.const 6)) |
| 38 |
(i32.add |
| 39 |
(i32.add (i32.const 7) (i32.const 8)) |
| 40 |
(i32.add |
| 41 |
(i32.add (i32.const 9) (i32.const 10)) |
| 42 |
(i32.add |
| 43 |
(i32.add (i32.const 11) (i32.const 12)) |
| 44 |
(i32.add |
| 45 |
(i32.add (i32.const 13) (i32.const 14)) |
| 46 |
(i32.add |
| 47 |
(i32.add (i32.const 15) (i32.const 16)) |
| 48 |
(i32.add |
| 49 |
(i32.add (i32.const 17) (i32.const 18)) |
| 50 |
(i32.add |
| 51 |
(i32.add (i32.const 19) (i32.const 20)) |
| 52 |
(i32.add |
| 53 |
(i32.add (i32.const 21) (i32.const 22)) |
| 54 |
(i32.add |
| 55 |
(i32.add (i32.const 23) (i32.const 24)) |
| 56 |
(i32.add |
| 57 |
(i32.add (i32.const 25) (i32.const 26)) |
| 58 |
(i32.add |
| 59 |
(i32.add (i32.const 27) (i32.const 28)) |
| 60 |
(i32.add |
| 61 |
(i32.add (i32.const 29) (i32.const 30)) |
| 62 |
(br_if $b (i32.const 31) (i32.const 1))))))))))))))))))) |
| 63 |
(return (local.get $v3))) |
| 64 |
(export "a" (func 0)))`).exports; |
| 65 |
|
| 66 |
assertEq(o["a"](), 0xEEFDEADB|0); |