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: --ignition-staging --turbo --no-always-opt | 6 // Flags: --ignition-staging --turbo --no-always-opt |
7 | 7 |
| 8 // If we are always or never optimizing it is useless. |
| 9 assertFalse(isAlwaysOptimize()); |
| 10 assertFalse(isNeverOptimize()); |
| 11 |
8 (function() { | 12 (function() { |
9 var sum = 0; | 13 var sum = 0; |
10 var i = 0; | 14 var i = 0; |
11 for (var i = 0; i < 3; ++i) { | 15 for (var i = 0; i < 3; ++i) { |
12 var f = function(x) { | 16 var f = function(x) { |
13 return 2 * x; | 17 return 2 * x; |
14 } | 18 } |
15 sum += f(i); | 19 sum += f(i); |
16 | 20 |
17 if (%GetOptimizationStatus(f) == 3 || %GetOptimizationStatus(f) == 4) { | |
18 // If we are always or never optimizing f, just exit, this test is useless
. | |
19 return; | |
20 } | |
21 | |
22 if (i == 1) { | 21 if (i == 1) { |
23 // f must be interpreted code. | 22 // f must be interpreted code. |
24 assertEquals(8, %GetOptimizationStatus(f)); | 23 assertTrue(isInterpreted(f)); |
25 | 24 |
26 // Run twice (i = 0, 1), then tier-up. | 25 // Run twice (i = 0, 1), then tier-up. |
27 %OptimizeFunctionOnNextCall(f); | 26 %OptimizeFunctionOnNextCall(f); |
28 } else if (i == 2) { | 27 } else if (i == 2) { |
29 // Tier-up at i = 2 should go up to turbofan. | 28 // Tier-up at i = 2 should go up to turbofan. |
30 assertEquals(7, %GetOptimizationStatus(f)); | 29 assertTrue(isTurboFanned(f)); |
31 } | 30 } |
32 } | 31 } |
33 })() | 32 })() |
OLD | NEW |