2017-02-14 11:27:26 +01:00
|
|
|
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
//
|
2017-05-02 10:50:00 +02:00
|
|
|
// Flags: --mark-shared-functions-for-tier-up --allow-natives-syntax
|
2022-09-21 13:28:42 +02:00
|
|
|
// Flags: --turbofan --no-always-turbofan --turbo-filter=*
|
2017-05-02 10:50:00 +02:00
|
|
|
|
|
|
|
// If we are always or never optimizing it is useless.
|
2019-03-12 09:01:49 +01:00
|
|
|
if (isNeverOptimizeLiteMode()) {
|
|
|
|
print("Warning: skipping test that requires optimization in Lite mode.");
|
2019-05-28 08:46:21 -04:00
|
|
|
testRunner.quit(0);
|
2019-03-12 09:01:49 +01:00
|
|
|
}
|
2017-05-02 10:50:00 +02:00
|
|
|
assertFalse(isAlwaysOptimize());
|
|
|
|
assertFalse(isNeverOptimize());
|
2017-02-14 11:27:26 +01:00
|
|
|
|
|
|
|
(function() {
|
|
|
|
var sum = 0;
|
|
|
|
var i = 0;
|
|
|
|
for (var i = 0; i < 3; ++i) {
|
|
|
|
var f = function(x) {
|
|
|
|
return 2 * x;
|
2019-08-01 08:38:30 +02:00
|
|
|
};
|
|
|
|
%PrepareFunctionForOptimization(f);
|
2017-02-14 11:27:26 +01:00
|
|
|
sum += f(i);
|
|
|
|
|
|
|
|
if (i == 1) {
|
|
|
|
// f must be interpreted code.
|
2023-03-30 12:11:08 +02:00
|
|
|
assertUnoptimized(f);
|
2017-02-14 11:27:26 +01:00
|
|
|
|
|
|
|
// Run twice (i = 0, 1), then tier-up.
|
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
} else if (i == 2) {
|
|
|
|
// Tier-up at i = 2 should go up to turbofan.
|
2023-03-30 12:11:08 +02:00
|
|
|
assertOptimized(f);
|
2017-02-14 11:27:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})()
|