Commit 8cbbc2e8 authored by Mythri A's avatar Mythri A Committed by Commit Bot

[cleanup] Add missing %PrepareFunctionForOptimize in mjsunit tests

Bug: v8:8801,v8:8394,v8:9183
Change-Id: I88c0268b30d4b927f9856db7a3b054b74baf1923
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1660608
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62189}
parent 63a9919a
...@@ -101,6 +101,7 @@ check_test_base(a, 3, false); ...@@ -101,6 +101,7 @@ check_test_base(a, 3, false);
// Test that we deopt on failed bounds checks. // Test that we deopt on failed bounds checks.
var dictionary_map_array = new Int32Array(128); var dictionary_map_array = new Int32Array(128);
test_base(dictionary_map_array, 5, true); test_base(dictionary_map_array, 5, true);
%PrepareFunctionForOptimization(test_base);
test_base(dictionary_map_array, 6, true); test_base(dictionary_map_array, 6, true);
test_base(dictionary_map_array, 5, false); test_base(dictionary_map_array, 5, false);
test_base(dictionary_map_array, 6, false); test_base(dictionary_map_array, 6, false);
...@@ -110,6 +111,7 @@ assertUnoptimized(test_base); ...@@ -110,6 +111,7 @@ assertUnoptimized(test_base);
// Forget about the dictionary_map_array's map. // Forget about the dictionary_map_array's map.
%ClearFunctionFeedback(test_base); %ClearFunctionFeedback(test_base);
%PrepareFunctionForOptimization(test_base);
test_base(a, 5, true); test_base(a, 5, true);
test_base(a, 6, true); test_base(a, 6, true);
...@@ -170,6 +172,7 @@ function short_test(a, i) { ...@@ -170,6 +172,7 @@ function short_test(a, i) {
a[i + 9] = 0; a[i + 9] = 0;
a[i - 10] = 0; a[i - 10] = 0;
} }
%PrepareFunctionForOptimization(short_test);
short_test(short_a, 50); short_test(short_a, 50);
short_test(short_a, 50); short_test(short_a, 50);
%OptimizeFunctionOnNextCall(short_test); %OptimizeFunctionOnNextCall(short_test);
......
...@@ -126,7 +126,8 @@ function assertKind(expected, obj, name_opt) { ...@@ -126,7 +126,8 @@ function assertKind(expected, obj, name_opt) {
assertTrue(a instanceof Array); assertTrue(a instanceof Array);
var contextB = Realm.create(); var contextB = Realm.create();
Realm.eval(contextB, "function bar2() { return new Array(); };"); Realm.eval(contextB,
"function bar2() { return new Array(); }; %PrepareFunctionForOptimization(bar2)");
Realm.eval(contextB, "bar2(); bar2();"); Realm.eval(contextB, "bar2(); bar2();");
Realm.eval(contextB, "%OptimizeFunctionOnNextCall(bar2);"); Realm.eval(contextB, "%OptimizeFunctionOnNextCall(bar2);");
Realm.eval(contextB, "bar2();"); Realm.eval(contextB, "bar2();");
......
...@@ -645,6 +645,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -645,6 +645,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
g(); g();
deopt = true; deopt = true;
g(); g();
%PrepareFunctionForOptimization(g);
deopt = false; deopt = false;
array = [11,22,33,45,56,6,77,84,93,101]; array = [11,22,33,45,56,6,77,84,93,101];
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -670,6 +671,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -670,6 +671,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
g(); g();
deopt = true; deopt = true;
g(); g();
%PrepareFunctionForOptimization(g);
deopt = false; deopt = false;
array = [11,22,33,45,56,6,77,84,93,101]; array = [11,22,33,45,56,6,77,84,93,101];
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -706,6 +708,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -706,6 +708,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
g(); g();
deopt = true; deopt = true;
g(); g();
%PrepareFunctionForOptimization(g);
deopt = false; deopt = false;
array = [11,22,33,45,56,6,77,84,93,101]; array = [11,22,33,45,56,6,77,84,93,101];
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -756,6 +759,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -756,6 +759,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
done = true; done = true;
assertEquals(null, g()); assertEquals(null, g());
done = false; done = false;
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
g(); g();
...@@ -788,6 +792,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -788,6 +792,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
done = true; done = true;
assertEquals(null, g()); assertEquals(null, g());
done = false; done = false;
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
g(); g();
...@@ -820,6 +825,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -820,6 +825,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
done = true; done = true;
assertEquals(null, g()); assertEquals(null, g());
done = false; done = false;
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
g(); g();
...@@ -853,6 +859,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -853,6 +859,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
done = true; done = true;
assertEquals(null, g()); assertEquals(null, g());
done = false; done = false;
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
g(); g();
...@@ -906,6 +913,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -906,6 +913,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
done = true; done = true;
assertEquals(null, g()); assertEquals(null, g());
done = false; done = false;
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
g(); g();
...@@ -941,6 +949,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -941,6 +949,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
done = true; done = true;
assertEquals(null, g()); assertEquals(null, g());
done = false; done = false;
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
g(); g();
...@@ -1031,6 +1040,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1031,6 +1040,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
g(); g();
deopt = true; deopt = true;
g(); g();
%PrepareFunctionForOptimization(g);
deopt = false; deopt = false;
array = [11,22,33,45,56,6,77,84,93,101]; array = [11,22,33,45,56,6,77,84,93,101];
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -1081,6 +1091,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1081,6 +1091,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
done = true; done = true;
assertEquals(null, g()); assertEquals(null, g());
done = false; done = false;
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
g(); g();
...@@ -1113,6 +1124,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1113,6 +1124,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
done = true; done = true;
assertEquals(null, g()); assertEquals(null, g());
done = false; done = false;
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
g(); g();
...@@ -1145,6 +1157,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1145,6 +1157,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
done = true; done = true;
assertEquals(null, g()); assertEquals(null, g());
done = false; done = false;
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
g(); g();
...@@ -1178,6 +1191,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1178,6 +1191,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
done = true; done = true;
assertEquals(null, g()); assertEquals(null, g());
done = false; done = false;
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
g(); g();
...@@ -1231,6 +1245,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1231,6 +1245,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
done = true; done = true;
assertEquals(null, g()); assertEquals(null, g());
done = false; done = false;
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
g(); g();
...@@ -1266,6 +1281,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1266,6 +1281,7 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
done = true; done = true;
assertEquals(null, g()); assertEquals(null, g());
done = false; done = false;
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
g(); g();
......
...@@ -82,6 +82,7 @@ failWithMessage = (msg) => %AbortJS(msg); ...@@ -82,6 +82,7 @@ failWithMessage = (msg) => %AbortJS(msg);
function foo() { function foo() {
return new Promise((a, b) => { throw new Error(); }); return new Promise((a, b) => { throw new Error(); });
} }
%PrepareFunctionForOptimization(foo);
function bar(i) { function bar(i) {
let error = null; let error = null;
......
...@@ -19,6 +19,7 @@ foo(function(){}); ...@@ -19,6 +19,7 @@ foo(function(){});
foo(function(){}); foo(function(){});
%OptimizeFunctionOnNextCall(foo); %OptimizeFunctionOnNextCall(foo);
foo(function(){}); foo(function(){});
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo); %OptimizeFunctionOnNextCall(foo);
foo(function(){}); foo(function(){});
assertOptimized(foo); assertOptimized(foo);
...@@ -23,6 +23,7 @@ foo([0, 1, 2]); ...@@ -23,6 +23,7 @@ foo([0, 1, 2]);
foo([0, 1, 2]); foo([0, 1, 2]);
%OptimizeFunctionOnNextCall(foo); %OptimizeFunctionOnNextCall(foo);
foo([0, 1, 2]); foo([0, 1, 2]);
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo); %OptimizeFunctionOnNextCall(foo);
foo([0, 1, 2]); foo([0, 1, 2]);
assertOptimized(foo); assertOptimized(foo);
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
// Verifies that closures in presence of eval work fine. // Verifies that closures in presence of eval work fine.
function withEval(expr, filter) { function withEval(expr, filter) {
%PrepareFunctionForOptimization(filter);
function walk(v) { function walk(v) {
for (var i in v) { for (var i in v) {
for (var i in v) {} for (var i in v) {}
......
...@@ -37,6 +37,7 @@ function test(f, iterations) { ...@@ -37,6 +37,7 @@ function test(f, iterations) {
for (let i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
f(); f();
%PrepareFunctionForOptimization(f);
} }
// Assert that the function finally stabilized. // Assert that the function finally stabilized.
assertOptimized(f); assertOptimized(f);
......
...@@ -233,12 +233,12 @@ convert_to_fast(smis); ...@@ -233,12 +233,12 @@ convert_to_fast(smis);
convert_to_fast(doubles); convert_to_fast(doubles);
// Test transition chain SMI->DOUBLE->FAST (crankshafted function will // Test transition chain SMI->DOUBLE->FAST (crankshafted function will
// transition to FAST directly). // transition to FAST directly).
%EnsureFeedbackVectorForFunction(convert_mixed);
function convert_mixed(array, value, kind) { function convert_mixed(array, value, kind) {
array[1] = value; array[1] = value;
assertKind(kind, array); assertKind(kind, array);
assertEquals(value, array[1]); assertEquals(value, array[1]);
} }
%PrepareFunctionForOptimization(convert_mixed);
smis = construct_smis(); smis = construct_smis();
for (var i = 0; i < 3; i++) { for (var i = 0; i < 3; i++) {
convert_mixed(smis, 1.5, elements_kind.fast_double); convert_mixed(smis, 1.5, elements_kind.fast_double);
......
...@@ -32,10 +32,10 @@ var test_id = 0; ...@@ -32,10 +32,10 @@ var test_id = 0;
function testTrunc(expected, input) { function testTrunc(expected, input) {
var test = new Function('n', var test = new Function('n',
'"' + (test_id++) + '";return Math.trunc(n)'); '"' + (test_id++) + '";return Math.trunc(n)');
%PrepareFunctionForOptimization(test);
assertEquals(expected, test(input)); assertEquals(expected, test(input));
assertEquals(expected, test(input)); assertEquals(expected, test(input));
assertEquals(expected, test(input)); assertEquals(expected, test(input));
%PrepareFunctionForOptimization(test);
%OptimizeFunctionOnNextCall(test); %OptimizeFunctionOnNextCall(test);
assertEquals(expected, test(input)); assertEquals(expected, test(input));
......
...@@ -9,6 +9,7 @@ var test_id = 0; ...@@ -9,6 +9,7 @@ var test_id = 0;
function testCeil(expect, input) { function testCeil(expect, input) {
var test = new Function('n', var test = new Function('n',
'"' + (test_id++) + '";return Math.ceil(n)'); '"' + (test_id++) + '";return Math.ceil(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));
......
...@@ -190,6 +190,8 @@ function TestAllScenarios(f) { ...@@ -190,6 +190,8 @@ function TestAllScenarios(f) {
%DeoptimizeFunction(AssignStrict); %DeoptimizeFunction(AssignStrict);
%ClearFunctionFeedback(Assign); %ClearFunctionFeedback(Assign);
%ClearFunctionFeedback(AssignStrict); %ClearFunctionFeedback(AssignStrict);
%PrepareFunctionForOptimization(Assign);
%PrepareFunctionForOptimization(AssignStrict);
for (var i = 0; i < t; ++i) { for (var i = 0; i < t; ++i) {
var o = create(); var o = create();
assertFalse("a" in o && !("a" in o.__proto__)); assertFalse("a" in o && !("a" in o.__proto__));
......
...@@ -32,6 +32,7 @@ function __f_4(i1) { ...@@ -32,6 +32,7 @@ function __f_4(i1) {
}; };
%PrepareFunctionForOptimization(__f_4); %PrepareFunctionForOptimization(__f_4);
function __f_3(i1) { function __f_3(i1) {
%PrepareFunctionForOptimization(__f_4);
__f_4(i1); __f_4(i1);
__f_4(i1 + 16); __f_4(i1 + 16);
__f_4(i1 + 32); __f_4(i1 + 32);
......
...@@ -36,6 +36,7 @@ function sum(a, b) { ...@@ -36,6 +36,7 @@ function sum(a, b) {
}; };
%PrepareFunctionForOptimization(sum); %PrepareFunctionForOptimization(sum);
function test(x, y, expectNaN) { function test(x, y, expectNaN) {
%PrepareFunctionForOptimization(sum);
for (var i = 0; i < 5; i++) { for (var i = 0; i < 5; i++) {
assertEquals(expectNaN, isNaN(sum(x, y))); assertEquals(expectNaN, isNaN(sum(x, y)));
} }
......
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