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