OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // Flags: --mark-shared-functions-for-tier-up --allow-natives-syntax | 5 // Flags: --mark-shared-functions-for-tier-up --allow-natives-syntax |
6 // Flags: --no-ignition --no-ignition-staging --no-turbo | 6 // Flags: --no-ignition --no-ignition-staging --no-turbo |
7 // Flags: --crankshaft --no-always-opt | 7 // Flags: --crankshaft --no-always-opt |
8 | 8 |
| 9 // If we are always or never optimizing it is useless. |
| 10 assertFalse(isAlwaysOptimize()); |
| 11 assertFalse(isNeverOptimize()); |
| 12 |
9 (function() { | 13 (function() { |
10 var sum = 0; | 14 var sum = 0; |
11 var i = 0; | 15 var i = 0; |
12 for (var i = 0; i < 3; ++i) { | 16 for (var i = 0; i < 3; ++i) { |
13 var f = function(x) { | 17 var f = function(x) { |
14 return 2 * x; | 18 return 2 * x; |
15 } | 19 } |
16 sum += f(i); | 20 sum += f(i); |
17 | 21 |
18 if (%GetOptimizationStatus(f) == 3 || %GetOptimizationStatus(f) == 4) { | |
19 // If we are always or never optimizing f, just exit, this test is useless
. | |
20 return; | |
21 } | |
22 | |
23 if (i == 1) { | 22 if (i == 1) { |
24 // f must be baseline code. | 23 // f must be baseline code. |
25 assertEquals(2, %GetOptimizationStatus(f)); | 24 assertTrue(isBaselined(f)); |
26 | 25 |
27 // Run twice (i = 0, 1), then tier-up. | 26 // Run twice (i = 0, 1), then tier-up. |
28 %OptimizeFunctionOnNextCall(f); | 27 %OptimizeFunctionOnNextCall(f); |
29 } else if (i == 2) { | 28 } else if (i == 2) { |
30 // Tier-up at i = 2 should go up to crankshaft. | 29 // Tier-up at i = 2 should go up to crankshaft. |
31 assertEquals(1, %GetOptimizationStatus(f)); | 30 assertTrue(isCrankshafted(f)); |
32 } | 31 } |
33 } | 32 } |
34 })() | 33 })() |
OLD | NEW |