Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 1 | // Copyright 2014 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 | // ----------------------------------------------------------------------------- |
| 8 | |
| 9 | function SmiTaggingCanOverflow(x) { |
| 10 | x = x | 0; |
| 11 | if (x == 0) return; |
| 12 | return x; |
| 13 | } |
| 14 | |
| 15 | SmiTaggingCanOverflow(2147483647); |
| 16 | SmiTaggingCanOverflow(2147483647); |
| 17 | %OptimizeFunctionOnNextCall(SmiTaggingCanOverflow); |
| 18 | assertEquals(2147483647, SmiTaggingCanOverflow(2147483647)); |
| 19 | |
| 20 | // ----------------------------------------------------------------------------- |
| 21 | |
| 22 | function ModILeftCanBeNegative() { |
| 23 | var x = 0; |
| 24 | for (var i = -1; i < 0; ++i) x = i % 2; |
| 25 | return x; |
| 26 | } |
| 27 | |
| 28 | ModILeftCanBeNegative(); |
| 29 | %OptimizeFunctionOnNextCall(ModILeftCanBeNegative); |
| 30 | assertEquals(-1, ModILeftCanBeNegative()); |
| 31 | |
| 32 | // ----------------------------------------------------------------------------- |
| 33 | |
| 34 | function ModIRightCanBeZero() { |
| 35 | var x = 0; |
| 36 | for (var i = -1; i <= 0; ++i) x = (2 % i) | 0; |
| 37 | return x; |
| 38 | } |
| 39 | |
| 40 | ModIRightCanBeZero(); |
| 41 | %OptimizeFunctionOnNextCall(ModIRightCanBeZero); |
| 42 | ModIRightCanBeZero(); |