2018-02-21 11:38:35 +00:00
|
|
|
// Copyright 2018 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.
|
|
|
|
|
|
|
|
// Flags: --allow-natives-syntax --opt --no-always-opt
|
|
|
|
|
|
|
|
(()=> {
|
|
|
|
function f(a) {
|
|
|
|
return Math.abs(a);
|
|
|
|
}
|
2019-05-03 12:48:33 +00:00
|
|
|
%PrepareFunctionForOptimization(f);
|
2018-02-21 11:38:35 +00:00
|
|
|
f(1);
|
|
|
|
f(1);
|
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
f("100");
|
2019-05-03 12:48:33 +00:00
|
|
|
%PrepareFunctionForOptimization(f);
|
2018-02-21 11:38:35 +00:00
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
f("100");
|
|
|
|
assertOptimized(f);
|
|
|
|
})();
|
|
|
|
|
|
|
|
(()=> {
|
|
|
|
function f(a) {
|
|
|
|
return Math.min(1,a);
|
|
|
|
}
|
2019-05-03 12:48:33 +00:00
|
|
|
%PrepareFunctionForOptimization(f);
|
2018-02-21 11:38:35 +00:00
|
|
|
f(1);
|
|
|
|
f(1);
|
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
f("100");
|
2019-05-03 12:48:33 +00:00
|
|
|
%PrepareFunctionForOptimization(f);
|
2018-02-21 11:38:35 +00:00
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
f("100");
|
|
|
|
assertOptimized(f);
|
|
|
|
})();
|
|
|
|
|
|
|
|
(()=> {
|
|
|
|
function f(a) {
|
|
|
|
return Math.pow(a,10);
|
|
|
|
}
|
2019-05-03 12:48:33 +00:00
|
|
|
%PrepareFunctionForOptimization(f);
|
2018-02-21 11:38:35 +00:00
|
|
|
f(1);
|
|
|
|
f(1);
|
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
f("100");
|
2019-05-03 12:48:33 +00:00
|
|
|
%PrepareFunctionForOptimization(f);
|
2018-02-21 11:38:35 +00:00
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
f("100");
|
|
|
|
assertOptimized(f);
|
|
|
|
})();
|
|
|
|
|
|
|
|
(()=> {
|
|
|
|
function f(a) {
|
|
|
|
return Math.clz32(a);
|
|
|
|
}
|
2019-05-03 12:48:33 +00:00
|
|
|
%PrepareFunctionForOptimization(f);
|
2018-02-21 11:38:35 +00:00
|
|
|
f(1);
|
|
|
|
f(1);
|
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
f("100");
|
2019-05-03 12:48:33 +00:00
|
|
|
%PrepareFunctionForOptimization(f);
|
2018-02-21 11:38:35 +00:00
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
f("100");
|
|
|
|
assertOptimized(f);
|
|
|
|
})();
|
|
|
|
|
|
|
|
(()=> {
|
|
|
|
function f(a) {
|
|
|
|
return Math.imul(a, 10);
|
|
|
|
}
|
2019-05-03 12:48:33 +00:00
|
|
|
%PrepareFunctionForOptimization(f);
|
2018-02-21 11:38:35 +00:00
|
|
|
f(1);
|
|
|
|
f(1);
|
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
f("100");
|
2019-05-03 12:48:33 +00:00
|
|
|
%PrepareFunctionForOptimization(f);
|
2018-02-21 11:38:35 +00:00
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
f("100");
|
|
|
|
assertOptimized(f);
|
|
|
|
})();
|