Commit ae1af6a5 authored by Mythri A's avatar Mythri A Committed by Commit Bot

[cleanup] Add %PrepareFunctionForOptimize for tests that use %OptimizeOsr

Bug: v8:8394, v8:8801, v8:9183
Change-Id: I29ff1a6dda97e89335b30fcc8c380bcb4055e1fb
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1664690Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62254}
parent 89e44e24
......@@ -13,6 +13,7 @@ function f() {
for (let i = 0; i < 10; i++) {
%OptimizeOsr();
%ScheduleBreak();
%PrepareFunctionForOptimization(f);
}
}
%PrepareFunctionForOptimization(f);
......
......@@ -7,11 +7,15 @@ Debug = debug.Debug;
Debug.setListener(function() {});
function f() {
for (var i = 0; i < 100; i++) %OptimizeOsr();
for (var i = 0; i < 100; i++) {
%OptimizeOsr();
%PrepareFunctionForOptimization(f);
}
}
%PrepareFunctionForOptimization(f);
Debug.setBreakPoint(f, 0, 0);
f();
%PrepareFunctionForOptimization(f);
f();
Debug.setListener(null);
......@@ -20,6 +20,7 @@ function wrapper1() {
// Get this function optimized before calling to increment.
// Check that that call performs the necessary side-effect checks.
%OptimizeOsr();
%PrepareFunctionForOptimization(wrapper1);
}
f1();
}
......
......@@ -266,6 +266,7 @@ function osr_inner(t, limit) {
}
r += x;
}
%PrepareFunctionForOptimization(osr_inner);
}
return r;
}
......
......@@ -38,7 +38,6 @@ function f1() {
}
return sum;
}
%PrepareFunctionForOptimization(f1);
function f2() {
var sum = 0;
......@@ -51,7 +50,6 @@ function f2() {
}
return sum;
}
%PrepareFunctionForOptimization(f2);
function f3() {
var sum = 0;
......@@ -64,11 +62,11 @@ function f3() {
}
return sum;
}
%PrepareFunctionForOptimization(f3);
function test1() {
var j = 11;
for (var i = 0; i < 2; i++) {
%PrepareFunctionForOptimization(f1);
assertEquals(509500, f1());
}
}
......@@ -76,6 +74,7 @@ function test1() {
function test2() {
for (var i = 0; i < 2; i++) {
var j = 11, k = 12;
%PrepareFunctionForOptimization(f2);
assertEquals(509500, f2());
}
}
......@@ -83,6 +82,7 @@ function test2() {
function test3() {
for (var i = 0; i < 2; i++) {
var j = 11, k = 13, m = 14;
%PrepareFunctionForOptimization(f3);
assertEquals(509500, f3());
}
}
......
......@@ -13,5 +13,6 @@ function f1() {
return sum;
}
%PrepareFunctionForOptimization(f1);
let result = f1(1, 1, 2, 3);
assertEquals(7000, result);
......@@ -12,12 +12,14 @@ function fastaRandom(n, table) {
%OptimizeOsr();
line[0] = n;
n--;
%PrepareFunctionForOptimization(fastaRandom);
}
}
%PrepareFunctionForOptimization(fastaRandom);
print("---BEGIN 1");
%PrepareFunctionForOptimization(fastaRandom);
assertEquals(undefined, fastaRandom(6, null));
print("---BEGIN 2");
%PrepareFunctionForOptimization(fastaRandom);
assertEquals(undefined, fastaRandom(6, null));
print("---END");
......@@ -22,6 +22,9 @@ function foo() {
return result;
}
%PrepareFunctionForOptimization(foo);
assertEquals(4950, foo()());
%PrepareFunctionForOptimization(foo);
assertEquals(4950, foo()());
%PrepareFunctionForOptimization(foo);
assertEquals(4950, foo()());
......@@ -28,10 +28,12 @@ function test(expected, func, depth) {
for (var depth = 1; depth < 4; depth++) {
var body = nest(orig, name, depth);
func = eval("(" + body + ")");
%PrepareFunctionForOptimization(func);
%PrepareFunctionForOptimization(func);
assertEquals(expected, func());
%PrepareFunctionForOptimization(func);
assertEquals(expected, func());
%PrepareFunctionForOptimization(func);
assertEquals(expected, func());
}
}
......@@ -43,6 +45,7 @@ function foo() {
for (var i = 0; i < 10; i++) {
%OptimizeOsr();
sum += i;
%PrepareFunctionForOptimization(foo);
}
result = sum;
}
......@@ -57,6 +60,7 @@ function bar() {
for (var i = 0; i < 10; i++) {
%OptimizeOsr();
sum += i;
%PrepareFunctionForOptimization(bar);
}
return sum;
}
......@@ -87,6 +91,7 @@ function row() {
%OptimizeOsr();
sum = i;
i = i + 1 | 0;
%PrepareFunctionForOptimization(row);
}
}
return 11;
......@@ -100,6 +105,7 @@ function nub() {
while (i < 2) {
%OptimizeOsr();
i++;
%PrepareFunctionForOptimization(nub);
}
return i;
}
......@@ -115,6 +121,7 @@ function kub() {
%OptimizeOsr();
i++;
result = x;
%PrepareFunctionForOptimization(kub);
}
return result;
}
......
......@@ -7,8 +7,11 @@
"use strict";
function test(expected, func) {
%PrepareFunctionForOptimization(func);
assertEquals(expected, func());
%PrepareFunctionForOptimization(func);
assertEquals(expected, func());
%PrepareFunctionForOptimization(func);
assertEquals(expected, func());
}
......@@ -31,24 +34,24 @@ test(4005, bar);
function baz() {
let sum = 0;
for (let i = 0; i < 2; i++) {
%PrepareFunctionForOptimization(baz);
sum = 2;
%OptimizeOsr();
}
return sum;
}
%PrepareFunctionForOptimization(baz);
test(2, baz);
function qux() {
var result = 0;
for (let i = 0; i < 2; i++) {
%PrepareFunctionForOptimization(qux);
result = i;
%OptimizeOsr();
}
return result;
}
%PrepareFunctionForOptimization(qux);
test(1, qux);
......@@ -56,6 +59,7 @@ function nux() {
var result = 0;
for (let i = 0; i < 2; i++) {
{
%PrepareFunctionForOptimization(nux);
let sum = i;
%OptimizeOsr();
result = sum;
......@@ -63,7 +67,6 @@ function nux() {
}
return result;
}
%PrepareFunctionForOptimization(nux);
test(1, nux);
......
......@@ -14,6 +14,7 @@ function foo(t) {
for (var x in t) {
for (var i = 0; i < 2; i++) {
%OptimizeOsr();
%PrepareFunctionForOptimization(foo);
}
}
return 5;
......@@ -28,6 +29,7 @@ function bar(t) {
for (var i = 0; i < 2; i++) {
%OptimizeOsr();
sum += t[x];
%PrepareFunctionForOptimization(bar);
}
}
return sum;
......
......@@ -8,6 +8,7 @@ function foo() {
var sum = 0;
A: for (var i = 0; i < 5; i++) {
B: for (var j = 0; j < 5; j++) {
%PrepareFunctionForOptimization(foo);
C: for (var k = 0; k < 10; k++) {
if (k === 5) %OptimizeOsr();
if (k === 6) break B;
......@@ -18,14 +19,15 @@ function foo() {
return sum;
}
%PrepareFunctionForOptimization(foo);
assertEquals(30, foo());
%PrepareFunctionForOptimization(foo);
assertEquals(30, foo());
function bar(a) {
var sum = 0;
A: for (var i = 0; i < 5; i++) {
B: for (var j = 0; j < 5; j++) {
%PrepareFunctionForOptimization(bar);
C: for (var k = 0; k < 10; k++) {
sum++;
%OptimizeOsr();
......@@ -38,12 +40,16 @@ function bar(a) {
return sum;
}
%PrepareFunctionForOptimization(bar);
assertEquals(1, bar(1));
%PrepareFunctionForOptimization(bar);
assertEquals(1, bar(1));
%PrepareFunctionForOptimization(bar);
assertEquals(5, bar(2));
%PrepareFunctionForOptimization(bar);
assertEquals(5, bar(2));
%PrepareFunctionForOptimization(bar);
assertEquals(25, bar(3));
%PrepareFunctionForOptimization(bar);
assertEquals(25, bar(3));
......@@ -8,6 +8,7 @@ function mod() {
function f0() {
for (var i = 0; i < 3; i = i + 1 | 0) {
%OptimizeOsr();
%PrepareFunctionForOptimization(f0);
}
return {blah: i};
}
......@@ -16,6 +17,7 @@ function mod() {
function f1(a) {
for (var i = 0; i < 3; i = i + 1 | 0) {
%OptimizeOsr();
%PrepareFunctionForOptimization(f1);
}
return {blah: i};
}
......@@ -24,6 +26,7 @@ function mod() {
function f2(a,b) {
for (var i = 0; i < 3; i = i + 1 | 0) {
%OptimizeOsr();
%PrepareFunctionForOptimization(f2);
}
return {blah: i};
}
......@@ -32,6 +35,7 @@ function mod() {
function f3(a,b,c) {
for (var i = 0; i < 3; i = i + 1 | 0) {
%OptimizeOsr();
%PrepareFunctionForOptimization(f3);
}
return {blah: i};
}
......@@ -40,6 +44,7 @@ function mod() {
function f4(a,b,c,d) {
for (var i = 0; i < 3; i = i + 1 | 0) {
%OptimizeOsr();
%PrepareFunctionForOptimization(f4);
}
return {blah: i};
}
......
......@@ -8,6 +8,7 @@ function mod() {
function f0() {
for (var i = 0; i < 3; i = i + 1 | 0) {
%OptimizeOsr();
%PrepareFunctionForOptimization(f0);
}
return {blah: i};
}
......@@ -16,6 +17,7 @@ function mod() {
function f1(a) {
for (var i = 0; i < 3; i = i + 1 | 0) {
%OptimizeOsr();
%PrepareFunctionForOptimization(f1);
}
return {blah: i};
}
......@@ -24,6 +26,7 @@ function mod() {
function f2(a,b) {
for (var i = 0; i < 3; i = i + 1 | 0) {
%OptimizeOsr();
%PrepareFunctionForOptimization(f2);
}
return {blah: i};
}
......@@ -32,6 +35,7 @@ function mod() {
function f3(a,b,c) {
for (var i = 0; i < 3; i = i + 1 | 0) {
%OptimizeOsr();
%PrepareFunctionForOptimization(f3);
}
return {blah: i};
}
......@@ -40,6 +44,7 @@ function mod() {
function f4(a,b,c,d) {
for (var i = 0; i < 3; i = i + 1 | 0) {
%OptimizeOsr();
%PrepareFunctionForOptimization(f4);
}
return {blah: i};
}
......
......@@ -8,35 +8,44 @@ function bar(goal) {
var count = 0;
var sum = 11;
var i = 35;
%PrepareFunctionForOptimization(bar);
while (i-- > 33) {
if (count++ == goal) %OptimizeOsr();
sum = sum + i;
}
%PrepareFunctionForOptimization(bar);
while (i-- > 31) {
if (count++ == goal) %OptimizeOsr();
j = 9;
%PrepareFunctionForOptimization(bar);
while (j-- > 7) {
if (count++ == goal) %OptimizeOsr();
sum = sum + j * 3;
}
%PrepareFunctionForOptimization(bar);
while (j-- > 5) {
if (count++ == goal) %OptimizeOsr();
sum = sum + j * 5;
}
}
while (i-- > 29) {
%PrepareFunctionForOptimization(bar);
if (count++ == goal) %OptimizeOsr();
while (j-- > 3) {
var k = 10;
%PrepareFunctionForOptimization(bar);
if (count++ == goal) %OptimizeOsr();
while (k-- > 8) {
%PrepareFunctionForOptimization(bar);
if (count++ == goal) %OptimizeOsr();
sum = sum + k * 11;
}
}
while (j-- > 1) {
%PrepareFunctionForOptimization(bar);
if (count++ == goal) %OptimizeOsr();
while (k-- > 6) {
%PrepareFunctionForOptimization(bar);
if (count++ == goal) %OptimizeOsr();
sum = sum + j * 13;
}
......
......@@ -51,7 +51,7 @@ function gen(i) {
body = body.replace(new RegExp("bar"), "bar" + i);
for (var j = 1; j < 10; j++) {
var r = new RegExp("LOOP" + j + "\\(\\);");
if (i == j) body = body.replace(r, "%OptimizeOsr();");
if (i == j) body = body.replace(r, "%OptimizeOsr(); %PrepareFunctionForOptimization(bar" + i +");");
else body = body.replace(r, "");
}
return eval("(" + body + ")");
......
......@@ -30,6 +30,7 @@
function f() {
var sum = 0;
for (var i = 0; i < 10; i++) {
%PrepareFunctionForOptimization(f);
for (var j = 0; j < 10; j++) {
var x = i + 2;
var y = x + 5;
......
......@@ -10,6 +10,7 @@ function foo(a) {
var r = /\0/;
for (var i = 0; i < 10; i++) {
if (a) %OptimizeOsr();
%PrepareFunctionForOptimization(foo);
}
return r;
}
......@@ -18,6 +19,7 @@ function foo(a) {
function bar(a) {
for (var i = 0; i < 10; i++) {
if (a) %OptimizeOsr();
%PrepareFunctionForOptimization(bar);
var r = /\0/;
}
return r;
......@@ -27,6 +29,7 @@ function bar(a) {
function baz(a) {
for (var i = 0; i < 10; i++) {
if (a) %OptimizeOsr();
%PrepareFunctionForOptimization(baz);
}
return /\0/;
}
......@@ -36,6 +39,7 @@ function qux(a) {
for (var i = 0; i < 10; i++) {
if (i > 5 && a) {
%OptimizeOsr();
%PrepareFunctionForOptimization(qux);
} else {
var r = /\0/;
}
......@@ -47,8 +51,11 @@ function qux(a) {
function test(f) {
// Test the reference equality of regex's created in OSR'd function.
var x = f(false);
%PrepareFunctionForOptimization(f);
assertEquals(x, f(true));
%PrepareFunctionForOptimization(f);
assertEquals(x, f(true));
%PrepareFunctionForOptimization(f);
assertEquals(x, f(true));
}
......
......@@ -4,13 +4,17 @@
// Flags: --use-osr --allow-natives-syntax
var sum = 0;
for (var i = 0; i < 10000; i++) {
if (i == 100) %OptimizeOsr();
var x = i + 2;
var y = x + 5;
var z = y + 3;
sum += z;
}
function f() {
var sum = 0;
for (var i = 0; i < 10000; i++) {
if (i == 100) %OptimizeOsr();
var x = i + 2;
var y = x + 5;
var z = y + 3;
sum += z;
}
assertEquals(50095000, sum);
assertEquals(50095000, sum);
}
%PrepareFunctionForOptimization(f);
f();
......@@ -4,16 +4,21 @@
// Flags: --use-osr --allow-natives-syntax
for (var j = 0; j < 3; j++) {
var sum = 0;
for (var i = 0; i < 1000; i++) {
if (i == 100) %OptimizeOsr();
var x = i + 2;
var y = x + 5;
var z = y + 3;
sum += z;
function f() {
for (var j = 0; j < 3; j++) {
var sum = 0;
for (var i = 0; i < 1000; i++) {
if (i == 100) %OptimizeOsr();
var x = i + 2;
var y = x + 5;
var z = y + 3;
sum += z;
}
assertEquals(509500, sum);
%PrepareFunctionForOptimization(f);
}
assertEquals(509500, sum);
}
assertEquals(509500, sum);
%PrepareFunctionForOptimization(f);
f();
......@@ -4,19 +4,24 @@
// Flags: --use-osr --allow-natives-syntax
for (var k = 0; k < 2; k++) {
for (var j = 0; j < 3; j++) {
var sum = 0;
for (var i = 0; i < 1000; i++) {
if (i == 100) %OptimizeOsr();
var x = i + 2;
var y = x + 5;
var z = y + 3;
sum += z;
function f() {
for (var k = 0; k < 2; k++) {
for (var j = 0; j < 3; j++) {
var sum = 0;
for (var i = 0; i < 1000; i++) {
if (i == 100) %OptimizeOsr();
var x = i + 2;
var y = x + 5;
var z = y + 3;
sum += z;
}
assertEquals(509500, sum);
%PrepareFunctionForOptimization(f);
}
assertEquals(509500, sum);
}
assertEquals(509500, sum);
}
assertEquals(509500, sum);
%PrepareFunctionForOptimization(f);
f();
......@@ -16,6 +16,7 @@ function SingleLoop() {
catch(e) {}
for (var b = 0; b < 1; b++) {
%OptimizeOsr();
%PrepareFunctionForOptimization(SingleLoop);
}
}
}
......@@ -37,6 +38,7 @@ function EmptyBody() {
if (a == 1) break;
a++;
%PrepareFunctionForOptimization(EmptyBody);
}
}
%PrepareFunctionForOptimization(EmptyBody);
......@@ -52,6 +54,7 @@ function NestedLoops() {
if (b == 1) break;
b++;
}
%PrepareFunctionForOptimization(NestedLoops);
}
}
%PrepareFunctionForOptimization(NestedLoops);
......
......@@ -17,6 +17,7 @@ function f(x) {
}
}
outer--;
%PrepareFunctionForOptimization(f);
}
return sum;
}
......
......@@ -26,6 +26,7 @@ function foo() {
for (; flag == 1; (flag = 0, temp_x = x)) {
if (x < 2) {
result = x; %OptimizeOsr();
%PrepareFunctionForOptimization(foo);
} else {
break outer;
}
......@@ -48,6 +49,7 @@ function smo() {
let y = x;
for (var i = 0; i < 5; i++) {
%OptimizeOsr();
%PrepareFunctionForOptimization(smo);
if (i) break outer;
else result = y;
}
......
......@@ -10,7 +10,10 @@
function g() {
for (var x in a) {
try {
for (var i = 0; i < 10; i++) { %OptimizeOsr(); }
for (var i = 0; i < 10; i++) {
%OptimizeOsr();
%PrepareFunctionForOptimization(g);
}
return;
} catch(e) {
continue;
......@@ -28,7 +31,10 @@
function g() {
for (var x in a) {
if (x) {
for (var i = 0; i < 10; i++) { %OptimizeOsr(); }
for (var i = 0; i < 10; i++) {
%OptimizeOsr();
%PrepareFunctionForOptimization(g);
}
}
continue;
}
......
......@@ -11,6 +11,7 @@ function f() {
sum = sum + 1;
%OptimizeOsr();
if (sum == 2) return;
%PrepareFunctionForOptimization(f);
}
}
return sum;
......
......@@ -9,5 +9,5 @@ function f() {
if (i == 5) %OptimizeOsr();
}
}
%EnsureFeedbackVectorForFunction(f);
%PrepareFunctionForOptimization(f);
f();
......@@ -55,6 +55,7 @@
for (var k = 0; k < 10; ++k) {
if (k == 5) %OptimizeOsr();
}
%PrepareFunctionForOptimization(gen4);
}
yield i;
}
......
......@@ -31,11 +31,14 @@
function f(a, deopt, osr) {
var result = (a + 10, "result");
var dummy = deopt + 0;
for (var i = 0; osr && i < 2; i++) %OptimizeOsr();
for (var i = 0; osr && i < 2; i++) {
%PrepareFunctionForOptimization(f);
%OptimizeOsr();
}
return result;
}
%PrepareFunctionForOptimization(f);
%PrepareFunctionForOptimization(f);
assertEquals("result", f(true, 3, false));
assertEquals("result", f(true, 3, false));
%OptimizeFunctionOnNextCall(f);
......
......@@ -31,7 +31,10 @@ function f(deopt, osr) {
var result = "result";
%_Call(function() {}, 0, 0);
var dummy = deopt + 0;
for (var i = 0; osr && i < 2; i++) %OptimizeOsr();
for (var i = 0; osr && i < 2; i++) {
%PrepareFunctionForOptimization(f);
%OptimizeOsr();
}
return result;
}
......
......@@ -46,7 +46,10 @@ function g() { try { return o.f(); } finally { }}
// This function should be optimized via OSR.
function h() {
for (var i = 0; i < 10; i++) %OptimizeOsr();
for (var i = 0; i < 10; i++) {
%OptimizeOsr();
%PrepareFunctionForOptimization(h);
}
g();
}
%PrepareFunctionForOptimization(h);
......
......@@ -38,7 +38,10 @@ assertFalse(isAlwaysOptimize());
function f() {
do {
do {
for (var i = 0; i < 10; i++) %OptimizeOsr();
for (var i = 0; i < 10; i++) {
%OptimizeOsr();
%PrepareFunctionForOptimization(f);
}
// Note: this check can't be wrapped in a function, because
// calling that function causes a deopt from lack of call
// feedback.
......@@ -70,7 +73,10 @@ function g() {
do {
do {
do {
for (var i = 0; i < 10; i++) %OptimizeOsr();
for (var i = 0; i < 10; i++) {
%OptimizeOsr();
%PrepareFunctionForOptimization(g);
}
var opt_status = %GetOptimizationStatus(g);
assertTrue(
(opt_status & V8OptimizationStatus.kMaybeDeopted) !== 0 ||
......
......@@ -10,16 +10,22 @@ function Cb(a, trigger) {
g = a.charCodeAt(f);
// This will fail after OSR if Runtime_StringCharCodeAt is modified
// to iterates optimized frames and visit safepoint pointers.
if (g == "C".charCodeAt(0)) %OptimizeOsr();
if (g == "C".charCodeAt(0)) {
%OptimizeOsr();
%PrepareFunctionForOptimization(Cb);
}
}
return g;
}
%PrepareFunctionForOptimization(Cb);
var s1 = "long string to make cons string 1";
var s2 = "long string to make cons string 2";
%PrepareFunctionForOptimization(Cb);
Cb(s1 + s2);
%PrepareFunctionForOptimization(Cb);
Cb(s1);
var s3 = "string for triggering osr in Cb";
%PrepareFunctionForOptimization(Cb);
Cb(s3 + s3);
%PrepareFunctionForOptimization(Cb);
Cb(s1 + s2);
......@@ -13,6 +13,7 @@ function foo(a) {
return sum;
}
%PrepareFunctionForOptimization(foo);
assertEquals("0a", foo());
assertEquals("0a", foo());
%OptimizeFunctionOnNextCall(foo);
......
......@@ -46,7 +46,10 @@
function outer() {
inner(1,2,3);
for (var i = 0; i < 3; i++) %OptimizeOsr();
for (var i = 0; i < 3; i++) {
%OptimizeOsr();
%PrepareFunctionForOptimization(outer);
}
}
%PrepareFunctionForOptimization(outer);
......
......@@ -9,7 +9,10 @@ function f() {
r[r] = function() {};
}
for (var i = 0; i < 300; i++) {
f();
if (i == 150) %OptimizeOsr();
function g() {
for (var i = 0; i < 300; i++) {
f();
if (i == 150) %OptimizeOsr();
}
}
%PrepareFunctionForOptimization(g);
......@@ -28,7 +28,7 @@ function g(obj) {
return obj.foo.length;
}
%PrepareFunctionForOptimization(f);
%PrepareFunctionForOptimization(g);
g(dummy);
g(dummy);
%OptimizeFunctionOnNextCall(g);
......
......@@ -10,6 +10,7 @@ function f(foo) {
if (null != g) {}
};
%PrepareFunctionForOptimization(f);
f(1.4);
f(1.4);
%OptimizeFunctionOnNextCall(f);
......
......@@ -10,6 +10,7 @@ var body =
" while (i-- > 31) {" +
" %OptimizeOsr(); " +
" j = 9; " +
" %PrepareFunctionForOptimization(bar1); " +
" while (j-- > 7);" +
" } " +
" return i; " +
......
......@@ -10,6 +10,7 @@ var f1 = (function() {
function f() { return g(); }
return f;
})();
%PrepareFunctionForOptimization(f1);
assertThrows("f1()");
%OptimizeFunctionOnNextCall(f1);
assertThrows("f1()");
......
......@@ -7,6 +7,7 @@
function f() {
with ({ value:"foo" }) { return value; }
}
%PrepareFunctionForOptimization(f);
assertEquals("foo", f());
%OptimizeFunctionOnNextCall(f);
assertEquals("foo", f());
......@@ -11,6 +11,7 @@ function f() {
function g() {
try { f(); } catch(e) { }
%PrepareFunctionForOptimization(g);
for (var i = 0; i < 3; ++i) if (i === 1) %OptimizeOsr();
%_DeoptimizeNow();
}
......
......@@ -12,5 +12,6 @@ var foo = (function() {
return function() { o.x = null; }
})();
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo);
foo();
......@@ -7,6 +7,7 @@
{
function f() {
for(let i = 0; i < 10; ++i){
%PrepareFunctionForOptimization(f);
try{
// Carefully constructed by a fuzzer to use a new register for s(), whose
// write is dead due to the unconditional throw after s()=N, but which is
......@@ -17,6 +18,6 @@
%OptimizeOsr();
}
}
%PrepareFunctionForOptimization(f);
%EnsureFeedbackVectorForFunction(f);
f();
}
......@@ -35,6 +35,7 @@ if (!%IsConcurrentRecompilationSupported()) {
}
function test(fun) {
%PrepareFunctionForOptimization(fun);
fun();
fun();
// Mark for concurrent optimization.
......
......@@ -14,6 +14,7 @@ function f(o) {
return result;
}
%PrepareFunctionForOptimization(f);
f(o);
f(o);
%OptimizeFunctionOnNextCall(f);
......
......@@ -8,6 +8,7 @@ function f() {
for (i = 0; i < 2; i++)
var x = i, // var x that's assigned on each iteration
y = y||(()=>x), // single arrow function that returns x
z0 = (%PrepareFunctionForOptimization(y)), // prepare function for optimization
z = (%OptimizeFunctionOnNextCall(y), y()); // optimize y on first iteration
return y()
};
......
......@@ -19,8 +19,8 @@ function get_closure() {
return x;
}
}
%PrepareFunctionForOptimization(get_closure);
var f1 = get_closure();
%PrepareFunctionForOptimization(f1);
f1(new Ctor(), false);
f1(new Ctor(), false);
......@@ -28,6 +28,7 @@ f1(new Ctor(), false);
// Kick off concurrent recompilation and OSR.
var o = new Ctor();
%PrepareFunctionForOptimization(f1);
f1(o, true);
// Flush the optimizing compiler's queue.
......@@ -37,4 +38,5 @@ f1(o, true);
o.c = 2.2;
var f2 = get_closure();
%PrepareFunctionForOptimization(f2);
f2(new Ctor(), true);
......@@ -13,6 +13,8 @@ function foo() {
let g1 = foo();
let g2 = foo();
%PrepareFunctionForOptimization(g1);
%PrepareFunctionForOptimization(g2);
g1({ f : 1});
g1({ f : 2});
......
......@@ -614,6 +614,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
deopt = true;
g();
assertOptimized(g);
%PrepareFunctionForOptimization(g);
deopt = false;
array = [11,'22',33,45,56,6,77,84,93,101];
Object.seal(array);
......@@ -645,6 +646,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
deopt = true;
g();
assertOptimized(g);
%PrepareFunctionForOptimization(g);
deopt = false;
array = [11,'22',33,45,56,6,77,84,93,101];
Object.seal(array);
......@@ -689,6 +691,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
deopt = true;
g();
assertOptimized(g);
%PrepareFunctionForOptimization(g);
deopt = false;
array = [11,'22',33,45,56,6,77,84,93,101];
Object.seal(array);
......@@ -744,7 +747,10 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
done = true;
assertEquals(null, g());
assertOptimized(g);
%PrepareFunctionForOptimization(g);
%OptimizeFunctionOnNextCall(g);
done = false;
%PrepareFunctionForOptimization(g);
g(); g();
%OptimizeFunctionOnNextCall(g);
g();
......@@ -779,7 +785,10 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
done = true;
assertEquals(null, g());
assertOptimized(g);
%PrepareFunctionForOptimization(g);
done = false;
%OptimizeFunctionOnNextCall(g);
%PrepareFunctionForOptimization(g);
g(); g();
%OptimizeFunctionOnNextCall(g);
g();
......@@ -815,6 +824,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
assertEquals(null, g());
assertOptimized(g);
done = false;
%PrepareFunctionForOptimization(g);
g(); g();
%OptimizeFunctionOnNextCall(g);
g();
......@@ -851,6 +861,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
assertEquals(null, g());
assertOptimized(g);
done = false;
%PrepareFunctionForOptimization(g);
g(); g();
%OptimizeFunctionOnNextCall(g);
g();
......@@ -910,6 +921,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
assertEquals(null, g());
assertOptimized(g);
done = false;
%PrepareFunctionForOptimization(g);
g(); g();
%OptimizeFunctionOnNextCall(g);
g();
......@@ -948,6 +960,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
assertEquals(null, g());
assertOptimized(g);
done = false;
%PrepareFunctionForOptimization(g);
g(); g();
%OptimizeFunctionOnNextCall(g);
g();
......@@ -1049,6 +1062,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
g();
assertOptimized(g);
deopt = true;
%PrepareFunctionForOptimization(g);
g();
deopt = false;
array = [11,'22',33,45,56,6,77,84,93,101];
......@@ -1105,6 +1119,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
done = true;
assertEquals(null, g());
done = false;
%PrepareFunctionForOptimization(g);
g(); g();
%OptimizeFunctionOnNextCall(g);
g();
......@@ -1140,6 +1155,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
assertEquals(null, g());
assertOptimized(g);
done = false;
%PrepareFunctionForOptimization(g);
g(); g();
%OptimizeFunctionOnNextCall(g);
g();
......@@ -1175,6 +1191,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
assertEquals(null, g());
assertOptimized(g);
done = false;
%PrepareFunctionForOptimization(g);
g(); g();
%OptimizeFunctionOnNextCall(g);
g();
......@@ -1211,6 +1228,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
done = true;
assertEquals(null, g());
done = false;
%PrepareFunctionForOptimization(g);
g(); g();
%OptimizeFunctionOnNextCall(g);
g();
......@@ -1269,6 +1287,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
assertEquals(null, g());
assertOptimized(g);
done = false;
%PrepareFunctionForOptimization(g);
g(); g();
%OptimizeFunctionOnNextCall(g);
g();
......@@ -1307,6 +1326,7 @@ assertEquals(undefined, Object.seal(arr).reduceRight(function(val) { return val
assertEquals(null, g());
assertOptimized(g);
done = false;
%PrepareFunctionForOptimization(g);
g(); g();
%OptimizeFunctionOnNextCall(g);
g();
......
......@@ -68,11 +68,12 @@ function strictCallNonStrict(n) {
"use strict";
nonstrictToBeInlined(n);
}
%PrepareFunctionForOptimization(strictCallNonStrict);
(function testInlineNonStrictInStrict() {
for (var i = 0; i <= MAX; i ++) {
try {
if (i == MAX - 1) %OptimizeFunctionOnNextCall(nonstrictCallStrict);
if (i == MAX - 1) %OptimizeFunctionOnNextCall(strictCallNonStrict);
strictCallNonStrict(i);
} catch (e) {
fail("no exception", "exception");
......@@ -88,6 +89,7 @@ function strictAssignToUndefined(n) {
global = "strict";
if (n == MAX) { undefined_variable_strict_2 = "value"; }
}
%PrepareFunctionForOptimization(nonstrictCallStrict);
(function testOptimizeStrictAssignToUndefined() {
for (var i = 0; i <= MAX; i ++) {
......
......@@ -155,6 +155,7 @@ TEST_F(LapContextTest, CurrentContextInLazyAccessorOnPlatformObject) {
caller_context->Global()->Set(caller_context, object_key, object).ToChecked();
const char script[] =
"function f() { object.property; object.property = 0; } "
"%PrepareFunctionForOptimization(f);"
"f(); f(); "
"%OptimizeFunctionOnNextCall(f); "
"f();";
......@@ -210,6 +211,7 @@ TEST_F(LapContextTest, CurrentContextInLazyAccessorOnInterface) {
.ToChecked();
const char script[] =
"function f() { Interface.property; Interface.property = 0; } "
"%PrepareFunctionForOptimization(f);"
"f(); f(); "
"%OptimizeFunctionOnNextCall(f); "
"f();";
......
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