OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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() { |
| 8 function foo(x) { |
| 9 x = x | 0; |
| 10 return Number.parseInt(x + 1); |
| 11 } |
| 12 |
| 13 assertEquals(1, foo(0)); |
| 14 assertEquals(2, foo(1)); |
| 15 %OptimizeFunctionOnNextCall(foo); |
| 16 assertEquals(Math.pow(2, 31), foo(Math.pow(2, 31) - 1)); |
| 17 })(); |
| 18 |
| 19 (function() { |
| 20 function foo(x) { |
| 21 x = x | 0; |
| 22 return Number.parseInt(x + 1, 0); |
| 23 } |
| 24 |
| 25 assertEquals(1, foo(0)); |
| 26 assertEquals(2, foo(1)); |
| 27 %OptimizeFunctionOnNextCall(foo); |
| 28 assertEquals(Math.pow(2, 31), foo(Math.pow(2, 31) - 1)); |
| 29 })(); |
| 30 |
| 31 (function() { |
| 32 function foo(x) { |
| 33 x = x | 0; |
| 34 return Number.parseInt(x + 1, 10); |
| 35 } |
| 36 |
| 37 assertEquals(1, foo(0)); |
| 38 assertEquals(2, foo(1)); |
| 39 %OptimizeFunctionOnNextCall(foo); |
| 40 assertEquals(Math.pow(2, 31), foo(Math.pow(2, 31) - 1)); |
| 41 })(); |
| 42 |
| 43 (function() { |
| 44 function foo(x) { |
| 45 x = x | 0; |
| 46 return Number.parseInt(x + 1, undefined); |
| 47 } |
| 48 |
| 49 assertEquals(1, foo(0)); |
| 50 assertEquals(2, foo(1)); |
| 51 %OptimizeFunctionOnNextCall(foo); |
| 52 assertEquals(Math.pow(2, 31), foo(Math.pow(2, 31) - 1)); |
| 53 })(); |
OLD | NEW |