Commit 55e8d613 authored by Mythri A's avatar Mythri A Committed by Commit Bot

[Test] Add %PrepareForOptimization in tests

With bytecode flushing and lazy feedback allocation, we need to call
%PrepareForOptimization before we call %OptimizeFunctionOnNextCall

Bug: v8:8801, v8:8394
Change-Id: I1f84477a8cef27b4cff61b54daf6fe1a9e5f8e76
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1591775
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61148}
parent 6b9af6b7
......@@ -10,6 +10,7 @@ function push(array, value) {
array.push(value);
}
%PrepareFunctionForOptimization(push);
push(array, 0);
push(array, 1);
push(array, 2);
......
......@@ -26,6 +26,8 @@
}
assertPromiseResult((async () => {
%PrepareFunctionForOptimization(one);
%PrepareFunctionForOptimization(two);
await test(one);
await test(one);
%OptimizeFunctionOnNextCall(two);
......@@ -57,6 +59,8 @@
}
assertPromiseResult((async() => {
%PrepareFunctionForOptimization(one);
%PrepareFunctionForOptimization(two);
await test(one);
await test(one);
%OptimizeFunctionOnNextCall(two);
......@@ -92,6 +96,8 @@
}
assertPromiseResult((async() => {
%PrepareFunctionForOptimization(one);
%PrepareFunctionForOptimization(two);
await test(one);
await test(one);
%OptimizeFunctionOnNextCall(two);
......@@ -131,6 +137,8 @@
}
assertPromiseResult((async() => {
%PrepareFunctionForOptimization(callOne);
%PrepareFunctionForOptimization(callTwo);
await test(callOne);
await test(callOne);
%OptimizeFunctionOnNextCall(callTwo);
......@@ -164,6 +172,8 @@
}
assertPromiseResult((async() => {
%PrepareFunctionForOptimization(one);
%PrepareFunctionForOptimization(two);
await test(one);
await test(one);
%OptimizeFunctionOnNextCall(two);
......@@ -196,6 +206,8 @@
}
assertPromiseResult((async () => {
%PrepareFunctionForOptimization(one);
%PrepareFunctionForOptimization(two);
await test(one);
await test(one);
%OptimizeFunctionOnNextCall(two);
......@@ -228,6 +240,8 @@
}
assertPromiseResult((async () => {
%PrepareFunctionForOptimization(one);
%PrepareFunctionForOptimization(two);
await test(one);
await test(one);
%OptimizeFunctionOnNextCall(two);
......@@ -260,6 +274,8 @@
}
assertPromiseResult((async () => {
%PrepareFunctionForOptimization(one);
%PrepareFunctionForOptimization(two);
await test(one);
await test(one);
%OptimizeFunctionOnNextCall(two);
......@@ -291,6 +307,8 @@
}
assertPromiseResult((async () => {
%PrepareFunctionForOptimization(one);
%PrepareFunctionForOptimization(two);
await test(one);
await test(one);
%OptimizeFunctionOnNextCall(two);
......
......@@ -34,6 +34,7 @@ function aoo(i) {
return a[i + 1];
}
%PrepareFunctionForOptimization(aoo);
aoo(1);
aoo(-1);
%OptimizeFunctionOnNextCall(aoo);
......@@ -51,6 +52,7 @@ function boo(i) {
return ret;
}
%PrepareFunctionForOptimization(boo);
boo(1);
boo(-1);
%OptimizeFunctionOnNextCall(boo);
......@@ -67,6 +69,7 @@ function coo() {
return ret;
}
%PrepareFunctionForOptimization(coo);
coo();
coo();
%OptimizeFunctionOnNextCall(coo);
......@@ -81,6 +84,7 @@ function doo() {
}
return ret;
}
%PrepareFunctionForOptimization(doo);
doo();
doo();
%OptimizeFunctionOnNextCall(doo);
......@@ -97,6 +101,7 @@ function eoo() {
return ret;
}
%PrepareFunctionForOptimization(eoo);
eoo();
eoo();
%OptimizeFunctionOnNextCall(eoo);
......@@ -118,6 +123,7 @@ function foo() {
return ret;
}
%PrepareFunctionForOptimization(foo);
foo();
foo();
%OptimizeFunctionOnNextCall(foo);
......@@ -133,6 +139,7 @@ function goo(i) {
return a[i + 3];
}
%PrepareFunctionForOptimization(goo);
goo(-1);
goo(-1);
%OptimizeFunctionOnNextCall(goo);
......@@ -147,6 +154,7 @@ function hoo() {
return a[index() + 3];
}
%PrepareFunctionForOptimization(hoo);
hoo();
hoo();
%OptimizeFunctionOnNextCall(hoo);
......@@ -157,6 +165,7 @@ function ioo(i) {
return a[i] + a[i + 1];
}
%PrepareFunctionForOptimization(ioo);
ioo(1);
ioo(1);
%OptimizeFunctionOnNextCall(ioo);
......
......@@ -15,8 +15,8 @@ function foo(i, deopt = false) {
}
}
%PrepareFunctionForOptimization(foo);
assertEquals(0, %GetDeoptCount(foo));
foo(10);
foo(10);
%OptimizeFunctionOnNextCall(foo);
......
......@@ -8,6 +8,7 @@ function f1(a, i) {
return a[i] + 0.5;
}
var arr = [,0.0,2.5];
%PrepareFunctionForOptimization(f1);
assertEquals(0.5, f1(arr, 1));
assertEquals(0.5, f1(arr, 1));
%OptimizeFunctionOnNextCall(f1);
......
......@@ -30,6 +30,7 @@
function f1(a, i) {
return a[i] + 0.5;
}
%PrepareFunctionForOptimization(f1);
var arr = [0.0,,2.5];
assertEquals(0.5, f1(arr, 0));
assertEquals(0.5, f1(arr, 0));
......
......@@ -39,6 +39,7 @@ function Turbo(count = 10000) {
return sum;
}
%PrepareFunctionForOptimization(Turbo);
Turbo(10);
Turbo(10);
%OptimizeFunctionOnNextCall(Turbo);
......
......@@ -36,6 +36,7 @@ var functions = [ f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14,
for (var i = 0; i < functions.length; ++i) {
var func = functions[i];
%PrepareFunctionForOptimization(func);
print("Testing:");
print(func);
for (var j = 0; j < 10; ++j) {
......@@ -317,6 +318,7 @@ function TestThrow() {
throw x;
}
}
%PrepareFunctionForOptimization(f);
for (var i = 0; i < 5; i++) {
try {
f();
......@@ -341,6 +343,7 @@ TestThrow();
function TestFunctionLocal(s) {
'use strict';
var func = eval("(function baz(){" + s + "; })");
%PrepareFunctionForOptimization(func);
print("Testing:");
print(func);
for (var i = 0; i < 5; ++i) {
......@@ -363,6 +366,7 @@ function TestFunctionLocal(s) {
function TestFunctionContext(s) {
'use strict';
var func = eval("(function baz(){ " + s + "; (function() { x; }); })");
%PrepareFunctionForOptimization(func);
print("Testing:");
print(func);
for (var i = 0; i < 5; ++i) {
......@@ -389,6 +393,7 @@ function TestFunctionContext(s) {
function TestBlockLocal(s) {
'use strict';
var func = eval("(function baz(){ { " + s + "; } })");
%PrepareFunctionForOptimization(func);
print("Testing:");
print(func);
for (var i = 0; i < 5; ++i) {
......@@ -411,6 +416,7 @@ function TestBlockLocal(s) {
function TestBlockContext(s) {
'use strict';
var func = eval("(function baz(){ { " + s + "; (function() { x; }); } })");
%PrepareFunctionForOptimization(func);
print("Testing:");
print(func);
for (var i = 0; i < 5; ++i) {
......@@ -469,6 +475,9 @@ function g(x) {
}
}
%PrepareFunctionForOptimization(f);
%PrepareFunctionForOptimization(g);
for (var i=0; i<10; i++) {
f(i);
g(i);
......
......@@ -37,6 +37,7 @@ function f1() {
assertEquals(1, x)
assertEquals(undefined, y)
}
%PrepareFunctionForOptimization(f1);
for (var j = 0; j < 5; ++j) f1();
%OptimizeFunctionOnNextCall(f1);
f1();
......@@ -85,6 +86,7 @@ function f3(one) {
assertEquals(8, b.foo());
}
}
%PrepareFunctionForOptimization(f3);
for (var j = 0; j < 5; ++j) f3(1);
%OptimizeFunctionOnNextCall(f3);
f3(1);
......
......@@ -39,6 +39,7 @@ function f1() {
assertEquals(1, x)
assertEquals(undefined, y)
}
%PrepareFunctionForOptimization(f1);
for (var j = 0; j < 5; ++j) f1();
%OptimizeFunctionOnNextCall(f1);
f1();
......@@ -87,6 +88,7 @@ function f3(one) {
assertEquals(8, b.foo());
}
}
%PrepareFunctionForOptimization(f3);
for (var j = 0; j < 5; ++j) f3(1);
%OptimizeFunctionOnNextCall(f3);
f3(1);
......
......@@ -20,6 +20,7 @@
return maxWithZero(x, y);
}
%PrepareFunctionForOptimization(testMax);
testMax(1, 2);
testMax(1, 2);
%OptimizeFunctionOnNextCall(testMax);
......
......@@ -8,6 +8,7 @@
'use strict';
function testBaselineAndOpt(func) {
%PrepareFunctionForOptimization(func);
func(-1, -2);
func(-1, -2);
%OptimizeFunctionOnNextCall(func);
......@@ -76,6 +77,7 @@
(function() {
function testBaselineAndOpt(func) {
%PrepareFunctionForOptimization(func);
func(-1, -2);
func(-1, -2);
%OptimizeFunctionOnNextCall(func);
......
......@@ -25,6 +25,7 @@ function TestSetWithCustomIterator(ctor) {
// code which causes the code to deopt.
global = entries;
}
%PrepareFunctionForOptimization(TestSetWithCustomIterator);
TestSetWithCustomIterator(Set);
TestSetWithCustomIterator(Set);
TestSetWithCustomIterator(Set);
......@@ -33,6 +34,7 @@ TestSetWithCustomIterator(Set);
assertOptimized(TestSetWithCustomIterator);
TestSetWithCustomIterator(WeakSet);
%PrepareFunctionForOptimization(TestSetWithCustomIterator);
TestSetWithCustomIterator(WeakSet);
TestSetWithCustomIterator(WeakSet);
%OptimizeFunctionOnNextCall(TestSetWithCustomIterator);
......@@ -58,6 +60,7 @@ function TestMapWithCustomIterator(ctor) {
// code which causes the code to deopt.
global = entries;
}
%PrepareFunctionForOptimization(TestMapWithCustomIterator);
TestMapWithCustomIterator(Map);
TestMapWithCustomIterator(Map);
TestMapWithCustomIterator(Map);
......@@ -66,6 +69,7 @@ TestMapWithCustomIterator(Map);
assertOptimized(TestMapWithCustomIterator);
TestMapWithCustomIterator(WeakMap);
%PrepareFunctionForOptimization(TestMapWithCustomIterator);
TestMapWithCustomIterator(WeakMap);
TestMapWithCustomIterator(WeakMap);
%OptimizeFunctionOnNextCall(TestMapWithCustomIterator);
......
......@@ -20,6 +20,7 @@ function g({x = {a:10,b:20}},
assertSame(0, n.length);
assertTrue(p.test("abc"));
}
%PrepareFunctionForOptimization(g);
g({},{});
%OptimizeFunctionOnNextCall(g);
g({},{});
......@@ -35,6 +36,7 @@ var h = ({x = {a:10,b:20}},
assertSame(0, n.length);
assertTrue(p.test("abc"));
};
%PrepareFunctionForOptimization(h);
h({},{});
%OptimizeFunctionOnNextCall(h);
h({},{});
......@@ -11,6 +11,7 @@
function foo(x) {
return x instanceof Array;
}
%PrepareFunctionForOptimization(foo);
assertTrue(foo([]));
assertFalse(foo({}));
%OptimizeFunctionOnNextCall(foo);
......@@ -42,6 +43,7 @@
}
return false;
}
%PrepareFunctionForOptimization(foo_catch);
assertTrue(foo_catch(o));
%OptimizeFunctionOnNextCall(foo_catch);
assertTrue(foo_catch(o));
......
......@@ -33,6 +33,7 @@ function TestMapConstructorEntrySideEffect(ctor) {
assertFalse(col.has(k3));
}
%PrepareFunctionForOptimization(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(Map);
TestMapConstructorEntrySideEffect(Map);
TestMapConstructorEntrySideEffect(Map);
......@@ -41,6 +42,7 @@ TestMapConstructorEntrySideEffect(Map);
assertOptimized(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(WeakMap);
%PrepareFunctionForOptimization(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(WeakMap);
TestMapConstructorEntrySideEffect(WeakMap);
%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
......
......@@ -28,6 +28,7 @@ function TestMapConstructorEntrySideEffect(ctor) {
assertTrue(col.has(k3));
}
%PrepareFunctionForOptimization(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(Map);
TestMapConstructorEntrySideEffect(Map);
TestMapConstructorEntrySideEffect(Map);
......@@ -36,6 +37,7 @@ TestMapConstructorEntrySideEffect(Map);
assertOptimized(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(WeakMap);
%PrepareFunctionForOptimization(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(WeakMap);
TestMapConstructorEntrySideEffect(WeakMap);
%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
......
......@@ -20,6 +20,7 @@ assertFalse(Realm.eval(realm, "1; Realm.global(0) instanceof Object"));
// Test that the instannceof check works in optimized code.
var test = Realm.eval(realm,
"()=>{1.1; return Realm.global(0) instanceof Object; }");
%PrepareFunctionForOptimization(test);
assertFalse(test());
test();
test();
......
......@@ -1510,6 +1510,7 @@ function TestConstructorWithProxyPrototype2(create, handler) {
function f() {
return o.x;
}
%PrepareFunctionForOptimization(f);
assertEquals(10, f());
assertEquals(10, f());
%OptimizeFunctionOnNextCall(f);
......
......@@ -45,6 +45,7 @@ assertEquals([1, 1, 1], f1(1));
function f1_(x) {
return [...[x, x, x]];
}
%PrepareFunctionForOptimization(f1_);
assertEquals([1, 1, 1], f1_(1));
%OptimizeFunctionOnNextCall(f1_);
assertEquals([1, 1, 1], f1_(1));
......@@ -64,6 +65,7 @@ assertEquals([1, 1, 1, ,], f2(1));
function f2_(x) {
return [...[x, x, x], ,];
}
%PrepareFunctionForOptimization(f2_);
assertEquals([1, 1, 1, ,], f2_(1));
%OptimizeFunctionOnNextCall(f2_);
assertEquals([1, 1, 1, ,], f2_(1));
......@@ -83,6 +85,7 @@ assertEquals([1, 0.1, "1", , ], f3(g(1, 0.1, "1")));
function f3_(it) {
return [...it, ,];
}
%PrepareFunctionForOptimization(f3_);
assertEquals([1, 0.1, "1", , ], f3_(g(1, 0.1, "1")));
%OptimizeFunctionOnNextCall(f3_);
assertEquals([1, 0.1, "1", , ], f3_(g(1, 0.1, "1")));
......@@ -102,6 +105,7 @@ assertEquals([1, 1, 1], f4(1));
function f4_(x) {
return [...[x, x, x]];
}
%PrepareFunctionForOptimization(f4_);
assertEquals([1, 1, 1], f4_(1));
%OptimizeFunctionOnNextCall(f4_);
assertEquals([1, 1, 1], f4_(1));
......@@ -121,6 +125,7 @@ assertEquals([1, 1, 1, ,], f5(1));
function f5_(x) {
return [...[x, x, x], ,];
}
%PrepareFunctionForOptimization(f5_);
assertEquals([1, 1, 1, ,], f5_(1));
%OptimizeFunctionOnNextCall(f5_);
assertEquals([1, 1, 1, ,], f5_(1));
......@@ -140,6 +145,7 @@ assertEquals([1, 0.1, "1", , ], f6(g(1, 0.1, "1")));
function f6_(it) {
return [...it, ,];
}
%PrepareFunctionForOptimization(f6_);
assertEquals([1, 0.1, "1", , ], f6_(g(1, 0.1, "1")));
%OptimizeFunctionOnNextCall(f6_);
assertEquals([1, 0.1, "1", , ], f6_(g(1, 0.1, "1")));
......@@ -159,6 +165,7 @@ assertEquals([1, 0.1, "1"], f7(G(1, 0.1, "1")));
function f7_(it) {
return [...it];
}
%PrepareFunctionForOptimization(f7_);
assertEquals([1, 0.1, "1"], f7_(G(1, 0.1, "1")));
%OptimizeFunctionOnNextCall(f7_);
assertEquals([1, 0.1, "1"], f7_(G(1, 0.1, "1")));
......@@ -178,6 +185,7 @@ assertEquals([1, 0.1, "1", , ], f8(G(1, 0.1, "1")));
function f8_(it) {
return [...it, ,];
}
%PrepareFunctionForOptimization(f8_);
assertEquals([1, 0.1, "1", , ], f8_(G(1, 0.1, "1")));
%OptimizeFunctionOnNextCall(f8_);
assertEquals([1, 0.1, "1", , ], f8_(G(1, 0.1, "1")));
......@@ -190,6 +198,7 @@ assertEquals([1, 0.1, "1", , ], f8_(G(1, 0.1, "1")));
function* f9() {
for (let i = 0; i < 160000; ++i) yield i;
}
%PrepareFunctionForOptimization(f9);
let a = [...f9()];
assertEquals(160000, a.length);
assertEquals(0, a[0]);
......@@ -263,6 +272,7 @@ function f10(b) {
...b];
return x.length;
}
%PrepareFunctionForOptimization(f10);
assertEquals(4335, f10([3.3, 3.3, 3.3]));
assertEquals(4335, f10([{}, "", 3.3]));
%OptimizeFunctionOnNextCall(f10);
......
......@@ -23,6 +23,7 @@
function testRestPoint(x, y) {
return new RestPoint(x, y);
}
%PrepareFunctionForOptimization(testRestPoint);
testRestPoint(1, 2);
testRestPoint(1, 2);
%OptimizeFunctionOnNextCall(testRestPoint);
......
......@@ -28,6 +28,7 @@
function testArgumentsPoint(x, y) {
return new ArgumentsPoint(x, y);
}
%PrepareFunctionForOptimization(testArgumentsPoint);
testArgumentsPoint(1, 2);
testArgumentsPoint(1, 2);
%OptimizeFunctionOnNextCall(testArgumentsPoint);
......
......@@ -15,6 +15,7 @@
}
function testBaselineAndOpt(func) {
%PrepareFunctionForOptimization(func);
func(1, 2);
func(1, 2);
%OptimizeFunctionOnNextCall(func);
......
......@@ -52,6 +52,7 @@ if (standalone) {
assertUnoptimized = empty_func;
assertOptimized = empty_func;
prepareForOptimize = emtpy_func;
optimize = empty_func;
clearFunctionTypeFeedback = empty_func;
deoptimizeFunction = empty_func;
......@@ -59,6 +60,9 @@ if (standalone) {
optimize = function(name) {
%OptimizeFunctionOnNextCall(name);
}
prepareForOptimize = function(name) {
%PrepareFunctionForOptimization(name);
}
clearFunctionTypeFeedback = function(name) {
%ClearFunctionFeedback(name);
}
......@@ -76,6 +80,7 @@ function base_getter_test(create_func) {
var ap = [];
ap.__defineGetter__(0, function() { calls++; return 0; });
prepareForOptimize(foo);
foo(a);
assertUnoptimized(foo);
// Smi and Double elements transition the KeyedLoadIC to Generic state
......@@ -145,6 +150,7 @@ function base_getter_test(create_func) {
a = create_func();
ap2 = [];
a.__proto__ = ap2;
prepareForOptimize(foo);
foo(a);
foo(a);
foo(a);
......@@ -165,6 +171,7 @@ function base_getter_test(create_func) {
a = create_func();
a.__proto__ = ap2;
bar = function(a) { return a[3] + 600; }
prepareForOptimize(bar);
bar(a);
bar(a);
bar(a);
......@@ -207,6 +214,7 @@ for(var c = 0; c < cf.length; c++) {
var a = [3.5,,,3.5];
fun = function(a) { return a[0] + 5.5; }
prepareForOptimize(fun);
fun(a);
fun(a);
fun(a); // should have a monomorphic KeyedLoadIC.
......@@ -229,6 +237,7 @@ var a = [3.5,,,,3.5];
var ap = [,,3.5];
ap.__proto__ = a.__proto__;
a.__proto__ = ap;
prepareForOptimize(fun);
fun(a);
optimize(fun);
fun(a);
......
......@@ -6,6 +6,7 @@
"use strict";
function test(expected, f) {
%PrepareFunctionForOptimization(f);
assertEquals(expected, f());
assertEquals(expected, f());
%OptimizeFunctionOnNextCall(f);
......@@ -14,6 +15,7 @@ function test(expected, f) {
}
function testThrows(f) {
%PrepareFunctionForOptimization(f);
assertThrows(f);
assertThrows(f);
%OptimizeFunctionOnNextCall(f);
......
......@@ -5,6 +5,7 @@
// Flags: --allow-natives-syntax
function test(expected, f) {
%PrepareFunctionForOptimization(f);
assertEquals(expected, f());
assertEquals(expected, f());
%OptimizeFunctionOnNextCall(f);
......@@ -13,6 +14,7 @@ function test(expected, f) {
}
function testThrows(f) {
%PrepareFunctionForOptimization(f);
assertThrows(f);
assertThrows(f);
%OptimizeFunctionOnNextCall(f);
......
......@@ -85,6 +85,7 @@ function variable_bound() {
}
function test(f) {
%PrepareFunctionForOptimization(f);
f();
assertTrue(f());
%OptimizeFunctionOnNextCall(f);
......
......@@ -180,6 +180,7 @@ function test_div() {
}
}
%PrepareFunctionForOptimization(test_div);
test_div();
%OptimizeFunctionOnNextCall(test_div);
test_div();
......@@ -201,6 +202,7 @@ function test_div2() {
}
}
%PrepareFunctionForOptimization(test_div2);
test_div2();
%OptimizeFunctionOnNextCall(test_div2);
test_div2();
......@@ -244,6 +246,9 @@ function test_div_deopt_div_by_zero() {
}
}
%PrepareFunctionForOptimization(test_div_deopt_minus_zero);
%PrepareFunctionForOptimization(test_div_deopt_overflow);
%PrepareFunctionForOptimization(test_div_deopt_div_by_zero);
test_div_deopt_minus_zero();
test_div_deopt_overflow();
test_div_deopt_div_by_zero();
......@@ -277,6 +282,9 @@ function test_div_deopt_div_by_zero_v() {
}
}
%PrepareFunctionForOptimization(test_div_deopt_minus_zero_v);
%PrepareFunctionForOptimization(test_div_deopt_overflow_v);
%PrepareFunctionForOptimization(test_div_deopt_div_by_zero_v);
test_div_deopt_minus_zero_v();
test_div_deopt_overflow_v();
test_div_deopt_div_by_zero_v();
......
......@@ -117,6 +117,7 @@ assertEquals(Infinity, 1/Math.max(ZERO, -0));
assertEquals(Infinity, 1/Math.max(-0, ZERO));
function run(crankshaft_test) {
%PrepareFunctionForOptimization(crankshaft_test);
crankshaft_test(1);
crankshaft_test(1);
%OptimizeFunctionOnNextCall(crankshaft_test);
......@@ -184,6 +185,7 @@ function f(o) {
return Math.min(o.a, o.b);
}
%PrepareFunctionForOptimization(f);
assertEquals(1, f(o));
assertEquals(1, f(o));
%OptimizeFunctionOnNextCall(f);
......
......@@ -7,6 +7,7 @@
export let x = 0;
function foo() { x++ };
%PrepareFunctionForOptimization(foo);
foo();
%OptimizeFunctionOnNextCall(foo);
foo();
......
......@@ -22,7 +22,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
return v;
}
a.map(callback);
}
};
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled();
eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled);
......@@ -42,7 +43,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
return v;
}
a.map(callback);
}
};
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled();
eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled);
......@@ -65,7 +67,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
return v;
}
a_noescape.map(callback);
}
};
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled();
eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled);
......@@ -92,7 +95,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
};
%NeverOptimizeFunction(callback);
b.map(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -115,7 +119,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
};
%NeverOptimizeFunction(callback);
return b.map(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
assertEquals([2,4,6], lazyDeopt());
assertEquals([2,4,6], lazyDeopt());
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -134,7 +139,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
return v;
}
b.map(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -157,7 +163,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
};
%NeverOptimizeFunction(callback);
b.map(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -181,7 +188,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
return v;
}
c.map(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -209,7 +217,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
} catch (e) {
caught = true;
}
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -238,7 +247,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
} catch (e) {
caught = true;
}
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -269,7 +279,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
result = "nope";
}
return result;
}
};
%PrepareFunctionForOptimization(lazyDeopt);
assertEquals([2,4,6,8], lazyDeopt(false));
assertEquals([2,4,6,8], lazyDeopt(false));
assertEquals("nope", lazyDeopt(true));
......@@ -294,7 +305,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
};
var o = [1,2,3];
b.map(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -317,7 +329,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
%NeverOptimizeFunction(callback);
var o = [1,2,3];
b.map(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -341,7 +354,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
};
var o = [1,2,3];
b.map(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -362,7 +376,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
return v;
};
a.map(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
assertThrows(() => lazyDeopt());
assertThrows(() => lazyDeopt());
try {
......@@ -395,7 +410,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
}
}
return c.map(callback);
}
};
%PrepareFunctionForOptimization(to_double);
to_double();
to_double();
%OptimizeFunctionOnNextCall(to_double);
......@@ -425,7 +441,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
}
}
return c.map(callback);
}
};
%PrepareFunctionForOptimization(to_fast);
to_fast();
to_fast();
%OptimizeFunctionOnNextCall(to_fast);
......@@ -445,6 +462,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
var callback = v => v + 0.5;
return a.map(callback);
}
%PrepareFunctionForOptimization(double_results);
double_results();
double_results();
%OptimizeFunctionOnNextCall(double_results);
......@@ -461,6 +479,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
var callback = v => "hello" + v.toString();
return a.map(callback);
}
%PrepareFunctionForOptimization(string_results);
string_results();
string_results();
%OptimizeFunctionOnNextCall(string_results);
......@@ -479,6 +498,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
return v;
});
}
%PrepareFunctionForOptimization(withHoles);
withHoles();
withHoles();
%OptimizeFunctionOnNextCall(withHoles);
......@@ -496,6 +516,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
return v;
});
}
%PrepareFunctionForOptimization(withHoles);
withHoles();
withHoles();
%OptimizeFunctionOnNextCall(withHoles);
......@@ -513,6 +534,7 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
}
let a = [1, 2, 3];
%PrepareFunctionForOptimization(unreliable);
unreliable(a, false);
unreliable(a, false);
%OptimizeFunctionOnNextCall(unreliable);
......@@ -531,7 +553,8 @@ var c = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25];
return v;
}
a.map(callback);
}
};
%PrepareFunctionForOptimization(species_breakage);
species_breakage();
species_breakage();
%OptimizeFunctionOnNextCall(species_breakage);
......
......@@ -22,6 +22,7 @@
return r + "S";
}, "H");
}
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled();
eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled);
......@@ -38,7 +39,8 @@
a = [,,,]; // also a holey smi array.
}
return a.reduce((r,v,i,o)=>r+v);
}
};
%PrepareFunctionForOptimization(nothingThere);
nothingThere();
nothingThere();
%OptimizeFunctionOnNextCall(nothingThere);
......@@ -62,6 +64,7 @@
} catch (e) {
assertTrue(re.exec(e.stack) !== null);
}
%PrepareFunctionForOptimization(alwaysThrows);
try { alwaysThrows(); } catch (e) {}
try { alwaysThrows(); } catch (e) {}
%OptimizeFunctionOnNextCall(alwaysThrows);
......
......@@ -13,6 +13,7 @@ function f() {
r.test("ABcd");
}
%PrepareFunctionForOptimization(f);
f();
assertEquals(1, counter);
%OptimizeFunctionOnNextCall(f);
......
......@@ -15,6 +15,7 @@ function add(a, b) {
return a.x + b.x;
}
%PrepareFunctionForOptimization(add);
assertEquals(3, add(f, g));
assertEquals(3, add(g, f));
%OptimizeFunctionOnNextCall(add);
......
......@@ -76,6 +76,11 @@ function testCall() {
obj();
}
%PrepareFunctionForOptimization(testCompares);
%PrepareFunctionForOptimization(testIfs);
%PrepareFunctionForOptimization(testWhiles);
%PrepareFunctionForOptimization(testFors);
%PrepareFunctionForOptimization(testCall);
for (var j = 0; j < 5; j++) {
testCompares();
testIfs();
......
......@@ -49,6 +49,7 @@ function test(object, prototype) {
return s.strict;
}
%PrepareFunctionForOptimization(nonstrict);
nonstrict(object);
nonstrict(object);
%OptimizeFunctionOnNextCall(nonstrict);
......@@ -56,6 +57,7 @@ function test(object, prototype) {
nonstrict(object);
assertEquals("object", typeof result);
%PrepareFunctionForOptimization(strict);
strict(object);
strict(object);
%OptimizeFunctionOnNextCall(strict);
......@@ -72,6 +74,7 @@ function test(object, prototype) {
return s.strict = 10;
}
%PrepareFunctionForOptimization(nonstrict);
nonstrict(object);
nonstrict(object);
%OptimizeFunctionOnNextCall(nonstrict);
......@@ -79,6 +82,7 @@ function test(object, prototype) {
nonstrict(object);
assertEquals("object", typeof result);
%PrepareFunctionForOptimization(strict);
strict(object);
strict(object);
%OptimizeFunctionOnNextCall(strict);
......
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