Commit eab992fd authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[cleanup] Add %PrepareForOptimization to some more mjsunit tests.

Bug=v8:8801,v8:8394,v8:9183

Change-Id: I9d88d2aa2b261b0f8df83dd6075b68cbc626161f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1660476
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Auto-Submit: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62172}
parent f16f0bcc
...@@ -8,6 +8,7 @@ var a = [] ...@@ -8,6 +8,7 @@ var a = []
for (var i = 0; i < 9; i++) a[i] = i + 1; for (var i = 0; i < 9; i++) a[i] = i + 1;
function test(f, arg1, arg2, expected) { function test(f, arg1, arg2, expected) {
%PrepareFunctionForOptimization(f);
assertEquals(expected, f(arg1)); assertEquals(expected, f(arg1));
f(arg2); f(arg2);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
......
...@@ -13,10 +13,11 @@ TestCoverage( ...@@ -13,10 +13,11 @@ TestCoverage(
` `
function g() { if (true) nop(); } // 0000 function g() { if (true) nop(); } // 0000
function f() { g(); g(); } // 0050 function f() { g(); g(); } // 0050
f(); f(); %OptimizeFunctionOnNextCall(f); // 0100 %PrepareFunctionForOptimization(f); // 0100
f(); f(); f(); f(); f(); f(); // 0150 f(); f(); %OptimizeFunctionOnNextCall(f); // 0150
f(); f(); f(); f(); f(); f(); // 0200
`, `,
[{"start":0,"end":199,"count":1}, [{"start":0,"end":249,"count":1},
{"start":0,"end":33,"count":16}, {"start":0,"end":33,"count":16},
{"start":50,"end":76,"count":8}] {"start":50,"end":76,"count":8}]
); );
...@@ -29,11 +30,12 @@ TestCoverage("Partial coverage collection", ...@@ -29,11 +30,12 @@ TestCoverage("Partial coverage collection",
function f(x) { // 0050 function f(x) { // 0050
if (x) { nop(); } else { nop(); } // 0100 if (x) { nop(); } else { nop(); } // 0100
} // 0150 } // 0150
f(true); f(true); // 0200 %PrepareFunctionForOptimization(f); // 0200
%OptimizeFunctionOnNextCall(f); // 0250 f(true); f(true); // 0250
%DebugCollectCoverage(); // 0300 %OptimizeFunctionOnNextCall(f); // 0300
f(false); // 0350 %DebugCollectCoverage(); // 0350
}(); // 0400 f(false); // 0400
}(); // 0450
`, `,
[{"start":52,"end":153,"count":1}, [{"start":52,"end":153,"count":1},
{"start":111,"end":121,"count":0}] {"start":111,"end":121,"count":0}]
......
...@@ -18,10 +18,11 @@ TestCoverage( ...@@ -18,10 +18,11 @@ TestCoverage(
` `
function g() { if (true) nop(); } // 0000 function g() { if (true) nop(); } // 0000
function f() { g(); g(); } // 0050 function f() { g(); g(); } // 0050
f(); f(); %OptimizeFunctionOnNextCall(f); // 0100 %PrepareFunctionForOptimization(f); // 0100
f(); f(); f(); f(); f(); f(); // 0150 f(); f(); %OptimizeFunctionOnNextCall(f); // 0150
f(); f(); f(); f(); f(); f(); // 0200
`, `,
[{"start":0,"end":199,"count":1}, [{"start":0,"end":249,"count":1},
{"start":0,"end":33,"count":16}, {"start":0,"end":33,"count":16},
{"start":50,"end":76,"count":8}] {"start":50,"end":76,"count":8}]
); );
...@@ -37,11 +38,12 @@ TestCoverage("Partial coverage collection", ...@@ -37,11 +38,12 @@ TestCoverage("Partial coverage collection",
function f(x) { // 0050 function f(x) { // 0050
if (x) { nop(); } else { nop(); } // 0100 if (x) { nop(); } else { nop(); } // 0100
} // 0150 } // 0150
f(true); f(true); // 0200 %PrepareFunctionForOptimization(f); // 0200
%OptimizeFunctionOnNextCall(f); // 0250 f(true); f(true); // 0250
%DebugCollectCoverage(); // 0300 %OptimizeFunctionOnNextCall(f); // 0300
f(false); // 0350 %DebugCollectCoverage(); // 0350
}(); // 0400 f(false); // 0400
}(); // 0450
`, `,
[{"start":52,"end":153,"count":1}, [{"start":52,"end":153,"count":1},
{"start":111,"end":121,"count":0}] {"start":111,"end":121,"count":0}]
......
...@@ -59,6 +59,7 @@ function test(a, b, less, greater) { ...@@ -59,6 +59,7 @@ function test(a, b, less, greater) {
assertEquals(lt(b, a), greater); assertEquals(lt(b, a), greater);
assertEquals(gt(b, a), less); assertEquals(gt(b, a), less);
} }
%PrepareFunctionForOptimization(test);
var obj1 = {toString: function() {return "1";}}; var obj1 = {toString: function() {return "1";}};
var obj2 = {toString: function() {return "2";}}; var obj2 = {toString: function() {return "2";}};
...@@ -88,6 +89,7 @@ var greater = obj1 > obj2; ...@@ -88,6 +89,7 @@ var greater = obj1 > obj2;
test(obj1, obj2, less, greater); test(obj1, obj2, less, greater);
test(obj1, obj2, less, greater); test(obj1, obj2, less, greater);
test(obj1, obj2, less, greater); test(obj1, obj2, less, greater);
%PrepareFunctionForOptimization(test);
%OptimizeFunctionOnNextCall(test); %OptimizeFunctionOnNextCall(test);
test(obj1, obj2, less, greater); test(obj1, obj2, less, greater);
test(obj1, obj2, less, greater); test(obj1, obj2, less, greater);
...@@ -96,6 +98,7 @@ obj1.toString = function() {return "1"}; ...@@ -96,6 +98,7 @@ obj1.toString = function() {return "1"};
var less = obj1 < obj2; var less = obj1 < obj2;
var greater = obj1 > obj2; var greater = obj1 > obj2;
test(obj1, obj2, less, greater); test(obj1, obj2, less, greater);
%PrepareFunctionForOptimization(test);
%OptimizeFunctionOnNextCall(test); %OptimizeFunctionOnNextCall(test);
test(obj1, obj2, less, greater); test(obj1, obj2, less, greater);
......
...@@ -35,6 +35,7 @@ function test_helper_for_ics(func, b1, b2, b3, b4) { ...@@ -35,6 +35,7 @@ function test_helper_for_ics(func, b1, b2, b3, b4) {
} }
function test_helper_for_crankshaft(func, b1, b2, b3, b4) { function test_helper_for_crankshaft(func, b1, b2, b3, b4) {
%PrepareFunctionForOptimization(func);
assertEquals(b1, func(.5, .5)); assertEquals(b1, func(.5, .5));
%OptimizeFunctionOnNextCall(func); %OptimizeFunctionOnNextCall(func);
assertEquals(b1, func(.5, .5)); assertEquals(b1, func(.5, .5));
......
...@@ -10,5 +10,6 @@ function* get() { ...@@ -10,5 +10,6 @@ function* get() {
get = []; get = [];
} }
} }
%PrepareFunctionForOptimization(get);
%OptimizeFunctionOnNextCall(get); %OptimizeFunctionOnNextCall(get);
get(); get();
...@@ -25,7 +25,7 @@ function test() { ...@@ -25,7 +25,7 @@ function test() {
assertFalse(%_IsJSReceiver(1)); assertFalse(%_IsJSReceiver(1));
} }
%PrepareFunctionForOptimization(test);
test(); test();
test(); test();
%OptimizeFunctionOnNextCall(test); %OptimizeFunctionOnNextCall(test);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
var realm = Realm.create(); var realm = Realm.create();
var test = Realm.eval(realm, var test = Realm.eval(realm,
"() => { return Realm.global(0) instanceof Object }"); "() => { return Realm.global(0) instanceof Object }");
%PrepareFunctionForOptimization(test);
assertFalse(test()); assertFalse(test());
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
function f(a, b, c) { function f(a, b, c) {
return String.prototype.indexOf.call(a, b, c); return String.prototype.indexOf.call(a, b, c);
} }
%PrepareFunctionForOptimization(f);
f("abc", "de", 1); f("abc", "de", 1);
f("abc", "de", 1); f("abc", "de", 1);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
function f(a, b, c) { function f(a, b, c) {
return String.prototype.indexOf.apply(a, [b, c]); return String.prototype.indexOf.apply(a, [b, c]);
} }
%PrepareFunctionForOptimization(f);
f("abc", "de", 1); f("abc", "de", 1);
f("abc", "de", 1); f("abc", "de", 1);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
...@@ -34,6 +36,7 @@ ...@@ -34,6 +36,7 @@
function f(a, b, c) { function f(a, b, c) {
return Reflect.apply(String.prototype.indexOf, a, [b, c]); return Reflect.apply(String.prototype.indexOf, a, [b, c]);
} }
%PrepareFunctionForOptimization(f);
f("abc", "de", 1); f("abc", "de", 1);
f("abc", "de", 1); f("abc", "de", 1);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
...@@ -47,6 +50,7 @@ ...@@ -47,6 +50,7 @@
function f(a, b) { function f(a, b) {
return String.fromCharCode.call(a, b); return String.fromCharCode.call(a, b);
} }
%PrepareFunctionForOptimization(f);
f("abc", 1); f("abc", 1);
f("abc", 1); f("abc", 1);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
...@@ -60,6 +64,7 @@ ...@@ -60,6 +64,7 @@
function f(a, b) { function f(a, b) {
return String.fromCharCode.apply(undefined, [b, {}]); return String.fromCharCode.apply(undefined, [b, {}]);
} }
%PrepareFunctionForOptimization(f);
f("abc", 1); f("abc", 1);
f("abc", 1); f("abc", 1);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
...@@ -74,6 +79,7 @@ ...@@ -74,6 +79,7 @@
function f(a, b) { function f(a, b) {
return Reflect.apply(String.fromCharCode, a, [b, {}]); return Reflect.apply(String.fromCharCode, a, [b, {}]);
} }
%PrepareFunctionForOptimization(f);
f("abc", 1); f("abc", 1);
f("abc", 1); f("abc", 1);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
......
...@@ -31,11 +31,13 @@ function mul (a, b) { ...@@ -31,11 +31,13 @@ function mul (a, b) {
return a * b; return a * b;
} }
%PrepareFunctionForOptimization(mul);
mul(-1, -1); mul(-1, -1);
mul(0x80000001|0, -1); mul(0x80000001|0, -1);
mul(0x80000001|0, -1); mul(0x80000001|0, -1);
%OptimizeFunctionOnNextCall(mul); %OptimizeFunctionOnNextCall(mul);
mul(0, -1); mul(0, -1);
%PrepareFunctionForOptimization(mul);
%OptimizeFunctionOnNextCall(mul); %OptimizeFunctionOnNextCall(mul);
mul(0, -1); mul(0, -1);
......
...@@ -305,6 +305,7 @@ function lithium_integer_mod() { ...@@ -305,6 +305,7 @@ function lithium_integer_mod() {
} }
%PrepareFunctionForOptimization(lithium_integer_mod);
lithium_integer_mod(); lithium_integer_mod();
%OptimizeFunctionOnNextCall(lithium_integer_mod) %OptimizeFunctionOnNextCall(lithium_integer_mod)
lithium_integer_mod(); lithium_integer_mod();
...@@ -34,6 +34,7 @@ function burn() { ...@@ -34,6 +34,7 @@ function burn() {
a[2] = 20; a[2] = 20;
return a; return a;
} }
%PrepareFunctionForOptimization(burn);
function check(a) { function check(a) {
assertEquals(10, a[0]); assertEquals(10, a[0]);
...@@ -56,6 +57,7 @@ function loop_test(x) { ...@@ -56,6 +57,7 @@ function loop_test(x) {
x[i] = (i+1) * 0.5; x[i] = (i+1) * 0.5;
} }
} }
%PrepareFunctionForOptimization(loop_test);
function check2(b) { function check2(b) {
assertEquals(0.5, b[0]); assertEquals(0.5, b[0]);
......
...@@ -38,6 +38,7 @@ function f(a) { ...@@ -38,6 +38,7 @@ function f(a) {
a[0] = 0; a[0] = 0;
a[1] = 0; a[1] = 0;
} }
%PrepareFunctionForOptimization(f);
var a = new Int32Array(2); var a = new Int32Array(2);
for (var i = 0; i < 5; i++) { for (var i = 0; i < 5; i++) {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
// Flags: --allow-natives-syntax // Flags: --allow-natives-syntax
function test(expected, f) { function test(expected, f) {
%PrepareFunctionForOptimization(f);
assertEquals(expected, f()); assertEquals(expected, f());
assertEquals(expected, f()); assertEquals(expected, f());
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
......
...@@ -64,6 +64,7 @@ var tests = { ...@@ -64,6 +64,7 @@ var tests = {
for (let test in tests) { for (let test in tests) {
%DeoptimizeFunction(testIn); %DeoptimizeFunction(testIn);
%ClearFunctionFeedback(testIn); %ClearFunctionFeedback(testIn);
%PrepareFunctionForOptimization(testIn);
tests[test](); tests[test]();
%OptimizeFunctionOnNextCall(testIn); %OptimizeFunctionOnNextCall(testIn);
tests[test](); tests[test]();
......
...@@ -255,6 +255,7 @@ var tests = { ...@@ -255,6 +255,7 @@ var tests = {
for (test in tests) { for (test in tests) {
%DeoptimizeFunction(testIn); %DeoptimizeFunction(testIn);
%ClearFunctionFeedback(testIn); %ClearFunctionFeedback(testIn);
%PrepareFunctionForOptimization(testIn);
tests[test](); tests[test]();
%OptimizeFunctionOnNextCall(testIn); %OptimizeFunctionOnNextCall(testIn);
tests[test](); tests[test]();
...@@ -267,8 +268,9 @@ for (test in tests) { ...@@ -267,8 +268,9 @@ for (test in tests) {
var proto = function() { var proto = function() {
assertTrue("prototype" in o); assertTrue("prototype" in o);
o.prototype; o.prototype;
} };
%PrepareFunctionForOptimization(proto);
proto(); proto();
proto(); proto();
%OptimizeFunctionOnNextCall(proto); %OptimizeFunctionOnNextCall(proto);
...@@ -281,6 +283,7 @@ for (test in tests) { ...@@ -281,6 +283,7 @@ for (test in tests) {
0 in "string" 0 in "string"
}; };
%PrepareFunctionForOptimization(test);
assertThrows(test, TypeError); assertThrows(test, TypeError);
assertThrows(test, TypeError); assertThrows(test, TypeError);
%OptimizeFunctionOnNextCall(test); %OptimizeFunctionOnNextCall(test);
...@@ -293,6 +296,7 @@ for (test in tests) { ...@@ -293,6 +296,7 @@ for (test in tests) {
assertTrue("length" in this); assertTrue("length" in this);
}; };
%PrepareFunctionForOptimization(test);
test.call(""); test.call("");
test.call(""); test.call("");
%OptimizeFunctionOnNextCall(test); %OptimizeFunctionOnNextCall(test);
...@@ -305,6 +309,7 @@ for (test in tests) { ...@@ -305,6 +309,7 @@ for (test in tests) {
return index in arguments; return index in arguments;
}; };
%PrepareFunctionForOptimization(test);
assertFalse(test()) assertFalse(test())
assertFalse(test()) assertFalse(test())
assertTrue(test(0)); assertTrue(test(0));
...@@ -327,6 +332,7 @@ for (test in tests) { ...@@ -327,6 +332,7 @@ for (test in tests) {
return 2 in arguments; return 2 in arguments;
}; };
%PrepareFunctionForOptimization(test);
assertFalse(test(1)); assertFalse(test(1));
assertFalse(test(1)); assertFalse(test(1));
%OptimizeFunctionOnNextCall(test); %OptimizeFunctionOnNextCall(test);
...@@ -342,6 +348,7 @@ for (test in tests) { ...@@ -342,6 +348,7 @@ for (test in tests) {
} }
return true; return true;
} }
%PrepareFunctionForOptimization(test);
var str = "string"; var str = "string";
// this will place slow_stub in the IC for strings. // this will place slow_stub in the IC for strings.
...@@ -370,6 +377,7 @@ for (test in tests) { ...@@ -370,6 +377,7 @@ for (test in tests) {
} }
return true; return true;
} }
%PrepareFunctionForOptimization(test);
var str = "string"; var str = "string";
assertFalse(test(str, "length")); assertFalse(test(str, "length"));
...@@ -387,6 +395,7 @@ for (test in tests) { ...@@ -387,6 +395,7 @@ for (test in tests) {
} }
return true; return true;
} }
%PrepareFunctionForOptimization(test);
var str = "string"; var str = "string";
assertFalse(test(str, 0)); assertFalse(test(str, 0));
...@@ -404,6 +413,7 @@ for (test in tests) { ...@@ -404,6 +413,7 @@ for (test in tests) {
} }
return true; return true;
} }
%PrepareFunctionForOptimization(test);
var ary = [0, 1, 2, '3']; var ary = [0, 1, 2, '3'];
function testArray(ary) { function testArray(ary) {
...@@ -452,6 +462,7 @@ function testHeapConstantArray(heap_constant_ary) { ...@@ -452,6 +462,7 @@ function testHeapConstantArray(heap_constant_ary) {
function test() { function test() {
return 1 in heap_constant_ary; return 1 in heap_constant_ary;
} }
%PrepareFunctionForOptimization(test);
assertTrue(test()); assertTrue(test());
assertTrue(test()); assertTrue(test());
...@@ -460,6 +471,7 @@ function testHeapConstantArray(heap_constant_ary) { ...@@ -460,6 +471,7 @@ function testHeapConstantArray(heap_constant_ary) {
heap_constant_ary[1] = 2; heap_constant_ary[1] = 2;
assertTrue(test()); assertTrue(test());
%PrepareFunctionForOptimization(test);
%OptimizeFunctionOnNextCall(test); %OptimizeFunctionOnNextCall(test);
assertTrue(test()); assertTrue(test());
} }
......
...@@ -17,18 +17,21 @@ function f(o) { ...@@ -17,18 +17,21 @@ function f(o) {
return result; return result;
} }
%PrepareFunctionForOptimization(f);
f(o1); f(o1);
f(o1); f(o1);
f(o1); f(o1);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
assertEquals(1000, f(o1)); assertEquals(1000, f(o1));
%PrepareFunctionForOptimization(f);
f(o2); f(o2);
f(o2); f(o2);
f(o2); f(o2);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
assertEquals(1100, f(o2)); assertEquals(1100, f(o2));
%PrepareFunctionForOptimization(f);
f(o3); f(o3);
f(o3); f(o3);
f(o3); f(o3);
...@@ -53,6 +56,7 @@ assertEquals(1200, f(o3)); ...@@ -53,6 +56,7 @@ assertEquals(1200, f(o3));
return g(1, o[h()]--, 10); return g(1, o[h()]--, 10);
} }
%PrepareFunctionForOptimization(test);
test(global); test(global);
test(global); test(global);
%OptimizeFunctionOnNextCall(test); %OptimizeFunctionOnNextCall(test);
...@@ -65,6 +69,7 @@ assertEquals(1200, f(o3)); ...@@ -65,6 +69,7 @@ assertEquals(1200, f(o3));
this[0, ""]--; this[0, ""]--;
} }
%PrepareFunctionForOptimization(test);
test(); test();
test(); test();
%OptimizeFunctionOnNextCall(test); %OptimizeFunctionOnNextCall(test);
......
...@@ -11,6 +11,7 @@ function f1() { ...@@ -11,6 +11,7 @@ function f1() {
assertEquals([undefined, 42], x); assertEquals([undefined, 42], x);
} }
%PrepareFunctionForOptimization(f1);
f1(); f1();
f1(); f1();
%OptimizeFunctionOnNextCall(f1); %OptimizeFunctionOnNextCall(f1);
...@@ -26,6 +27,7 @@ function f2() { ...@@ -26,6 +27,7 @@ function f2() {
assertEquals([0, 1, 2, 3, 4], x); assertEquals([0, 1, 2, 3, 4], x);
} }
%PrepareFunctionForOptimization(f2);
f2(); f2();
f2(); f2();
%OptimizeFunctionOnNextCall(f2); %OptimizeFunctionOnNextCall(f2);
...@@ -41,6 +43,7 @@ function f3() { ...@@ -41,6 +43,7 @@ function f3() {
assertEquals([0, 1.1, {}], x); assertEquals([0, 1.1, {}], x);
} }
%PrepareFunctionForOptimization(f3);
f3(); f3();
f3(); f3();
%OptimizeFunctionOnNextCall(f3); %OptimizeFunctionOnNextCall(f3);
...@@ -52,6 +55,7 @@ function f4(x) { ...@@ -52,6 +55,7 @@ function f4(x) {
x[x.length] = x.length; x[x.length] = x.length;
} }
%PrepareFunctionForOptimization(f4);
let x1 = []; let x1 = [];
f4(x1); f4(x1);
assertEquals([0], x1); assertEquals([0], x1);
...@@ -63,6 +67,7 @@ assertEquals([0, 1, 2], x1); ...@@ -63,6 +67,7 @@ assertEquals([0, 1, 2], x1);
f4(x1); f4(x1);
assertEquals([0, 1, 2, 3], x1); assertEquals([0, 1, 2, 3], x1);
%PrepareFunctionForOptimization(f4);
let x2 = {length: 42}; let x2 = {length: 42};
f4(x2); f4(x2);
assertEquals(42, x2[42]); assertEquals(42, x2[42]);
......
...@@ -32,6 +32,7 @@ var test_id = 0; ...@@ -32,6 +32,7 @@ var test_id = 0;
function testFloor(expect, input) { function testFloor(expect, input) {
var test = new Function('n', var test = new Function('n',
'"' + (test_id++) + '";return Math.floor(n)'); '"' + (test_id++) + '";return Math.floor(n)');
%PrepareFunctionForOptimization(test);
assertEquals(expect, test(input)); assertEquals(expect, test(input));
assertEquals(expect, test(input)); assertEquals(expect, test(input));
assertEquals(expect, test(input)); assertEquals(expect, test(input));
...@@ -41,6 +42,7 @@ function testFloor(expect, input) { ...@@ -41,6 +42,7 @@ function testFloor(expect, input) {
var test_double_input = new Function( var test_double_input = new Function(
'n', 'n',
'"' + (test_id++) + '";return Math.floor(+n)'); '"' + (test_id++) + '";return Math.floor(+n)');
%PrepareFunctionForOptimization(test_double_input);
assertEquals(expect, test_double_input(input)); assertEquals(expect, test_double_input(input));
assertEquals(expect, test_double_input(input)); assertEquals(expect, test_double_input(input));
assertEquals(expect, test_double_input(input)); assertEquals(expect, test_double_input(input));
...@@ -50,6 +52,7 @@ function testFloor(expect, input) { ...@@ -50,6 +52,7 @@ function testFloor(expect, input) {
var test_double_output = new Function( var test_double_output = new Function(
'n', 'n',
'"' + (test_id++) + '";return Math.floor(n) + -0.0'); '"' + (test_id++) + '";return Math.floor(n) + -0.0');
%PrepareFunctionForOptimization(test_double_output);
assertEquals(expect, test_double_output(input)); assertEquals(expect, test_double_output(input));
assertEquals(expect, test_double_output(input)); assertEquals(expect, test_double_output(input));
assertEquals(expect, test_double_output(input)); assertEquals(expect, test_double_output(input));
...@@ -59,6 +62,7 @@ function testFloor(expect, input) { ...@@ -59,6 +62,7 @@ function testFloor(expect, input) {
var test_via_ceil = new Function( var test_via_ceil = new Function(
'n', 'n',
'"' + (test_id++) + '";return -Math.ceil(-n)'); '"' + (test_id++) + '";return -Math.ceil(-n)');
%PrepareFunctionForOptimization(test_via_ceil);
assertEquals(expect, test_via_ceil(input)); assertEquals(expect, test_via_ceil(input));
assertEquals(expect, test_via_ceil(input)); assertEquals(expect, test_via_ceil(input));
assertEquals(expect, test_via_ceil(input)); assertEquals(expect, test_via_ceil(input));
...@@ -69,6 +73,7 @@ function testFloor(expect, input) { ...@@ -69,6 +73,7 @@ function testFloor(expect, input) {
var test_via_trunc = new Function( var test_via_trunc = new Function(
'n', 'n',
'"' + (test_id++) + '";return Math.trunc(n)'); '"' + (test_id++) + '";return Math.trunc(n)');
%PrepareFunctionForOptimization(test_via_trunc);
assertEquals(expect, test_via_trunc(input)); assertEquals(expect, test_via_trunc(input));
assertEquals(expect, test_via_trunc(input)); assertEquals(expect, test_via_trunc(input));
assertEquals(expect, test_via_trunc(input)); assertEquals(expect, test_via_trunc(input));
......
...@@ -32,6 +32,7 @@ var test_id = 0; ...@@ -32,6 +32,7 @@ var test_id = 0;
function testFloor(expect, input) { function testFloor(expect, input) {
var test = new Function('n', var test = new Function('n',
'"' + (test_id++) + '";return Math.floor(n)'); '"' + (test_id++) + '";return Math.floor(n)');
%PrepareFunctionForOptimization(test);
assertEquals(expect, test(input)); assertEquals(expect, test(input));
assertEquals(expect, test(input)); assertEquals(expect, test(input));
assertEquals(expect, test(input)); assertEquals(expect, test(input));
...@@ -41,6 +42,7 @@ function testFloor(expect, input) { ...@@ -41,6 +42,7 @@ function testFloor(expect, input) {
var test_double_input = new Function( var test_double_input = new Function(
'n', 'n',
'"' + (test_id++) + '";return Math.floor(+n)'); '"' + (test_id++) + '";return Math.floor(+n)');
%PrepareFunctionForOptimization(test_double_input);
assertEquals(expect, test_double_input(input)); assertEquals(expect, test_double_input(input));
assertEquals(expect, test_double_input(input)); assertEquals(expect, test_double_input(input));
assertEquals(expect, test_double_input(input)); assertEquals(expect, test_double_input(input));
...@@ -50,6 +52,7 @@ function testFloor(expect, input) { ...@@ -50,6 +52,7 @@ function testFloor(expect, input) {
var test_double_output = new Function( var test_double_output = new Function(
'n', 'n',
'"' + (test_id++) + '";return Math.floor(n) + -0.0'); '"' + (test_id++) + '";return Math.floor(n) + -0.0');
%PrepareFunctionForOptimization(test_double_output);
assertEquals(expect, test_double_output(input)); assertEquals(expect, test_double_output(input));
assertEquals(expect, test_double_output(input)); assertEquals(expect, test_double_output(input));
assertEquals(expect, test_double_output(input)); assertEquals(expect, test_double_output(input));
...@@ -59,6 +62,7 @@ function testFloor(expect, input) { ...@@ -59,6 +62,7 @@ function testFloor(expect, input) {
var test_via_ceil = new Function( var test_via_ceil = new Function(
'n', 'n',
'"' + (test_id++) + '";return -Math.ceil(-n)'); '"' + (test_id++) + '";return -Math.ceil(-n)');
%PrepareFunctionForOptimization(test_via_ceil);
assertEquals(expect, test_via_ceil(input)); assertEquals(expect, test_via_ceil(input));
assertEquals(expect, test_via_ceil(input)); assertEquals(expect, test_via_ceil(input));
assertEquals(expect, test_via_ceil(input)); assertEquals(expect, test_via_ceil(input));
...@@ -69,6 +73,7 @@ function testFloor(expect, input) { ...@@ -69,6 +73,7 @@ function testFloor(expect, input) {
var test_via_trunc = new Function( var test_via_trunc = new Function(
'n', 'n',
'"' + (test_id++) + '";return Math.trunc(n)'); '"' + (test_id++) + '";return Math.trunc(n)');
%PrepareFunctionForOptimization(test_via_trunc);
assertEquals(expect, test_via_trunc(input)); assertEquals(expect, test_via_trunc(input));
assertEquals(expect, test_via_trunc(input)); assertEquals(expect, test_via_trunc(input));
assertEquals(expect, test_via_trunc(input)); assertEquals(expect, test_via_trunc(input));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment