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 = []
for (var i = 0; i < 9; i++) a[i] = i + 1;
function test(f, arg1, arg2, expected) {
%PrepareFunctionForOptimization(f);
assertEquals(expected, f(arg1));
f(arg2);
%OptimizeFunctionOnNextCall(f);
......
......@@ -13,10 +13,11 @@ TestCoverage(
`
function g() { if (true) nop(); } // 0000
function f() { g(); g(); } // 0050
f(); f(); %OptimizeFunctionOnNextCall(f); // 0100
f(); f(); f(); f(); f(); f(); // 0150
%PrepareFunctionForOptimization(f); // 0100
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":50,"end":76,"count":8}]
);
......@@ -29,11 +30,12 @@ TestCoverage("Partial coverage collection",
function f(x) { // 0050
if (x) { nop(); } else { nop(); } // 0100
} // 0150
f(true); f(true); // 0200
%OptimizeFunctionOnNextCall(f); // 0250
%DebugCollectCoverage(); // 0300
f(false); // 0350
}(); // 0400
%PrepareFunctionForOptimization(f); // 0200
f(true); f(true); // 0250
%OptimizeFunctionOnNextCall(f); // 0300
%DebugCollectCoverage(); // 0350
f(false); // 0400
}(); // 0450
`,
[{"start":52,"end":153,"count":1},
{"start":111,"end":121,"count":0}]
......
......@@ -18,10 +18,11 @@ TestCoverage(
`
function g() { if (true) nop(); } // 0000
function f() { g(); g(); } // 0050
f(); f(); %OptimizeFunctionOnNextCall(f); // 0100
f(); f(); f(); f(); f(); f(); // 0150
%PrepareFunctionForOptimization(f); // 0100
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":50,"end":76,"count":8}]
);
......@@ -37,11 +38,12 @@ TestCoverage("Partial coverage collection",
function f(x) { // 0050
if (x) { nop(); } else { nop(); } // 0100
} // 0150
f(true); f(true); // 0200
%OptimizeFunctionOnNextCall(f); // 0250
%DebugCollectCoverage(); // 0300
f(false); // 0350
}(); // 0400
%PrepareFunctionForOptimization(f); // 0200
f(true); f(true); // 0250
%OptimizeFunctionOnNextCall(f); // 0300
%DebugCollectCoverage(); // 0350
f(false); // 0400
}(); // 0450
`,
[{"start":52,"end":153,"count":1},
{"start":111,"end":121,"count":0}]
......
......@@ -59,6 +59,7 @@ function test(a, b, less, greater) {
assertEquals(lt(b, a), greater);
assertEquals(gt(b, a), less);
}
%PrepareFunctionForOptimization(test);
var obj1 = {toString: function() {return "1";}};
var obj2 = {toString: function() {return "2";}};
......@@ -88,6 +89,7 @@ var greater = obj1 > obj2;
test(obj1, obj2, less, greater);
test(obj1, obj2, less, greater);
test(obj1, obj2, less, greater);
%PrepareFunctionForOptimization(test);
%OptimizeFunctionOnNextCall(test);
test(obj1, obj2, less, greater);
test(obj1, obj2, less, greater);
......@@ -96,6 +98,7 @@ obj1.toString = function() {return "1"};
var less = obj1 < obj2;
var greater = obj1 > obj2;
test(obj1, obj2, less, greater);
%PrepareFunctionForOptimization(test);
%OptimizeFunctionOnNextCall(test);
test(obj1, obj2, less, greater);
......
......@@ -35,6 +35,7 @@ function test_helper_for_ics(func, b1, b2, b3, b4) {
}
function test_helper_for_crankshaft(func, b1, b2, b3, b4) {
%PrepareFunctionForOptimization(func);
assertEquals(b1, func(.5, .5));
%OptimizeFunctionOnNextCall(func);
assertEquals(b1, func(.5, .5));
......
......@@ -10,5 +10,6 @@ function* get() {
get = [];
}
}
%PrepareFunctionForOptimization(get);
%OptimizeFunctionOnNextCall(get);
get();
......@@ -25,7 +25,7 @@ function test() {
assertFalse(%_IsJSReceiver(1));
}
%PrepareFunctionForOptimization(test);
test();
test();
%OptimizeFunctionOnNextCall(test);
......
......@@ -8,6 +8,7 @@
var realm = Realm.create();
var test = Realm.eval(realm,
"() => { return Realm.global(0) instanceof Object }");
%PrepareFunctionForOptimization(test);
assertFalse(test());
......
......@@ -8,6 +8,7 @@
function f(a, b, c) {
return String.prototype.indexOf.call(a, b, c);
}
%PrepareFunctionForOptimization(f);
f("abc", "de", 1);
f("abc", "de", 1);
%OptimizeFunctionOnNextCall(f);
......@@ -21,6 +22,7 @@
function f(a, b, c) {
return String.prototype.indexOf.apply(a, [b, c]);
}
%PrepareFunctionForOptimization(f);
f("abc", "de", 1);
f("abc", "de", 1);
%OptimizeFunctionOnNextCall(f);
......@@ -34,6 +36,7 @@
function f(a, b, c) {
return Reflect.apply(String.prototype.indexOf, a, [b, c]);
}
%PrepareFunctionForOptimization(f);
f("abc", "de", 1);
f("abc", "de", 1);
%OptimizeFunctionOnNextCall(f);
......@@ -47,6 +50,7 @@
function f(a, b) {
return String.fromCharCode.call(a, b);
}
%PrepareFunctionForOptimization(f);
f("abc", 1);
f("abc", 1);
%OptimizeFunctionOnNextCall(f);
......@@ -60,6 +64,7 @@
function f(a, b) {
return String.fromCharCode.apply(undefined, [b, {}]);
}
%PrepareFunctionForOptimization(f);
f("abc", 1);
f("abc", 1);
%OptimizeFunctionOnNextCall(f);
......@@ -74,6 +79,7 @@
function f(a, b) {
return Reflect.apply(String.fromCharCode, a, [b, {}]);
}
%PrepareFunctionForOptimization(f);
f("abc", 1);
f("abc", 1);
%OptimizeFunctionOnNextCall(f);
......
......@@ -31,11 +31,13 @@ function mul (a, b) {
return a * b;
}
%PrepareFunctionForOptimization(mul);
mul(-1, -1);
mul(0x80000001|0, -1);
mul(0x80000001|0, -1);
%OptimizeFunctionOnNextCall(mul);
mul(0, -1);
%PrepareFunctionForOptimization(mul);
%OptimizeFunctionOnNextCall(mul);
mul(0, -1);
......
......@@ -305,6 +305,7 @@ function lithium_integer_mod() {
}
%PrepareFunctionForOptimization(lithium_integer_mod);
lithium_integer_mod();
%OptimizeFunctionOnNextCall(lithium_integer_mod)
lithium_integer_mod();
......@@ -34,6 +34,7 @@ function burn() {
a[2] = 20;
return a;
}
%PrepareFunctionForOptimization(burn);
function check(a) {
assertEquals(10, a[0]);
......@@ -56,6 +57,7 @@ function loop_test(x) {
x[i] = (i+1) * 0.5;
}
}
%PrepareFunctionForOptimization(loop_test);
function check2(b) {
assertEquals(0.5, b[0]);
......
......@@ -38,6 +38,7 @@ function f(a) {
a[0] = 0;
a[1] = 0;
}
%PrepareFunctionForOptimization(f);
var a = new Int32Array(2);
for (var i = 0; i < 5; i++) {
......
......@@ -5,6 +5,7 @@
// Flags: --allow-natives-syntax
function test(expected, f) {
%PrepareFunctionForOptimization(f);
assertEquals(expected, f());
assertEquals(expected, f());
%OptimizeFunctionOnNextCall(f);
......
......@@ -64,6 +64,7 @@ var tests = {
for (let test in tests) {
%DeoptimizeFunction(testIn);
%ClearFunctionFeedback(testIn);
%PrepareFunctionForOptimization(testIn);
tests[test]();
%OptimizeFunctionOnNextCall(testIn);
tests[test]();
......
......@@ -255,6 +255,7 @@ var tests = {
for (test in tests) {
%DeoptimizeFunction(testIn);
%ClearFunctionFeedback(testIn);
%PrepareFunctionForOptimization(testIn);
tests[test]();
%OptimizeFunctionOnNextCall(testIn);
tests[test]();
......@@ -267,8 +268,9 @@ for (test in tests) {
var proto = function() {
assertTrue("prototype" in o);
o.prototype;
}
};
%PrepareFunctionForOptimization(proto);
proto();
proto();
%OptimizeFunctionOnNextCall(proto);
......@@ -281,6 +283,7 @@ for (test in tests) {
0 in "string"
};
%PrepareFunctionForOptimization(test);
assertThrows(test, TypeError);
assertThrows(test, TypeError);
%OptimizeFunctionOnNextCall(test);
......@@ -293,6 +296,7 @@ for (test in tests) {
assertTrue("length" in this);
};
%PrepareFunctionForOptimization(test);
test.call("");
test.call("");
%OptimizeFunctionOnNextCall(test);
......@@ -305,6 +309,7 @@ for (test in tests) {
return index in arguments;
};
%PrepareFunctionForOptimization(test);
assertFalse(test())
assertFalse(test())
assertTrue(test(0));
......@@ -327,6 +332,7 @@ for (test in tests) {
return 2 in arguments;
};
%PrepareFunctionForOptimization(test);
assertFalse(test(1));
assertFalse(test(1));
%OptimizeFunctionOnNextCall(test);
......@@ -342,6 +348,7 @@ for (test in tests) {
}
return true;
}
%PrepareFunctionForOptimization(test);
var str = "string";
// this will place slow_stub in the IC for strings.
......@@ -370,6 +377,7 @@ for (test in tests) {
}
return true;
}
%PrepareFunctionForOptimization(test);
var str = "string";
assertFalse(test(str, "length"));
......@@ -387,6 +395,7 @@ for (test in tests) {
}
return true;
}
%PrepareFunctionForOptimization(test);
var str = "string";
assertFalse(test(str, 0));
......@@ -404,6 +413,7 @@ for (test in tests) {
}
return true;
}
%PrepareFunctionForOptimization(test);
var ary = [0, 1, 2, '3'];
function testArray(ary) {
......@@ -452,6 +462,7 @@ function testHeapConstantArray(heap_constant_ary) {
function test() {
return 1 in heap_constant_ary;
}
%PrepareFunctionForOptimization(test);
assertTrue(test());
assertTrue(test());
......@@ -460,6 +471,7 @@ function testHeapConstantArray(heap_constant_ary) {
heap_constant_ary[1] = 2;
assertTrue(test());
%PrepareFunctionForOptimization(test);
%OptimizeFunctionOnNextCall(test);
assertTrue(test());
}
......
......@@ -17,18 +17,21 @@ function f(o) {
return result;
}
%PrepareFunctionForOptimization(f);
f(o1);
f(o1);
f(o1);
%OptimizeFunctionOnNextCall(f);
assertEquals(1000, f(o1));
%PrepareFunctionForOptimization(f);
f(o2);
f(o2);
f(o2);
%OptimizeFunctionOnNextCall(f);
assertEquals(1100, f(o2));
%PrepareFunctionForOptimization(f);
f(o3);
f(o3);
f(o3);
......@@ -53,6 +56,7 @@ assertEquals(1200, f(o3));
return g(1, o[h()]--, 10);
}
%PrepareFunctionForOptimization(test);
test(global);
test(global);
%OptimizeFunctionOnNextCall(test);
......@@ -65,6 +69,7 @@ assertEquals(1200, f(o3));
this[0, ""]--;
}
%PrepareFunctionForOptimization(test);
test();
test();
%OptimizeFunctionOnNextCall(test);
......
......@@ -11,6 +11,7 @@ function f1() {
assertEquals([undefined, 42], x);
}
%PrepareFunctionForOptimization(f1);
f1();
f1();
%OptimizeFunctionOnNextCall(f1);
......@@ -26,6 +27,7 @@ function f2() {
assertEquals([0, 1, 2, 3, 4], x);
}
%PrepareFunctionForOptimization(f2);
f2();
f2();
%OptimizeFunctionOnNextCall(f2);
......@@ -41,6 +43,7 @@ function f3() {
assertEquals([0, 1.1, {}], x);
}
%PrepareFunctionForOptimization(f3);
f3();
f3();
%OptimizeFunctionOnNextCall(f3);
......@@ -52,6 +55,7 @@ function f4(x) {
x[x.length] = x.length;
}
%PrepareFunctionForOptimization(f4);
let x1 = [];
f4(x1);
assertEquals([0], x1);
......@@ -63,6 +67,7 @@ assertEquals([0, 1, 2], x1);
f4(x1);
assertEquals([0, 1, 2, 3], x1);
%PrepareFunctionForOptimization(f4);
let x2 = {length: 42};
f4(x2);
assertEquals(42, x2[42]);
......
......@@ -32,6 +32,7 @@ var test_id = 0;
function testFloor(expect, input) {
var test = new Function('n',
'"' + (test_id++) + '";return Math.floor(n)');
%PrepareFunctionForOptimization(test);
assertEquals(expect, test(input));
assertEquals(expect, test(input));
assertEquals(expect, test(input));
......@@ -41,6 +42,7 @@ function testFloor(expect, input) {
var test_double_input = new Function(
'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));
......@@ -50,6 +52,7 @@ function testFloor(expect, input) {
var test_double_output = new Function(
'n',
'"' + (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));
......@@ -59,6 +62,7 @@ function testFloor(expect, input) {
var test_via_ceil = new Function(
'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));
......@@ -69,6 +73,7 @@ function testFloor(expect, input) {
var test_via_trunc = new Function(
'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));
......
......@@ -32,6 +32,7 @@ var test_id = 0;
function testFloor(expect, input) {
var test = new Function('n',
'"' + (test_id++) + '";return Math.floor(n)');
%PrepareFunctionForOptimization(test);
assertEquals(expect, test(input));
assertEquals(expect, test(input));
assertEquals(expect, test(input));
......@@ -41,6 +42,7 @@ function testFloor(expect, input) {
var test_double_input = new Function(
'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));
......@@ -50,6 +52,7 @@ function testFloor(expect, input) {
var test_double_output = new Function(
'n',
'"' + (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));
......@@ -59,6 +62,7 @@ function testFloor(expect, input) {
var test_via_ceil = new Function(
'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));
......@@ -69,6 +73,7 @@ function testFloor(expect, input) {
var test_via_trunc = new Function(
'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));
......
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