Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 1 | // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Flags: --allow-natives-syntax |
| 6 | |
| 7 | function f(a, i, bool) { |
| 8 | var result; |
| 9 | if (bool) { |
| 10 | // Make sure i - -0x80000000 doesn't overflow in BCE, missing a check for |
| 11 | // x-0 later on. |
| 12 | result = f2(a, 0x7fffffff, i, i, -0x80000000); |
| 13 | } else { |
| 14 | result = f2(a, -3, 4, i, 0); |
| 15 | } |
| 16 | return result; |
| 17 | } |
| 18 | |
| 19 | function f2(a, c, x, i, d) { |
| 20 | return a[x + c] + a[x - 0] + a[i - d]; |
| 21 | } |
| 22 | |
| 23 | |
| 24 | var a = []; |
| 25 | var i = 0; |
| 26 | a.push(i++); |
| 27 | a.push(i++); |
| 28 | a.push(i++); |
| 29 | a.push(i++); |
| 30 | a.push(i++); |
| 31 | f(a, 0, false); |
| 32 | f(a, 0, false); |
| 33 | f(a, 0, false); |
| 34 | %OptimizeFunctionOnNextCall(f); |
| 35 | %DebugPrint(f(a, -0x7fffffff, true)); |