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

Reland "[Test] Update tests to work with lazy feedback allocation."

This is a reland of 289b2576.
The fix for failures landed here:
https://chromium-review.googlesource.com/c/v8/v8/+/1599388

Original change's description:
> [Test] Update tests to work with lazy feedback allocation.
>
> This adds either %EnsureFeedbackVectorForFunction or
> %PrepareFunctionForOptimization to allocate feedback vectors when testing
> optimization, allocation sites, IC transitions etc.,
>
> Bug: v8:8394
> Change-Id: I6ad1b6d460e4abda693b326cddb87754e080a0a1
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1593303
> Commit-Queue: Mythri Alle <mythria@chromium.org>
> Auto-Submit: Mythri Alle <mythria@chromium.org>
> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#61212}

Bug: v8:8394
Change-Id: Idb5bba221d138e6fd73155f959b9e16fc948c709
TBR: rmcilroy@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1599607Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Auto-Submit: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61332}
parent f3f3f289
......@@ -784,7 +784,9 @@ TEST(InvocationCount) {
CompileRun(
"function bar() {};"
"%EnsureFeedbackVectorForFunction(bar);"
"function foo() { return bar(); };"
"%EnsureFeedbackVectorForFunction(foo);"
"foo();");
Handle<JSFunction> foo = Handle<JSFunction>::cast(GetGlobalProperty("foo"));
CHECK_EQ(1, foo->feedback_vector()->invocation_count());
......
......@@ -37,6 +37,7 @@ function ChangeSmiConstantAndOsr() {
}
return j;
}
%PrepareFunctionForOptimization(ChangeSmiConstantAndOsr);
var r1 = ChangeSmiConstantAndOsr();
if (changed) {
assertEquals("result", r1);
......@@ -54,6 +55,7 @@ function ChangeFloatConstantAndOsr() {
}
return j;
}
%PrepareFunctionForOptimization(ChangeFloatConstantAndOsr);
var r2 = ChangeFloatConstantAndOsr();
if (changed) {
assertEquals("result", r2);
......@@ -72,6 +74,7 @@ function ChangeFloatVarAndOsr() {
}
return j;
}
%PrepareFunctionForOptimization(ChangeFloatVarAndOsr);
var r3 = ChangeFloatVarAndOsr();
if (changed) {
assertEquals("result0.1", r3);
......@@ -105,6 +108,7 @@ function ChangeIntVarAndOsr() {
}
return j;
}
%PrepareFunctionForOptimization(ChangeIntVarAndOsr);
var r4 = ChangeIntVarAndOsr();
if (changed) {
......
......@@ -7,9 +7,13 @@ var Debug = debug.Debug;
Debug.setListener(() => undefined);
const myObj = {};
function f() {
const myObj = {};
for (let i = 0; i < 10; i++) {
%OptimizeOsr();
%ScheduleBreak();
for (let i = 0; i < 10; i++) {
%OptimizeOsr();
%ScheduleBreak();
}
}
%PrepareFunctionForOptimization(f);
f()
......@@ -9,6 +9,7 @@ Debug.setListener(function() {});
function f() {
for (var i = 0; i < 100; i++) %OptimizeOsr();
}
%PrepareFunctionForOptimization(f);
Debug.setBreakPoint(f, 0, 0);
f();
......
......@@ -23,6 +23,7 @@ function wrapper1() {
}
f1();
}
%PrepareFunctionForOptimization(wrapper1);
function f2() {
counter++;
......
......@@ -67,6 +67,7 @@ function assertKind(expected, obj, name_opt) {
function bar0(t) {
return new t();
}
%PrepareFunctionForOptimization(bar0);
a = bar0(Array);
a[0] = 3.5;
b = bar0(Array);
......@@ -77,7 +78,8 @@ function assertKind(expected, obj, name_opt) {
assertOptimized(bar0);
// bar0 should deopt
b = bar0(Object);
assertUnoptimized(bar0)
assertUnoptimized(bar0);
%PrepareFunctionForOptimization(bar0);
// When it's re-optimized, we should call through the full stub
bar0(Array);
%OptimizeFunctionOnNextCall(bar0);
......@@ -99,6 +101,7 @@ function assertKind(expected, obj, name_opt) {
function bar() {
return new Array();
}
%PrepareFunctionForOptimization(bar);
a = bar();
bar();
%OptimizeFunctionOnNextCall(bar);
......@@ -115,6 +118,7 @@ function assertKind(expected, obj, name_opt) {
// map for Array in that context will be used.
(function() {
function bar() { return new Array(); }
%PrepareFunctionForOptimization(bar);
bar();
bar();
%OptimizeFunctionOnNextCall(bar);
......@@ -134,6 +138,7 @@ function assertKind(expected, obj, name_opt) {
// should deal with arguments that create holey arrays.
(function() {
function bar(len) { return new Array(len); }
%PrepareFunctionForOptimization(bar);
bar(0);
bar(0);
%OptimizeFunctionOnNextCall(bar);
......@@ -153,6 +158,7 @@ function assertKind(expected, obj, name_opt) {
// Test: Make sure that crankshaft continues with feedback for large arrays.
(function() {
function bar(len) { return new Array(len); }
%PrepareFunctionForOptimization(bar);
var size = 100001;
// Perform a gc, because we are allocating a very large array and if a gc
// happens during the allocation we could lose our memento.
......
......@@ -79,6 +79,7 @@ function array_literal_test() {
assertEquals(2, f0[1]);
assertEquals(1, f0[0]);
}
%PrepareFunctionForOptimization(array_literal_test);
%PrepareFunctionForOptimization(array_literal_test);
for (var i = 0; i < 3; i++) {
......@@ -109,6 +110,7 @@ function test_large_literal() {
[0, 1, 2, 3, 4, 5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5,
new Object(), new Object(), new Object(), new Object()]);
}
%PrepareFunctionForOptimization(test_large_literal);
%PrepareFunctionForOptimization(test_large_literal);
for (var i = 0; i < 3; i++) {
......@@ -124,6 +126,7 @@ function deopt_array(use_literal) {
return new Array();
}
}
%PrepareFunctionForOptimization(deopt_array);
%PrepareFunctionForOptimization(deopt_array);
deopt_array(false);
......@@ -142,6 +145,7 @@ assertOptimized(deopt_array);
function deopt_array_literal_all_smis(a) {
return [0, 1, a];
}
%PrepareFunctionForOptimization(deopt_array_literal_all_smis);
%PrepareFunctionForOptimization(deopt_array_literal_all_smis);
deopt_array_literal_all_smis(2);
......@@ -168,6 +172,7 @@ assertEquals(.5, array[2]);
function deopt_array_literal_all_doubles(a) {
return [0.5, 1, a];
}
%PrepareFunctionForOptimization(deopt_array_literal_all_doubles);
%PrepareFunctionForOptimization(deopt_array_literal_all_doubles);
deopt_array_literal_all_doubles(.5);
......
......@@ -17,6 +17,7 @@ function makeArray() {
return a;
}
%PrepareFunctionForOptimization(doShift);
doShift(makeArray());
doShift(makeArray());
%OptimizeFunctionOnNextCall(doShift);
......
......@@ -197,6 +197,7 @@ assertEquals(0.5, array_store_1([], 0, 0.5));
a[b] = c;
}
%PrepareFunctionForOptimization(grow_store);
a = new Array(1);
grow_store(a,1,1);
grow_store(a,2,1);
......@@ -216,6 +217,7 @@ assertEquals(0.5, array_store_1([], 0, 0.5));
function f(o, k, v) {
o[k] = v;
}
%PrepareFunctionForOptimization(f);
a = [3.5];
f(a, 1, "hi"); // DOUBLE packed array -> tagged packed grow
......@@ -238,6 +240,7 @@ assertEquals(0.5, array_store_1([], 0, 0.5));
function f(o, k, v) {
o[k] = v;
}
%PrepareFunctionForOptimization(f);
a = [3.5];
f(a, 0, "hi"); // DOUBLE packed array -> tagged packed grow
......
......@@ -21,6 +21,7 @@
}
%PrepareFunctionForOptimization(slice0);
%PrepareFunctionForOptimization(slice);
assertEquals(arr, slice());
assertFalse(arr === slice());
......@@ -29,7 +30,6 @@
%OptimizeFunctionOnNextCall(slice0);
assertEquals(slice(), slice0());
%PrepareFunctionForOptimization(slice);
%OptimizeFunctionOnNextCall(slice);
assertEquals(slice(), slice0());
......@@ -415,6 +415,7 @@
function test() {
%PrepareFunctionForOptimization(slice0);
%PrepareFunctionForOptimization(slice);
assertEquals(arr, slice());
assertFalse(arr === slice());
......@@ -423,7 +424,6 @@
%OptimizeFunctionOnNextCall(slice0);
assertEquals(slice(), slice0());
%PrepareFunctionForOptimization(slice);
%OptimizeFunctionOnNextCall(slice);
assertEquals(slice(), slice0());
......@@ -455,13 +455,13 @@
}
function test() {
%PrepareFunctionForOptimization(slice0);
%PrepareFunctionForOptimization(slice);
assertEquals(arr, slice());
assertFalse(arr === slice());
assertEquals(slice(), slice0());
assertEquals(slice0(), slice());
%PrepareFunctionForOptimization(slice0);
%PrepareFunctionForOptimization(slice);
%OptimizeFunctionOnNextCall(slice0);
assertEquals(slice(), slice0());
%OptimizeFunctionOnNextCall(slice);
......
......@@ -38,6 +38,7 @@ function f() {
arr[500] = 20;
arr[10] = arr[50];
}
%EnsureFeedbackVectorForFunction(f);
function g() {
f();
......
......@@ -32,6 +32,7 @@
(function() {
// Produce a SpeculativeNumberEqual with Number feedback.
function bar(x, y) { return x === y; }
%EnsureFeedbackVectorForFunction(bar);
bar(0.1, 0.5);
bar(-0, 100);
......@@ -83,6 +84,7 @@
(function() {
// Produce a SpeculativeNumberLessThan with Number feedback.
function bar(x, y) { return x < y; }
%EnsureFeedbackVectorForFunction(bar);
bar(0.1, 0.5);
bar(-0, 100);
......@@ -134,6 +136,7 @@
(function() {
// Produce a SpeculativeNumberLessThanOrEqual with Number feedback.
function bar(x, y) { return x <= y; }
%EnsureFeedbackVectorForFunction(bar);
bar(0.1, 0.5);
bar(-0, 100);
......
......@@ -269,6 +269,7 @@ function osr_inner(t, limit) {
}
return r;
}
%PrepareFunctionForOptimization(osr_inner);
function osr_outer(t, osr_after) {
var r = 1;
......@@ -281,6 +282,7 @@ function osr_outer(t, osr_after) {
}
return r;
}
%PrepareFunctionForOptimization(osr_outer);
function osr_outer_and_deopt(t, osr_after) {
var r = 1;
......@@ -290,6 +292,7 @@ function osr_outer_and_deopt(t, osr_after) {
}
return r;
}
%PrepareFunctionForOptimization(osr_outer_and_deopt);
function test_osr() {
with ({}) {} // Disable optimizations of this function.
......
......@@ -38,6 +38,7 @@ function f1() {
}
return sum;
}
%PrepareFunctionForOptimization(f1);
function f2() {
var sum = 0;
......@@ -50,6 +51,7 @@ function f2() {
}
return sum;
}
%PrepareFunctionForOptimization(f2);
function f3() {
var sum = 0;
......@@ -62,6 +64,7 @@ function f3() {
}
return sum;
}
%PrepareFunctionForOptimization(f3);
function test1() {
var j = 11;
......
......@@ -14,6 +14,7 @@ function fastaRandom(n, table) {
n--;
}
}
%PrepareFunctionForOptimization(fastaRandom);
print("---BEGIN 1");
assertEquals(undefined, fastaRandom(6, null));
......
......@@ -41,4 +41,5 @@ function f(x, b, c) {
return a + 4;
}
%PrepareFunctionForOptimization(f);
assertEquals(55, f(5, "122", "1221"));
......@@ -24,6 +24,7 @@ function foo() {
result.push(out);
return result;
}
%PrepareFunctionForOptimization(foo);
function check() {
......
......@@ -28,6 +28,7 @@ function test(expected, func, depth) {
for (var depth = 1; depth < 4; depth++) {
var body = nest(orig, name, depth);
func = eval("(" + body + ")");
%PrepareFunctionForOptimization(func);
assertEquals(expected, func());
assertEquals(expected, func());
......@@ -47,6 +48,7 @@ function foo() {
}
return result;
}
%PrepareFunctionForOptimization(foo);
test(45, foo);
......@@ -58,6 +60,7 @@ function bar() {
}
return sum;
}
%PrepareFunctionForOptimization(bar);
test(45, bar);
......@@ -71,6 +74,7 @@ function bon() {
return sum;
}
}
%PrepareFunctionForOptimization(bon);
test(45, bon);
......@@ -87,6 +91,7 @@ function row() {
}
return 11;
}
%PrepareFunctionForOptimization(row);
test(7, row);
......@@ -98,6 +103,7 @@ function nub() {
}
return i;
}
%PrepareFunctionForOptimization(nub);
test(2, nub);
......@@ -112,5 +118,6 @@ function kub() {
}
return result;
}
%PrepareFunctionForOptimization(kub);
test(1, kub);
......@@ -24,6 +24,7 @@ function bar() {
}
return result;
}
%PrepareFunctionForOptimization(bar);
test(4005, bar);
......@@ -35,6 +36,7 @@ function baz() {
}
return sum;
}
%PrepareFunctionForOptimization(baz);
test(2, baz);
......@@ -46,6 +48,7 @@ function qux() {
}
return result;
}
%PrepareFunctionForOptimization(qux);
test(1, qux);
......@@ -60,6 +63,7 @@ function nux() {
}
return result;
}
%PrepareFunctionForOptimization(nux);
test(1, nux);
......@@ -78,5 +82,6 @@ function blo() {
}
return result;
}
%PrepareFunctionForOptimization(blo);
test(4005, blo());
......@@ -18,6 +18,7 @@ function foo(t) {
}
return 5;
}
%PrepareFunctionForOptimization(foo);
test(5, foo, {x:20});
......@@ -31,5 +32,6 @@ function bar(t) {
}
return sum;
}
%PrepareFunctionForOptimization(bar);
test(62, bar, {x:20,y:11});
......@@ -11,6 +11,7 @@ function thrower() {
if (x == 5) %OptimizeOsr(1);
if (x == 10) throw "terminate";
}
%PrepareFunctionForOptimization(thrower);
%NeverOptimizeFunction(thrower); // Don't want to inline the thrower.
%NeverOptimizeFunction(test); // Don't want to inline the func into test.
......@@ -25,18 +26,22 @@ function test(func) {
function n1() {
while (true) thrower();
}
%PrepareFunctionForOptimization(n1);
function n2() {
while (true) while (true) thrower();
}
%PrepareFunctionForOptimization(n2);
function n3() {
while (true) while (true) while (true) thrower();
}
%PrepareFunctionForOptimization(n3);
function n4() {
while (true) while (true) while (true) while (true) thrower();
}
%PrepareFunctionForOptimization(n4);
function b1(a) {
while (true) {
......@@ -44,6 +49,7 @@ function b1(a) {
if (a) break
}
}
%PrepareFunctionForOptimization(b1);
function b2(a) {
......@@ -54,6 +60,7 @@ function b2(a) {
}
}
}
%PrepareFunctionForOptimization(b2);
function b3(a) {
......@@ -67,6 +74,7 @@ function b3(a) {
}
}
}
%PrepareFunctionForOptimization(b3);
test(n1);
......
......@@ -17,6 +17,7 @@ function foo() {
}
return sum;
}
%PrepareFunctionForOptimization(foo);
assertEquals(30, foo());
assertEquals(30, foo());
......@@ -36,6 +37,7 @@ function bar(a) {
}
return sum;
}
%PrepareFunctionForOptimization(bar);
assertEquals(1, bar(1));
assertEquals(1, bar(1));
......
......@@ -11,6 +11,7 @@ function mod() {
}
return {blah: i};
}
%PrepareFunctionForOptimization(f0);
function f1(a) {
for (var i = 0; i < 3; i = i + 1 | 0) {
......@@ -18,6 +19,7 @@ function mod() {
}
return {blah: i};
}
%PrepareFunctionForOptimization(f1);
function f2(a,b) {
for (var i = 0; i < 3; i = i + 1 | 0) {
......@@ -25,6 +27,7 @@ function mod() {
}
return {blah: i};
}
%PrepareFunctionForOptimization(f2);
function f3(a,b,c) {
for (var i = 0; i < 3; i = i + 1 | 0) {
......@@ -32,6 +35,7 @@ function mod() {
}
return {blah: i};
}
%PrepareFunctionForOptimization(f3);
function f4(a,b,c,d) {
for (var i = 0; i < 3; i = i + 1 | 0) {
......@@ -39,6 +43,7 @@ function mod() {
}
return {blah: i};
}
%PrepareFunctionForOptimization(f4);
function bar() {
assertEquals(3, f0().blah);
......
......@@ -11,6 +11,7 @@ function mod() {
}
return {blah: i};
}
%PrepareFunctionForOptimization(f0);
function f1(a) {
for (var i = 0; i < 3; i = i + 1 | 0) {
......@@ -18,6 +19,7 @@ function mod() {
}
return {blah: i};
}
%PrepareFunctionForOptimization(f1);
function f2(a,b) {
for (var i = 0; i < 3; i = i + 1 | 0) {
......@@ -25,6 +27,7 @@ function mod() {
}
return {blah: i};
}
%PrepareFunctionForOptimization(f2);
function f3(a,b,c) {
for (var i = 0; i < 3; i = i + 1 | 0) {
......@@ -32,6 +35,7 @@ function mod() {
}
return {blah: i};
}
%PrepareFunctionForOptimization(f3);
function f4(a,b,c,d) {
for (var i = 0; i < 3; i = i + 1 | 0) {
......@@ -39,6 +43,7 @@ function mod() {
}
return {blah: i};
}
%PrepareFunctionForOptimization(f4);
function bar() {
assertEquals(3, f0().blah);
......
......@@ -22,10 +22,12 @@ function gen(w) { // defeat compiler cache.
"} f" + num;
return eval(src);
}
%PrepareFunctionForOptimization(gen);
function check(x,a,b,c) {
for (var i = 0; i < 3; i++) {
var f = gen(i);
%PrepareFunctionForOptimization(f);
assertEquals(x, f(a, b, c));
}
}
......
......@@ -26,6 +26,7 @@ function gen(w) { // defeat compiler cache.
function check(x,a,b,c) {
for (var i = 0; i < 3; i++) {
var f = gen(i);
%PrepareFunctionForOptimization(f);
assertEquals(x, f(a, b, c));
}
}
......
......@@ -44,6 +44,7 @@ function bar(goal) {
}
return sum;
}
%PrepareFunctionForOptimization(bar);
for (var i = 0; i < 13; i++) {
%DeoptimizeFunction(bar);
......
......@@ -59,5 +59,6 @@ function gen(i) {
for (var i = 1; i < 10; i++) {
var f = gen(i);
%PrepareFunctionForOptimization(f);
assertEquals(1979, f());
}
......@@ -40,6 +40,7 @@ function f() {
}
return sum;
}
%PrepareFunctionForOptimization(f);
assertEquals(1450, f());
......
......@@ -19,7 +19,7 @@ function f() {
return sum;
}
%PrepareFunctionForOptimization(f);
assertEquals(15000, f());
assertEquals(15000, f());
assertEquals(15000, f());
......@@ -16,5 +16,6 @@ function f(x) {
}
return sum;
}
%PrepareFunctionForOptimization(f);
assertEquals(50, f(5));
......@@ -13,6 +13,7 @@ function foo(a) {
}
return r;
}
%PrepareFunctionForOptimization(foo);
function bar(a) {
for (var i = 0; i < 10; i++) {
......@@ -21,6 +22,7 @@ function bar(a) {
}
return r;
}
%PrepareFunctionForOptimization(bar);
function baz(a) {
for (var i = 0; i < 10; i++) {
......@@ -28,6 +30,7 @@ function baz(a) {
}
return /\0/;
}
%PrepareFunctionForOptimization(baz);
function qux(a) {
for (var i = 0; i < 10; i++) {
......@@ -39,6 +42,7 @@ function qux(a) {
}
return r;
}
%PrepareFunctionForOptimization(qux);
function test(f) {
// Test the reference equality of regex's created in OSR'd function.
......
......@@ -15,6 +15,7 @@ function f() {
}
return sum;
}
%PrepareFunctionForOptimization(f);
for (var i = 0; i < 2; i++) {
......
......@@ -19,6 +19,7 @@ function SingleLoop() {
}
}
}
%PrepareFunctionForOptimization(SingleLoop);
// These function could also fail if the exception handlers are not updated at
......@@ -38,6 +39,7 @@ function EmptyBody() {
a++;
}
}
%PrepareFunctionForOptimization(EmptyBody);
function NestedLoops() {
for (var a = 0; a < 2; a++) {
......@@ -52,6 +54,7 @@ function NestedLoops() {
}
}
}
%PrepareFunctionForOptimization(NestedLoops);
SingleLoop();
......
......@@ -20,5 +20,6 @@ function f(x) {
}
return sum;
}
%PrepareFunctionForOptimization(f);
assertEquals(500, f(5));
......@@ -35,6 +35,7 @@ function foo() {
}
return result;
}
%PrepareFunctionForOptimization(foo);
test(1, foo);
......@@ -54,5 +55,6 @@ function smo() {
}
return result;
}
%PrepareFunctionForOptimization(smo);
test(11, smo);
......@@ -18,6 +18,7 @@
}
}
%PrepareFunctionForOptimization(g);
g();
})();
......@@ -33,5 +34,6 @@
}
}
%PrepareFunctionForOptimization(g);
g();
})();
......@@ -16,4 +16,5 @@ function f() {
return sum;
}
%PrepareFunctionForOptimization(f);
f();
......@@ -13,4 +13,5 @@ function f() {
return x;
}
%PrepareFunctionForOptimization(f);
assertEquals(0, f());
......@@ -6,12 +6,14 @@
(function() {
"use asm";
return function() {
var f = function() {
for (var i = 0; i < 10; i++) {
if (i == 5) {
%OptimizeOsr();
}
}
with (Object());
}
};
%PrepareFunctionForOptimization(f);
return f;
})()();
......@@ -12,4 +12,5 @@ function f() {
}
}
%PrepareFunctionForOptimization(f);
f();
......@@ -13,4 +13,5 @@ function foo() {
}
}
%PrepareFunctionForOptimization(foo);
foo();
......@@ -12,4 +12,5 @@ function f(get, ...a) {
}
return get();
}
%PrepareFunctionForOptimization(f);
assertThrows(f);
......@@ -11,6 +11,7 @@ function foo(o) {
}
}
%PrepareFunctionForOptimization(foo);
foo([1]);
foo([1]);
%OptimizeFunctionOnNextCall(foo);
......
......@@ -13,6 +13,7 @@ function OSRInsideTry(x) {
}
return x + 2;
}
%PrepareFunctionForOptimization(OSRInsideTry);
assertEquals(24, OSRInsideTry(23));
......@@ -25,6 +26,7 @@ function OSRInsideCatch(x) {
}
return x + 2;
}
%PrepareFunctionForOptimization(OSRInsideCatch);
assertEquals(24, OSRInsideCatch(23));
......@@ -37,6 +39,7 @@ function OSRInsideFinally_Return(x) {
}
return x + 2;
}
%PrepareFunctionForOptimization(OSRInsideFinally_Return);
assertEquals(24, OSRInsideFinally_Return(23));
......@@ -48,4 +51,5 @@ function OSRInsideFinally_ReThrow(x) {
}
return x + 2;
}
%PrepareFunctionForOptimization(OSRInsideFinally_ReThrow);
assertThrows("OSRInsideFinally_ReThrow(new Error)", Error);
......@@ -44,6 +44,7 @@ if (!%IsConcurrentRecompilationSupported()) {
function f1(a, i) {
return a[i] + 0.5;
}
%PrepareFunctionForOptimization(f1);
%PrepareFunctionForOptimization(f1);
var arr = [0.0,,2.5];
......
......@@ -99,6 +99,7 @@ function TestLoadFromConstantFieldOfAPrototype(the_value, other_value) {
// Ensure O.prototype is in fast mode by loading from its field.
function warmup() { return new O().v; }
%EnsureFeedbackVectorForFunction(warmup);
warmup(); warmup(); warmup();
assertTrue(%HasFastProperties(O.prototype));
......
......@@ -14,6 +14,7 @@ function foo(i, deopt = false) {
foo(i - 1, deopt);
}
}
%PrepareFunctionForOptimization(foo);
assertEquals(0, %GetDeoptCount(foo));
......
......@@ -14,6 +14,7 @@ function foo(i, deopt = false) {
foo(i - 1, deopt);
}
}
%PrepareFunctionForOptimization(foo);
%PrepareFunctionForOptimization(foo);
assertEquals(0, %GetDeoptCount(foo));
......
......@@ -18,6 +18,7 @@ function foo(i, deopt = false, deoptobj = null) {
assertEquals(0, %GetDeoptCount(foo));
%PrepareFunctionForOptimization(foo);
foo(10);
foo(10);
%OptimizeFunctionOnNextCall(foo);
......
......@@ -75,6 +75,7 @@ function test(a, b, c, d, e, v) {
assertEquals(24, d);
assertEquals(37.5, e);
}
%PrepareFunctionForOptimization(test);
test(10.0, 20.0, 30.0, 40.0, 50.0, 1.5);
......
......@@ -6,6 +6,7 @@
function f(x, y) { return x + y; }
%PrepareFunctionForOptimization(f);
assertEquals(1, f(0, 1));
assertEquals(5, f(2, 3));
%OptimizeFunctionOnNextCall(f);
......
......@@ -30,7 +30,7 @@
function div(g) {
return (g/-1) ^ 1
}
%PrepareFunctionForOptimization(div);
var kMinInt = 1 << 31;
var expected_MinInt = div(kMinInt);
var expected_minus_zero = div(0);
......@@ -42,6 +42,7 @@ function mul(g) {
return (g * -1) ^ 1
}
%PrepareFunctionForOptimization(mul);
expected_MinInt = mul(kMinInt);
expected_minus_zero = mul(0);
%OptimizeFunctionOnNextCall(mul);
......
......@@ -45,6 +45,7 @@ function test_wrapper() {
} while (--count > 0);
}
%PrepareFunctionForOptimization(testDoubleConversion4);
testDoubleConversion4(new Array(5));
testDoubleConversion4(new Array(5)); // Call twice to make sure that second
// store is a transition and not
......@@ -71,6 +72,7 @@ function test_wrapper() {
} while (--count > 0);
}
%PrepareFunctionForOptimization(testExactMapHoisting);
testExactMapHoisting(new Array(5));
testExactMapHoisting(new Array(5)); // Call twice to make sure that second
// store is a transition and not
......@@ -102,6 +104,7 @@ function test_wrapper() {
} while (--count > 0);
}
%PrepareFunctionForOptimization(testExactMapHoisting2);
testExactMapHoisting2(new Array(5));
testExactMapHoisting2(new Array(5)); // Call twice to make sure that second
// store is a transition and not
......@@ -129,6 +132,7 @@ function test_wrapper() {
} while (--count > 0);
}
%PrepareFunctionForOptimization(testExactMapHoisting3);
var add_transition = new Array(5);
add_transition.foo = 0;
add_transition[0] = new Object(); // For FAST_ELEMENT transition to be created
......@@ -155,6 +159,7 @@ function test_wrapper() {
}
/*
%PrepareFunctionForOptimization(testDominatingTransitionHoisting1);
testDominatingTransitionHoisting1(new Array(5));
testDominatingTransitionHoisting1(new Array(5)); // Call twice to make sure
// that second store is a
......@@ -180,6 +185,7 @@ function test_wrapper() {
} while (--count > 3);
}
%PrepareFunctionForOptimization(testHoistingWithSideEffect);
testHoistingWithSideEffect(new Array(5));
testHoistingWithSideEffect(new Array(5)); // Call twice to make sure that
// second store is a transition and
......@@ -203,6 +209,7 @@ function test_wrapper() {
} while (--count > 3);
}
%PrepareFunctionForOptimization(testStraightLineDupeElinination);
testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,0,0,.5);
testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,0,.5,0);
testStraightLineDupeElinination(new Array(0, 0, 0, 0, 0),0,0,.5,0,0);
......
......@@ -30,6 +30,7 @@
assertUnoptimized(foo);
assertTrue(%HasDictionaryElements(a));
%PrepareFunctionForOptimization(foo);
var b = [];
foo(b, 1);
foo(b, 2);
......
......@@ -15,6 +15,7 @@
function readA(x) {
return x.a;
}
%PrepareFunctionForOptimization(readA);
var a = new A();
assertUnoptimized(readA);
readA(a); readA(a); readA(a);
......@@ -26,6 +27,7 @@
b.b = o;
assertEquals(readA(b), o);
assertUnoptimized(readA);
%PrepareFunctionForOptimization(readA);
%OptimizeFunctionOnNextCall(readA);
assertEquals(readA(a), o);
assertOptimized(readA);
......@@ -37,6 +39,7 @@
return x.a;
}
assertUnoptimized(readAFromB);
%PrepareFunctionForOptimization(readAFromB);
readAFromB(b); readAFromB(b); readAFromB(b);
%OptimizeFunctionOnNextCall(readAFromB);
assertEquals(readAFromB(b), o);
......@@ -49,6 +52,8 @@
c.a = [1];
assertUnoptimized(readA);
assertUnoptimized(readAFromB);
%PrepareFunctionForOptimization(readA);
%PrepareFunctionForOptimization(readAFromB);
assertEquals(readA(a), o);
assertEquals(readA(b), o);
assertEquals(readA(c), [1]);
......@@ -77,7 +82,9 @@
A.prototype = {y: 20};
function B(o) { return o.a.y; }
function C() { this.a = new A(); }
%EnsureFeedbackVectorForFunction(C);
%PrepareFunctionForOptimization(B);
B(new C());
B(new C());
%OptimizeFunctionOnNextCall(B);
......@@ -88,6 +95,7 @@
assertEquals(10, B(c));
assertUnoptimized(B);
%PrepareFunctionForOptimization(B);
var c = new C();
%OptimizeFunctionOnNextCall(B);
assertEquals(20, B(c));
......@@ -116,6 +124,7 @@
var f2 = new Foo({x: 2});
var f3 = new Foo({x: 3});
function readX(f) { return f.x.x; }
%PrepareFunctionForOptimization(readX);
assertEquals(readX(f1), 1);
assertEquals(readX(f2), 2);
assertUnoptimized(readX);
......@@ -123,6 +132,7 @@
assertEquals(readX(f3), 3);
assertOptimized(readX);
function writeX(f, x) { f.x = x; }
%PrepareFunctionForOptimization(writeX);
writeX(f1, {x: 11});
writeX(f2, {x: 22});
assertUnoptimized(writeX);
......@@ -146,6 +156,7 @@
var f2 = new Narf(2);
var f3 = new Narf(3);
function baz(f, y) { f.y = y; }
%PrepareFunctionForOptimization(baz);
baz(f1, {b: 9});
baz(f2, {b: 9});
baz(f2, {b: 9});
......@@ -161,6 +172,7 @@
function readA(o) { return o.x.a; }
var f = new Foo({a:1});
var b = new Bar({a:2});
%PrepareFunctionForOptimization(readA);
assertEquals(readA(f), 1);
assertEquals(readA(b), 2);
assertEquals(readA(f), 1);
......
......@@ -7,7 +7,7 @@
// Test that the information on which variables to allocate in context doesn't
// change when recompiling.
(function TestVarInInnerFunction() {
function TestVarInInnerFunction() {
// Introduce variables which would potentially be context allocated, depending
// on whether an inner function refers to them or not.
var a = 1;
......@@ -26,13 +26,15 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestVarInInnerFunction);
TestVarInInnerFunction();
// Other tests are the same, except that the shadowing variable "a" in inner
// functions is declared differently.
(function TestLetInInnerFunction() {
function TestLetInInnerFunction() {
var a = 1;
var b = 2;
var c = 3;
......@@ -48,9 +50,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestLetInInnerFunction);
TestLetInInnerFunction();
(function TestConstInInnerFunction() {
function TestConstInInnerFunction() {
var a = 1;
var b = 2;
var c = 3;
......@@ -66,9 +70,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestConstInInnerFunction);
TestConstInInnerFunction();
(function TestInnerFunctionParameter() {
function TestInnerFunctionParameter() {
var a = 1;
var b = 2;
var c = 3;
......@@ -83,9 +89,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionParameter);
TestInnerFunctionParameter();
(function TestInnerFunctionRestParameter() {
function TestInnerFunctionRestParameter() {
var a = 1;
var b = 2;
var c = 3;
......@@ -100,9 +108,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionRestParameter);
TestInnerFunctionRestParameter();
(function TestInnerFunctionDestructuredParameter_1() {
function TestInnerFunctionDestructuredParameter_1() {
var a = 1;
var b = 2;
var c = 3;
......@@ -117,9 +127,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionDestructuredParameter_1);
TestInnerFunctionDestructuredParameter_1();
(function TestInnerFunctionDestructuredParameter_2() {
function TestInnerFunctionDestructuredParameter_2() {
var a = 1;
var b = 2;
var c = 3;
......@@ -134,9 +146,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionDestructuredParameter_2);
TestInnerFunctionDestructuredParameter_2();
(function TestInnerArrowFunctionParameter() {
function TestInnerArrowFunctionParameter() {
var a = 1;
var b = 2;
var c = 3;
......@@ -149,9 +163,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerArrowFunctionParameter);
TestInnerArrowFunctionParameter();
(function TestInnerArrowFunctionRestParameter() {
function TestInnerArrowFunctionRestParameter() {
var a = 1;
var b = 2;
var c = 3;
......@@ -164,9 +180,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerArrowFunctionRestParameter);
TestInnerArrowFunctionRestParameter();
(function TestInnerArrowFunctionDestructuredParameter_1() {
function TestInnerArrowFunctionDestructuredParameter_1() {
var a = 1;
var b = 2;
var c = 3;
......@@ -179,9 +197,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerArrowFunctionDestructuredParameter_1);
TestInnerArrowFunctionDestructuredParameter_1();
(function TestInnerArrowFunctionDestructuredParameter_2() {
function TestInnerArrowFunctionDestructuredParameter_2() {
var a = 1;
var b = 2;
var c = 3;
......@@ -194,9 +214,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerArrowFunctionDestructuredParameter_2);
TestInnerArrowFunctionDestructuredParameter_2();
(function TestInnerInnerFunctionParameter() {
function TestInnerInnerFunctionParameter() {
var a = 1;
var b = 2;
var c = 3;
......@@ -211,9 +233,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerInnerFunctionParameter);
TestInnerInnerFunctionParameter();
(function TestInnerInnerFunctionRestParameter() {
function TestInnerInnerFunctionRestParameter() {
var a = 1;
var b = 2;
var c = 3;
......@@ -228,9 +252,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerInnerFunctionRestParameter);
TestInnerInnerFunctionRestParameter();
(function TestInnerInnerFunctionDestructuredParameter_1() {
function TestInnerInnerFunctionDestructuredParameter_1() {
var a = 1;
var b = 2;
var c = 3;
......@@ -245,9 +271,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerInnerFunctionDestructuredParameter_1);
TestInnerInnerFunctionDestructuredParameter_1();
(function TestInnerInnerFunctionDestructuredParameter_2() {
function TestInnerInnerFunctionDestructuredParameter_2() {
var a = 1;
var b = 2;
var c = 3;
......@@ -262,9 +290,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerInnerFunctionDestructuredParameter_2);
TestInnerInnerFunctionDestructuredParameter_2();
(function TestInnerInnerArrowFunctionParameter() {
function TestInnerInnerArrowFunctionParameter() {
var a = 1;
var b = 2;
var c = 3;
......@@ -279,9 +309,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerInnerArrowFunctionParameter);
TestInnerInnerArrowFunctionParameter();
(function TestInnerInnerArrowFunctionRestParameter() {
function TestInnerInnerArrowFunctionRestParameter() {
var a = 1;
var b = 2;
var c = 3;
......@@ -296,9 +328,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerInnerArrowFunctionRestParameter);
TestInnerInnerArrowFunctionRestParameter();
(function TestInnerInnerArrowFunctionDestructuredParameter_1() {
function TestInnerInnerArrowFunctionDestructuredParameter_1() {
var a = 1;
var b = 2;
var c = 3;
......@@ -313,9 +347,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerInnerArrowFunctionDestructuredParameter_1);
TestInnerInnerArrowFunctionDestructuredParameter_1();
(function TestInnerInnerArrowFunctionDestructuredParameter_2() {
function TestInnerInnerArrowFunctionDestructuredParameter_2() {
var a = 1;
var b = 2;
var c = 3;
......@@ -330,9 +366,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerInnerArrowFunctionDestructuredParameter_2);
TestInnerInnerArrowFunctionDestructuredParameter_2();
(function TestInnerFunctionInnerFunction() {
function TestInnerFunctionInnerFunction() {
var a = 1;
var b = 2;
var c = 3;
......@@ -348,9 +386,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionInnerFunction);
TestInnerFunctionInnerFunction();
(function TestInnerFunctionSloppyBlockFunction() {
function TestInnerFunctionSloppyBlockFunction() {
var a = 1;
var b = 2;
var c = 3;
......@@ -366,9 +406,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionSloppyBlockFunction);
TestInnerFunctionSloppyBlockFunction();
(function TestInnerFunctionCatchVariable() {
function TestInnerFunctionCatchVariable() {
var a = 1;
var b = 2;
var c = 3;
......@@ -387,9 +429,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
};
%PrepareFunctionForOptimization(TestInnerFunctionCatchVariable);
TestInnerFunctionCatchVariable();
(function TestInnerFunctionLoopVariable1() {
function TestInnerFunctionLoopVariable1() {
var a = 1;
var b = 2;
var c = 3;
......@@ -406,9 +450,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionLoopVariable1);
TestInnerFunctionLoopVariable1();
(function TestInnerFunctionLoopVariable2() {
function TestInnerFunctionLoopVariable2() {
var a = 1;
var b = 2;
var c = 3;
......@@ -425,9 +471,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionLoopVariable2);
TestInnerFunctionLoopVariable2();
(function TestInnerFunctionLoopVariable3() {
function TestInnerFunctionLoopVariable3() {
var a = 1;
var b = 2;
var c = 3;
......@@ -444,9 +492,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionLoopVariable3);
TestInnerFunctionLoopVariable3();
(function TestInnerFunctionLoopVariable4() {
function TestInnerFunctionLoopVariable4() {
var a = 1;
var b = 2;
var c = 3;
......@@ -463,9 +513,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionLoopVariable4);
TestInnerFunctionLoopVariable4();
(function TestInnerFunctionClass() {
function TestInnerFunctionClass() {
var a = 1;
var b = 2;
var c = 3;
......@@ -481,9 +533,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionClass);
TestInnerFunctionClass();
(function TestInnerFunctionDestructuring1() {
function TestInnerFunctionDestructuring1() {
var a = 1;
var b = 2;
var c = 3;
......@@ -499,9 +553,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionDestructuring1);
TestInnerFunctionDestructuring1();
(function TestInnerFunctionDestructuring2() {
function TestInnerFunctionDestructuring2() {
var a = 1;
var b = 2;
var c = 3;
......@@ -517,9 +573,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionDestructuring2);
TestInnerFunctionDestructuring2();
(function TestInnerFunctionDestructuring3() {
function TestInnerFunctionDestructuring3() {
var a = 1;
var b = 2;
var c = 3;
......@@ -535,9 +593,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionDestructuring3);
TestInnerFunctionDestructuring3();
(function TestInnerFunctionDestructuring4() {
function TestInnerFunctionDestructuring4() {
var a = 1;
var b = 2;
var c = 3;
......@@ -553,9 +613,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionDestructuring4);
TestInnerFunctionDestructuring4();
(function TestInnerFunctionDestructuring5() {
function TestInnerFunctionDestructuring5() {
var a = 1;
var b = 2;
var c = 3;
......@@ -571,9 +633,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionDestructuring5);
TestInnerFunctionDestructuring5();
(function TestInnerFunctionDestructuring6() {
function TestInnerFunctionDestructuring6() {
var a = 1;
var b = 2;
var c = 3;
......@@ -589,9 +653,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionDestructuring6);
TestInnerFunctionDestructuring6();
(function TestInnerFunctionDestructuring7() {
function TestInnerFunctionDestructuring7() {
var a = 1;
var b = 2;
var c = 3;
......@@ -607,9 +673,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionDestructuring7);
TestInnerFunctionDestructuring7();
(function TestInnerFunctionDestructuring8() {
function TestInnerFunctionDestructuring8() {
var a = 1;
var b = 2;
var c = 3;
......@@ -625,9 +693,11 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionDestructuring8);
TestInnerFunctionDestructuring8();
(function TestInnerFunctionDestructuring9() {
function TestInnerFunctionDestructuring9() {
var a = 1;
var b = 2;
var c = 3;
......@@ -643,11 +713,13 @@
assertEquals(2, b);
assertEquals(3, c);
}
})();
}
%PrepareFunctionForOptimization(TestInnerFunctionDestructuring9);
TestInnerFunctionDestructuring9();
// A cluster of similar tests where the inner function only declares a variable
// whose name clashes with an outer function variable name, but doesn't use it.
(function TestRegress650969_1_var() {
function TestRegress650969_1_var() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -657,9 +729,11 @@
var a;
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_1_var);
TestRegress650969_1_var();
(function TestRegress650969_1_let() {
function TestRegress650969_1_let() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -669,9 +743,11 @@
let a;
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_1_let);
TestRegress650969_1_let();
(function TestRegress650969_2_var() {
function TestRegress650969_2_var() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -681,9 +757,11 @@
var a = 6;
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_2_var);
TestRegress650969_2_var();
(function TestRegress650969_2_let() {
function TestRegress650969_2_let() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -693,9 +771,11 @@
let a = 6;
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_2_let);
TestRegress650969_2_let();
(function TestRegress650969_2_const() {
function TestRegress650969_2_const() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -705,9 +785,11 @@
const a = 6;
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_2_const);
TestRegress650969_2_const();
(function TestRegress650969_3_var() {
function TestRegress650969_3_var() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -717,9 +799,11 @@
var a, b;
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_3_var);
TestRegress650969_3_var();
(function TestRegress650969_3_let() {
function TestRegress650969_3_let() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -729,9 +813,11 @@
let a, b;
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_3_let);
TestRegress650969_3_let();
(function TestRegress650969_4_var() {
function TestRegress650969_4_var() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -741,9 +827,11 @@
var a = 6, b;
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_4_var);
TestRegress650969_4_var();
(function TestRegress650969_4_let() {
function TestRegress650969_4_let() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -753,9 +841,11 @@
let a = 6, b;
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_4_let);
TestRegress650969_4_let();
(function TestRegress650969_4_const() {
function TestRegress650969_4_const() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -765,9 +855,11 @@
const a = 0, b = 0;
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_4_const);
TestRegress650969_4_const();
(function TestRegress650969_9_parameter() {
function TestRegress650969_9_parameter() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -775,9 +867,11 @@
var a;
function inner(a) {}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_9_parameter);
TestRegress650969_9_parameter();
(function TestRegress650969_9_restParameter() {
function TestRegress650969_9_restParameter() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -785,9 +879,11 @@
var a;
function inner(...a) {}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_9_restParameter);
TestRegress650969_9_restParameter();
(function TestRegress650969_9_destructuredParameter_1() {
function TestRegress650969_9_destructuredParameter_1() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -795,9 +891,11 @@
var a;
function inner([d, a]) {}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_9_destructuredParameter_1);
TestRegress650969_9_destructuredParameter_1();
(function TestRegress650969_9_destructuredParameter_2() {
function TestRegress650969_9_destructuredParameter_2() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -805,9 +903,11 @@
var a;
function inner({d, a}) {}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_9_destructuredParameter_2);
TestRegress650969_9_destructuredParameter_2();
(function TestRegress650969_10_parameter() {
function TestRegress650969_10_parameter() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -817,9 +917,11 @@
function innerinner(a) {}
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_10_parameter);
TestRegress650969_10_parameter();
(function TestRegress650969_10_restParameter() {
function TestRegress650969_10_restParameter() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -829,9 +931,11 @@
function innerinner(...a) {}
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_10_restParameter);
TestRegress650969_10_restParameter();
(function TestRegress650969_10_destructuredParameter_1() {
function TestRegress650969_10_destructuredParameter_1() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -841,9 +945,11 @@
function innerinner([d, a]) {}
}
}
})();
}
%PrepareFunctionForOptimization( TestRegress650969_10_destructuredParameter_1);
TestRegress650969_10_destructuredParameter_1();
(function TestRegress650969_10_destructuredParameter_2() {
function TestRegress650969_10_destructuredParameter_2() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -853,9 +959,11 @@
function innerinner({d, a}) {}
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_10_destructuredParameter_2);
TestRegress650969_10_destructuredParameter_2();
(function TestRegress650969_11_var() {
function TestRegress650969_11_var() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -865,9 +973,12 @@
var [a, b] = [1, 2];
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_11_var);
TestRegress650969_11_var();
(function TestRegress650969_11_let() {
function TestRegress650969_11_let() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -877,9 +988,11 @@
let [a, b] = [1, 2];
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_11_let);
TestRegress650969_11_let();
(function TestRegress650969_11_const() {
function TestRegress650969_11_const() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -889,9 +1002,11 @@
const [a, b] = [1, 2];
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_11_const);
TestRegress650969_11_const();
(function TestRegress650969_12_var() {
function TestRegress650969_12_var() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -901,9 +1016,11 @@
var [b, a] = [1, 2];
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_12_var);
TestRegress650969_12_var();
(function TestRegress650969_12_let() {
function TestRegress650969_12_let() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -913,9 +1030,11 @@
let [b, a] = [1, 2];
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_12_let);
TestRegress650969_12_let();
(function TestRegress650969_12_const() {
function TestRegress650969_12_const() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -925,9 +1044,11 @@
const [b, a] = [1, 2];
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_12_const);
TestRegress650969_12_const();
(function TestRegress650969_13_var() {
function TestRegress650969_13_var() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -937,9 +1058,11 @@
var [b, ...a] = [1, 2];
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_13_var);
TestRegress650969_13_var();
(function TestRegress650969_13_let() {
function TestRegress650969_13_let() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -949,9 +1072,11 @@
let [b, ...a] = [1, 2];
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_13_let);
TestRegress650969_13_let();
(function TestRegress650969_13_const() {
function TestRegress650969_13_const() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -961,9 +1086,11 @@
const [b, ...a] = [1, 2];
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_13_const);
TestRegress650969_13_const();
(function TestRegress650969_14_var() {
function TestRegress650969_14_var() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -973,9 +1100,11 @@
var {a, b} = {a: 1, b: 2};
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_14_var);
TestRegress650969_14_var();
(function TestRegress650969_14_let() {
function TestRegress650969_14_let() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -985,9 +1114,11 @@
let {a, b} = {a: 1, b: 2};
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_14_let);
TestRegress650969_14_let();
(function TestRegress650969_14_const() {
function TestRegress650969_14_const() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -997,9 +1128,11 @@
const {a, b} = {a: 1, b: 2};
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_14_const);
TestRegress650969_14_const();
(function TestRegress650969_15_var() {
function TestRegress650969_15_var() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1009,9 +1142,11 @@
var {b: {a}, c} = {b: {a: 1}, c: 2};
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_15_var);
TestRegress650969_15_var();
(function TestRegress650969_15_let() {
function TestRegress650969_15_let() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1021,9 +1156,11 @@
let {b: {a}, c} = {b: {a: 1}, c: 2};
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_15_let);
TestRegress650969_15_let();
(function TestRegress650969_15_const() {
function TestRegress650969_15_const() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1033,9 +1170,11 @@
const {b: {a}, c} = {b: {a: 1}, c: 2};
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_15_const);
TestRegress650969_15_const();
(function TestRegress650969_16_var() {
function TestRegress650969_16_var() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1045,9 +1184,11 @@
var {a: {b}, c} = {a: {b: 1}, c: 2};
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_16_var);
TestRegress650969_16_var();
(function TestRegress650969_16_let() {
function TestRegress650969_16_let() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1057,9 +1198,11 @@
let {a: {b}, c} = {a: {b: 1}, c: 2};
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_16_let);
TestRegress650969_16_let();
(function TestRegress650969_16_const() {
function TestRegress650969_16_const() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1069,9 +1212,11 @@
const {a: {b}, c} = {a: {b: 1}, c: 2};
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_16_const);
TestRegress650969_16_const();
(function TestRegress650969_17_var() {
function TestRegress650969_17_var() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1081,9 +1226,11 @@
for (var a = 0; 0 == 1; ) { }
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_17_var);
TestRegress650969_17_var();
(function TestRegress650969_17_let() {
function TestRegress650969_17_let() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1093,9 +1240,11 @@
for (let a = 0; 0 == 1; ) { }
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_17_let);
TestRegress650969_17_let();
(function TestRegress650969_17_const() {
function TestRegress650969_17_const() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1105,9 +1254,11 @@
for (const a = 0; 0 == 1; ) { }
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_17_const);
TestRegress650969_17_const();
(function TestRegress650969_18() {
function TestRegress650969_18() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1117,9 +1268,11 @@
function innerinner([a, b]) {}
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_18);
TestRegress650969_18();
(function TestRegress650969_18() {
function TestRegress650969_18() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1129,11 +1282,13 @@
function innerinner(a) {}
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_18);
TestRegress650969_18();
// Regression tests for an intermediate stage where unresolved references were
// discarded too aggressively.
(function TestRegress650969_sidetrack_var() {
function TestRegress650969_sidetrack_var() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1144,9 +1299,11 @@
var {b: {a}, c} = {b: {a: 1}, c: 2};
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_sidetrack_var);
TestRegress650969_sidetrack_var();
(function TestRegress650969_sidetrack_let() {
function TestRegress650969_sidetrack_let() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1157,9 +1314,11 @@
let {b: {a}, c} = {b: {a: 1}, c: 2};
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_sidetrack_let);
TestRegress650969_sidetrack_let();
(function TestRegress650969_sidetrack_const() {
function TestRegress650969_sidetrack_const() {
for (var i = 0; i < 3; ++i) {
if (i == 1) {
%OptimizeOsr();
......@@ -1170,4 +1329,6 @@
const {b: {a}, c} = {b: {a: 1}, c: 2};
}
}
})();
}
%PrepareFunctionForOptimization(TestRegress650969_sidetrack_const);
TestRegress650969_sidetrack_const();
......@@ -9,4 +9,5 @@ function f() {
if (i == 5) %OptimizeOsr();
}
}
%EnsureFeedbackVectorForFunction(f);
f();
......@@ -11,6 +11,7 @@
}
return 23;
}
%PrepareFunctionForOptimization(gen1);
var g = gen1();
assertEquals({ value:23, done:true }, g.next());
})();
......@@ -23,6 +24,7 @@
}
return 23;
}
%PrepareFunctionForOptimization(gen2);
var g = gen2();
assertEquals({ value:0, done:false }, g.next());
assertEquals({ value:1, done:false }, g.next());
......@@ -38,6 +40,7 @@
}
return 23;
}
%PrepareFunctionForOptimization(gen3);
var g = gen3();
assertEquals({ value:0, done:false }, g.next());
assertEquals({ value:1, done:false }, g.next());
......@@ -57,6 +60,7 @@
}
return 23;
}
%PrepareFunctionForOptimization(gen4);
var g = gen4();
assertEquals({ value:0, done:false }, g.next());
assertEquals({ value:1, done:false }, g.next());
......
......@@ -10,6 +10,10 @@ function f(b) {
}
}
f(0);
assertThrows(() => {f(1)}, ReferenceError);
%PrepareFunctionForOptimization(f);
f(0);
f(0);
%OptimizeFunctionOnNextCall(f);
......
......@@ -15,7 +15,13 @@ class B extends A {
}
}
}
// No feedback case
test = new B(0);
assertThrows(() => {new B(1)}, ReferenceError);
// Ensure Feedback
%PrepareFunctionForOptimization(B);
%EnsureFeedbackVectorForFunction(A);
test = new B(0);
test = new B(0);
assertThrows(() => {new B(1)}, ReferenceError);
......
......@@ -15,6 +15,10 @@ class B extends A {
}
}
test = new B(1);
assertThrows(() => {new B(0)}, ReferenceError);
%PrepareFunctionForOptimization(B);
test = new B(1);
test = new B(1);
%OptimizeFunctionOnNextCall(B);
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --opt --interrupt-budget=100 --allow-natives-syntax
// Flags: --opt --interrupt-budget=100 --budget-for-feedback-vector-allocation=10 --allow-natives-syntax
function f() {
let s = 0;
......
......@@ -11,6 +11,7 @@
function foo(a, i) { return a[i]; }
%PrepareFunctionForOptimization(foo);
var a = ['one', , 'three'];
foo(a, 0);
foo(a, 0);
......
......@@ -36,6 +36,7 @@ function get(obj, key) {
return obj[key];
}
%PrepareFunctionForOptimization(get);
get(o, "foo");
get(o, "foo");
get(o, "foo");
......
......@@ -37,6 +37,7 @@ function get(obj, key) {
return obj[key];
}
%PrepareFunctionForOptimization(get);
assertEquals("bar", get(o, s));
get(o, s);
get(o, s);
......
......@@ -34,6 +34,7 @@ function test_div_no_deopt_minus_zero() {
assertTrue(0 === (Math.floor((zero_in_array[0] | 0) / -1) | 0));
}
%PrepareFunctionForOptimization(test_div_no_deopt_minus_zero);
test_div_no_deopt_minus_zero();
test_div_no_deopt_minus_zero();
%OptimizeFunctionOnNextCall(test_div_no_deopt_minus_zero);
......
......@@ -29,6 +29,7 @@
function o1() {
}
%PrepareFunctionForOptimization(o1);
o1(); o1();
%OptimizeFunctionOnNextCall(o1);
......@@ -45,6 +46,8 @@ function u1() {
function u2() {
u1();
}
%PrepareFunctionForOptimization(u1);
%PrepareFunctionForOptimization(u2);
u1(); u1();
u2(); u2();
......
......@@ -220,9 +220,11 @@ assertDoesNotThrow(function() { objControl.splice(0, 0, 100, 101, 102); });
// Verify that crankshaft still does the right thing.
obj = [1, 2, 3];
push_call = function(a) { a.push(1000); return a; }
push_call = function(a) { a.push(1000); return a; };
%PrepareFunctionForOptimization(push_call);
// Include a call site that doesn't have a custom built-in.
var shift_call = function(a) { a.shift(1000); return a; }
var shift_call = function(a) { a.shift(1000); return a; };
%PrepareFunctionForOptimization(shift_call);
for (var i = 0; i < 3; i++) {
push_call(obj);
shift_call(obj);
......
......@@ -20,7 +20,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];
a.abc = 25;
}
return v;
}
};
%EnsureFeedbackVectorForFunction(callback);
a.map(callback);
};
%PrepareFunctionForOptimization(eagerDeoptInCalled);
......@@ -41,7 +42,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 += v;
a.length = (i == 13 && deopt) ? 25 : 27;
return v;
}
};
%EnsureFeedbackVectorForFunction(callback);
a.map(callback);
};
%PrepareFunctionForOptimization(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];
a_noescape.length = 25;
}
return v;
}
};
%EnsureFeedbackVectorForFunction(callback);
a_noescape.map(callback);
};
%PrepareFunctionForOptimization(eagerDeoptInCalled);
......@@ -93,6 +96,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];
gc(); gc();
return v;
};
%EnsureFeedbackVectorForFunction(callback);
%NeverOptimizeFunction(callback);
b.map(callback);
};
......@@ -117,6 +121,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 2 * v;
};
%EnsureFeedbackVectorForFunction(callback);
%NeverOptimizeFunction(callback);
return b.map(callback);
};
......@@ -137,7 +142,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];
%DeoptimizeNow();
}
return v;
}
};
%EnsureFeedbackVectorForFunction(callback);
b.map(callback);
};
%PrepareFunctionForOptimization(lazyDeopt);
......@@ -161,6 +167,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;
};
%EnsureFeedbackVectorForFunction(callback);
%NeverOptimizeFunction(callback);
b.map(callback);
};
......@@ -186,7 +193,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];
gc();
}
return v;
}
};
%EnsureFeedbackVectorForFunction(callback);
c.map(callback);
};
%PrepareFunctionForOptimization(lazyDeopt);
......@@ -211,7 +219,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];
throw("a");
}
return v;
}
};
%EnsureFeedbackVectorForFunction(callback);
try {
c.map(callback);
} catch (e) {
......@@ -241,6 +250,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;
};
%EnsureFeedbackVectorForFunction(callback);
%NeverOptimizeFunction(callback);
try {
c.map(callback);
......@@ -270,6 +280,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 2 * v;
};
%EnsureFeedbackVectorForFunction(callback);
%NeverOptimizeFunction(callback);
var result = 0;
try {
......@@ -303,6 +314,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;
};
%EnsureFeedbackVectorForFunction(callback);
var o = [1,2,3];
b.map(callback);
};
......@@ -326,6 +338,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;
};
%EnsureFeedbackVectorForFunction(callback);
%NeverOptimizeFunction(callback);
var o = [1,2,3];
b.map(callback);
......@@ -352,6 +365,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;
};
%EnsureFeedbackVectorForFunction(callback);
var o = [1,2,3];
b.map(callback);
};
......@@ -375,6 +389,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;
};
%EnsureFeedbackVectorForFunction(callback);
a.map(callback);
};
%PrepareFunctionForOptimization(lazyDeopt);
......@@ -408,7 +423,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];
// array.
return v;
}
}
};
%EnsureFeedbackVectorForFunction(callback);
return c.map(callback);
};
%PrepareFunctionForOptimization(to_double);
......@@ -439,7 +455,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];
// Later, to PACKED_ELEMENTS.
return v + 'hello';
}
}
};
%EnsureFeedbackVectorForFunction(callback);
return c.map(callback);
};
%PrepareFunctionForOptimization(to_fast);
......@@ -460,6 +477,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];
function double_results() {
// TurboFan recognizes the result is a double.
var callback = v => v + 0.5;
%EnsureFeedbackVectorForFunction(callback);
return a.map(callback);
}
%PrepareFunctionForOptimization(double_results);
......
......@@ -43,6 +43,8 @@ function f(x) {
g();
}
%PrepareFunctionForOptimization(f);
%PrepareFunctionForOptimization(g);
f();
f();
%OptimizeFunctionOnNextCall(f);
......
......@@ -34,6 +34,7 @@
for (var i = 0; osr && i < 2; i++) %OptimizeOsr();
return result;
}
%PrepareFunctionForOptimization(f);
assertEquals("result", f(true, 3, false));
assertEquals("result", f(true, 3, false));
......@@ -58,6 +59,7 @@
function f() {
return g(void(h() + ""));
};
%PrepareFunctionForOptimization(f);
f();
%OptimizeFunctionOnNextCall(f);
......
......@@ -35,6 +35,7 @@ function f(deopt, osr) {
return result;
}
%PrepareFunctionForOptimization(f);
assertEquals("result", f(3, false));
assertEquals("result", f(3, false));
%OptimizeFunctionOnNextCall(f);
......
......@@ -31,21 +31,25 @@
// should be able to construct a receiver from all optimized stack frames.
function A() { }
%EnsureFeedbackVectorForFunction(A);
A.prototype.f = function() { }
function B() { }
%EnsureFeedbackVectorForFunction(B);
var o = new A();
// This function throws if o does not have an f property, and should not be
// inlined.
function g() { try { return o.f(); } finally { }}
%EnsureFeedbackVectorForFunction(g);
// This function should be optimized via OSR.
function h() {
for (var i = 0; i < 10; i++) %OptimizeOsr();
g();
}
%PrepareFunctionForOptimization(h);
h();
o = new B();
......
......@@ -31,4 +31,5 @@ function foo () {
};
}
%PrepareFunctionForOptimization(foo);
foo();
......@@ -31,6 +31,7 @@ function mul(x, y) {
return (x * y) | 0;
}
%PrepareFunctionForOptimization(mul);
mul(0, 0);
mul(0, 0);
%OptimizeFunctionOnNextCall(mul);
......@@ -41,6 +42,7 @@ function div(x, y) {
return (x / y) | 0;
}
%PrepareFunctionForOptimization(div);
div(4, 2);
div(4, 2);
%OptimizeFunctionOnNextCall(div);
......
......@@ -35,8 +35,10 @@ function simple_two_args(always_zero, always_undefined) {
var always_five = always_undefined || 5;
return always_zero * always_five * .5;
}
%EnsureFeedbackVectorForFunction(simple_two_args);
%PrepareFunctionForOptimization(simple);
simple();
simple();
%OptimizeFunctionOnNextCall(simple);
......
......@@ -33,6 +33,7 @@ function f() {
assertEquals(-1.0, Math.round(-0.5000000000000001));
}
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);
......
......@@ -55,6 +55,7 @@ function callConstantFunctionOnPrototype(obj) {
obj.holderMethod();
}
%PrepareFunctionForOptimization(callConstantFunctionOnPrototype);
callConstantFunctionOnPrototype(receiver);
callConstantFunctionOnPrototype(receiver);
%OptimizeFunctionOnNextCall(callConstantFunctionOnPrototype);
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --use-osr --allow-natives-syntax --ignition-osr --opt
// Flags: --use-osr --allow-natives-syntax --opt
// Flags: --no-always-opt
// Can't OSR with always-opt or in Lite mode.
......@@ -50,6 +50,7 @@ function f() {
} while (false);
}
%PrepareFunctionForOptimization(f);
f();
function g() {
......@@ -85,4 +86,5 @@ function g() {
} while (false);
}
%PrepareFunctionForOptimization(g);
g();
......@@ -14,6 +14,7 @@ function Cb(a, trigger) {
}
return g;
}
%PrepareFunctionForOptimization(Cb);
var s1 = "long string to make cons string 1";
var s2 = "long string to make cons string 2";
......
......@@ -33,7 +33,7 @@ if (isNeverOptimizeLiteMode()) {
x = 42;
return f.arguments[0];
}
%EnsureFeedbackVectorForFunction(f);
f(0);
%OptimizeFunctionOnNextCall(f);
assertEquals(42, f(0));
......
......@@ -27,6 +27,10 @@
// Flags: --allow-natives-syntax
for (var i = 0; i < 10; i++) { if (i == 5) %OptimizeOsr(); }
var xl = 4096;
var z = i % xl;
function f() {
for (var i = 0; i < 10; i++) { if (i == 5) %OptimizeOsr(); }
var xl = 4096;
var z = i % xl;
}
%PrepareFunctionForOptimization(f);
f();
......@@ -10,6 +10,7 @@ function foo(a) {
}
}
%PrepareFunctionForOptimization(foo);
foo([1,2,3]);
foo([2,3,4]);
%OptimizeFunctionOnNextCall(foo);
......
......@@ -18,6 +18,7 @@ function foo() {
}
}
%PrepareFunctionForOptimization(foo);
foo();
foo();
%OptimizeFunctionOnNextCall(foo);
......
......@@ -10,6 +10,7 @@ function foo(obj) {
counter += obj;
return counter;
}
%PrepareFunctionForOptimization(foo);
function bar() {
var a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
......
......@@ -59,6 +59,7 @@ assertEquals(1, r1);
assertTrue(r1 === r2);
assertTrue(r2 === r3);
%OptimizeFunctionOnNextCall(callsFReceiver);
r1 = callsFReceiver(o1);
callsFReceiver(o1);
%OptimizeFunctionOnNextCall(callsFReceiver);
......
......@@ -23,6 +23,7 @@ function literals_sharing_test(warmup, optimize) {
// propagated to the next closure.
assertTrue(%HasDoubleElements(a));
};
%EnsureFeedbackVectorForFunction(closure);
if (optimize) %OptimizeFunctionOnNextCall(closure);
closure();
}
......
......@@ -9,6 +9,7 @@ function bar(a) {
return x == undefined;
}
%PrepareFunctionForOptimization(bar);
// Make the keyed load be polymorphic on holey smi and holey fast.
bar([, 2, 3]);
bar([, 'two', 'three']);
......
......@@ -11,6 +11,7 @@
return 23;
} while(false)
}
%PrepareFunctionForOptimization(f);
assertEquals(23, f());
assertEquals(23, f());
})();
......@@ -24,6 +25,7 @@
} while(false)
return 999;
}
%PrepareFunctionForOptimization(g);
var gen = g();
assertEquals({ value:23, done:false }, gen.next());
assertEquals({ value:42, done:false }, gen.next());
......
......@@ -20,6 +20,7 @@ function f(osr_and_recurse) {
}
return 65;
}
%PrepareFunctionForOptimization(f);
assertEquals(65, f(false));
assertEquals(65, f(false));
assertEquals(42, f(true));
......@@ -15,6 +15,7 @@ var f = (function() {
}
}
})();
%PrepareFunctionForOptimization(f);
g = (function() { f((Array), counter()); });
g();
......@@ -8,6 +8,7 @@ function get(a, i) {
return a[i];
}
%PrepareFunctionForOptimization(get);
get([1,,3], 0);
get([1,,3], 2);
%OptimizeFunctionOnNextCall(get);
......
......@@ -8,6 +8,7 @@ function get(a, i) {
return a[i];
}
%PrepareFunctionForOptimization(get);
get([1,,3], 0);
get([1,,3], 2);
%OptimizeFunctionOnNextCall(get);
......
......@@ -7,6 +7,7 @@
function foo(x) {
return Symbol.iterator == x;
}
%PrepareFunctionForOptimization(foo);
function main() {
foo(Symbol());
......
......@@ -8,6 +8,7 @@ var o = {};
function foo(s) { return o[s]; }
%PrepareFunctionForOptimization(foo);
var s = 'c' + 'c';
foo(s);
foo(s);
......
......@@ -7,6 +7,7 @@
(function() {
function foo(o) { o["x"] = 1; }
%PrepareFunctionForOptimization(foo);
assertThrows(() => foo(undefined));
assertThrows(() => foo(undefined));
%OptimizeFunctionOnNextCall(foo);
......@@ -17,6 +18,7 @@
(function() {
function foo(o) { o["x"] = 1; }
%PrepareFunctionForOptimization(foo);
assertThrows(() => foo(null));
assertThrows(() => foo(null));
%OptimizeFunctionOnNextCall(foo);
......@@ -27,6 +29,7 @@
(function() {
function foo(o) { return o["x"]; }
%PrepareFunctionForOptimization(foo);
assertThrows(() => foo(undefined));
assertThrows(() => foo(undefined));
%OptimizeFunctionOnNextCall(foo);
......@@ -37,6 +40,7 @@
(function() {
function foo(o) { return o["x"]; }
%PrepareFunctionForOptimization(foo);
assertThrows(() => foo(null));
assertThrows(() => foo(null));
%OptimizeFunctionOnNextCall(foo);
......@@ -47,6 +51,7 @@
(function() {
function foo(o) { o.x = 1; }
%PrepareFunctionForOptimization(foo);
assertThrows(() => foo(undefined));
assertThrows(() => foo(undefined));
%OptimizeFunctionOnNextCall(foo);
......@@ -57,6 +62,7 @@
(function() {
function foo(o) { o.x = 1; }
%PrepareFunctionForOptimization(foo);
assertThrows(() => foo(null));
assertThrows(() => foo(null));
%OptimizeFunctionOnNextCall(foo);
......@@ -67,6 +73,7 @@
(function() {
function foo(o) { return o.x; }
%PrepareFunctionForOptimization(foo);
assertThrows(() => foo(undefined));
assertThrows(() => foo(undefined));
%OptimizeFunctionOnNextCall(foo);
......@@ -77,6 +84,7 @@
(function() {
function foo(o) { return o.x; }
%PrepareFunctionForOptimization(foo);
assertThrows(() => foo(null));
assertThrows(() => foo(null));
%OptimizeFunctionOnNextCall(foo);
......
......@@ -6,6 +6,7 @@
function foo(o) { return o.x; }
%PrepareFunctionForOptimization(foo);
assertEquals(undefined, foo({}));
assertEquals(undefined, foo(1));
assertEquals(undefined, foo({}));
......
......@@ -8,6 +8,7 @@ function foo(s) {
return s[5];
}
%PrepareFunctionForOptimization(foo);
assertEquals("f", foo("abcdef"));
assertEquals(undefined, foo("a"));
%OptimizeFunctionOnNextCall(foo);
......@@ -19,6 +20,7 @@ assertOptimized(foo);
String.prototype[5] = "5";
assertEquals("f", foo("abcdef"));
%PrepareFunctionForOptimization(foo);
assertEquals("5", foo("a"));
%OptimizeFunctionOnNextCall(foo);
assertEquals("f", foo("abcdef"));
......
......@@ -8,6 +8,7 @@ function foo(s) {
return s[5];
}
%PrepareFunctionForOptimization(foo);
assertEquals("f", foo("abcdef"));
assertEquals(undefined, foo("a"));
%OptimizeFunctionOnNextCall(foo);
......@@ -23,6 +24,7 @@ String.prototype.__proto__ = new Proxy(String.prototype.__proto__, {
});
assertEquals("f", foo("abcdef"));
%PrepareFunctionForOptimization(foo);
assertEquals("5", foo("a"));
%OptimizeFunctionOnNextCall(foo);
assertEquals("f", foo("abcdef"));
......
......@@ -5,12 +5,14 @@
// Flags: --allow-natives-syntax --opt
function foo() { return -"0" }
%PrepareFunctionForOptimization(foo);
foo();
%OptimizeFunctionOnNextCall(foo);
foo();
assertOptimized(foo);
function bar() { return -"1" }
%PrepareFunctionForOptimization(bar);
bar();
%OptimizeFunctionOnNextCall(bar);
bar();
......
......@@ -6,6 +6,7 @@
function foo(t) { return 'a'.concat(t); }
%PrepareFunctionForOptimization(foo);
foo(1);
foo(1);
%OptimizeFunctionOnNextCall(foo);
......
......@@ -4,8 +4,12 @@
// Flags: --allow-natives-syntax
var C = class {};
for (var i = 0; i < 4; ++i) {
if (i == 2) %OptimizeOsr();
C.prototype.foo = 42;
function f() {
var C = class {};
for (var i = 0; i < 4; ++i) {
if (i == 2) %OptimizeOsr();
C.prototype.foo = 42;
}
}
%PrepareFunctionForOptimization(f);
f();
......@@ -4,9 +4,13 @@
// Flags: --allow-natives-syntax --expose-gc --verify-heap
C = class {};
for (var i = 0; i < 5; ++i) {
gc();
if (i == 2) %OptimizeOsr();
C.prototype.foo = i + 9000000000000000;
function f() {
C = class {};
for (var i = 0; i < 5; ++i) {
gc();
if (i == 2) %OptimizeOsr();
C.prototype.foo = i + 9000000000000000;
}
}
%PrepareFunctionForOptimization(f);
f();
......@@ -42,11 +42,13 @@
assertSame(2, arguments[1]);
assertSame(3, arguments[2]);
}
%EnsureFeedbackVectorForFunction(inner);
function outer() {
inner(1,2,3);
for (var i = 0; i < 3; i++) %OptimizeOsr();
}
%PrepareFunctionForOptimization(outer);
outer();
})();
......@@ -16,6 +16,8 @@ function foo() {
}
return c;
}
%PrepareFunctionForOptimization(foo);
try {
foo();
} catch (e) {
......
......@@ -16,8 +16,10 @@ function makeFun() {
if (i == osr_fuse) %OptimizeOsr();
}
}
%PrepareFunctionForOptimization(fun);
return fun;
}
%PrepareFunctionForOptimization(makeFun);
makeFun()(7); // Warm up.
makeFun()(4); // Optimize once.
......
......@@ -19,4 +19,6 @@ function gen() {
return eval("(" + body + ")");
}
gen()();
var f = gen();
%PrepareFunctionForOptimization(f);
f();
......@@ -7,6 +7,7 @@
(function() {
var key = "s";
function f(object) { return object[key]; };
%PrepareFunctionForOptimization(f);
f("");
f("");
%OptimizeFunctionOnNextCall(f);
......
......@@ -7,6 +7,7 @@
// The Crankshaft fast case for String.fromCharCode used to unconditionally
// deoptimize on non int32 indices.
function foo(i) { return String.fromCharCode(i); }
%PrepareFunctionForOptimization(foo);
foo(33);
foo(33);
%OptimizeFunctionOnNextCall(foo);
......
......@@ -24,6 +24,7 @@ function load() {
return sum;
}
%PrepareFunctionForOptimization(load);
load();
load();
%OptimizeFunctionOnNextCall(load);
......@@ -37,6 +38,7 @@ function store() {
}
}
%PrepareFunctionForOptimization(store);
store();
store();
%OptimizeFunctionOnNextCall(store);
......@@ -70,6 +72,7 @@ function inferrable_store(key) {
store_element(o5, key);
}
%PrepareFunctionForOptimization(inferrable_store);
inferrable_store(0);
inferrable_store(0);
%OptimizeFunctionOnNextCall(inferrable_store);
......
......@@ -7,9 +7,11 @@
function f() {
for (var i = 0; i < 10; i++) if (i == 5) %OptimizeOsr();
function g() {}
%PrepareFunctionForOptimization(g);
%OptimizeFunctionOnNextCall(g);
g();
}
%PrepareFunctionForOptimization(f);
f();
gc(); // Make sure that ...
gc(); // ... code flushing ...
......
......@@ -8,8 +8,10 @@ function A() {
this.x = 0;
for (var i = 0; i < max; ) {}
}
%EnsureFeedbackVectorForFunction(A);
function foo() {
for (var i = 0; i < 1; i = 2) %OptimizeOsr();
return new A();
}
%PrepareFunctionForOptimization(foo);
try { foo(); } catch (e) { }
......@@ -15,4 +15,5 @@ function f() {
throw "no loop, thank you";
}
}
%PrepareFunctionForOptimization(f);
assertThrows(f);
......@@ -14,6 +14,7 @@ function g() {
for (var i = 0; i < 3; ++i) if (i === 1) %OptimizeOsr();
%_DeoptimizeNow();
}
%PrepareFunctionForOptimization(g);
%OptimizeFunctionOnNextCall(g);
g();
......@@ -13,4 +13,5 @@ function f() {
gc();
}
}
%PrepareFunctionForOptimization(f);
f();
......@@ -17,5 +17,6 @@ function f() {
}
return result;
}
%PrepareFunctionForOptimization(f);
assertEquals("R:121212", f());
......@@ -12,6 +12,7 @@ function shift_array() {
return array.shift();
}
%PrepareFunctionForOptimization(shift_array);
assertThrows(shift_array);
assertThrows(shift_array);
%OptimizeFunctionOnNextCall(shift_array);
......@@ -25,6 +26,7 @@ function shift_object() {
return object.shift();
}
%PrepareFunctionForOptimization(shift_object);
assertThrows(shift_object);
assertThrows(shift_object);
%OptimizeFunctionOnNextCall(shift_object);
......
......@@ -5,14 +5,18 @@
// Flags: --allow-natives-syntax
{
for(let i = 0; i < 10; ++i){
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
// read in the ({...g}) call, which therefore must also be marked dead and
// elided.
with(f&&g&&(s()=N)({...g})){}
} catch {}
%OptimizeOsr();
function f() {
for(let i = 0; i < 10; ++i){
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
// read in the ({...g}) call, which therefore must also be marked dead and
// elided.
with(f&&g&&(s()=N)({...g})){}
} catch {}
%OptimizeOsr();
}
}
%PrepareFunctionForOptimization(f);
f();
}
......@@ -16,5 +16,6 @@
}
return a;
}
%PrepareFunctionForOptimization(f);
assertEquals(18, f());
})();
......@@ -37,6 +37,7 @@ function f(a) { // First parameter is tagged.
n = i + a;
}
%PrepareFunctionForOptimization(f);
f(1);
f(1);
%OptimizeFunctionOnNextCall(f);
......@@ -51,6 +52,7 @@ function g() { // 0th parameter (receiver) is tagged.
n = i + this;
}
%PrepareFunctionForOptimization(g);
g.call(1);
g.call(1);
%OptimizeFunctionOnNextCall(g);
......
......@@ -32,6 +32,7 @@ function f() {
o["<abc>"] = 123;
}
%PrepareFunctionForOptimization(f);
f();
f();
f();
......
......@@ -19,7 +19,7 @@ function get_closure() {
return x;
}
}
%PrepareFunctionForOptimization(get_closure);
var f1 = get_closure();
f1(new Ctor(), false);
f1(new Ctor(), false);
......
......@@ -27,6 +27,10 @@ function assertKind(expected, obj, name_opt) {
function make2() { return new Array(); }
function make3() { return new Array(); }
function foo(a, i) { a[0] = i; }
%EnsureFeedbackVectorForFunction(make1);
%EnsureFeedbackVectorForFunction(make2);
%EnsureFeedbackVectorForFunction(make3);
%EnsureFeedbackVectorForFunction(foo);
function run_test(maker_function) {
var one = maker_function();
......@@ -37,6 +41,7 @@ function assertKind(expected, obj, name_opt) {
var two = maker_function();
assertKind(elements_kind.fast_double, two);
}
%EnsureFeedbackVectorForFunction(run_test);
// Initialize the KeyedStoreIC in foo; the actual operation will be done
// in the runtime.
......
......@@ -31,6 +31,7 @@ function divp4(x) {
return x / 4;
}
%PrepareFunctionForOptimization(divp4);
divp4(8);
divp4(8);
%OptimizeFunctionOnNextCall(divp4);
......@@ -42,6 +43,7 @@ function divn4(x) {
return x / (-4);
}
%PrepareFunctionForOptimization(divn4);
divn4(8);
divn4(8);
%OptimizeFunctionOnNextCall(divn4);
......@@ -55,6 +57,7 @@ function divn1(x) {
return x / (-1);
}
%PrepareFunctionForOptimization(divn1);
var two_31 = 1 << 31;
divn1(2);
divn1(2);
......@@ -68,6 +71,7 @@ function divp4t(x) {
return (x / 4) | 0;
}
%PrepareFunctionForOptimization(divp4t);
divp4t(8);
divp4t(8);
%OptimizeFunctionOnNextCall(divp4t);
......@@ -79,6 +83,7 @@ function divn4t(x) {
return (x / -4) | 0;
}
%PrepareFunctionForOptimization(divn4t);
divn4t(8);
divn4t(8);
%OptimizeFunctionOnNextCall(divn4t);
......@@ -91,6 +96,7 @@ function div_by_two(x) {
return (x / 2) | 0;
}
%PrepareFunctionForOptimization(div_by_two);
div_by_two(12);
div_by_two(34);
%OptimizeFunctionOnNextCall(div_by_two);
......
......@@ -38,6 +38,7 @@ function no_deopt_on_minus_zero(x) {
return Math.sin(x) + Math.cos(x) + Math.tan(x);
}
%PrepareFunctionForOptimization(no_deopt_on_minus_zero);
no_deopt_on_minus_zero(1);
no_deopt_on_minus_zero(1);
%OptimizeFunctionOnNextCall(no_deopt_on_minus_zero);
......
......@@ -28,6 +28,7 @@
// Flags: --allow-natives-syntax --opt --noalways-opt
function check(func, input, expected) {
%PrepareFunctionForOptimization(func);
func(-1);
func(-1);
%OptimizeFunctionOnNextCall(func);
......
......@@ -13,6 +13,7 @@
return a;
}
%PrepareFunctionForOptimization(foo);
foo();
foo();
%OptimizeFunctionOnNextCall(foo);
......@@ -26,9 +27,13 @@
return o.x + o.y;
}
function mapPlus(a, y) {
return a.map(x => hot({x, y}));
var f = (x => hot({x, y}));
%EnsureFeedbackVectorForFunction(f);
return a.map(f);
}
%EnsureFeedbackVectorForFunction(mapPlus);
%PrepareFunctionForOptimization(hot);
var a = [1, 2, 3];
print(mapPlus(a, 1));
print(mapPlus(a, 2));
......@@ -44,10 +49,12 @@
(function() {
var sopen = 'function wrapper() { ';
var s1 = 'function foo() { return bar(5); } ';
var s2 = 'foo(); foo(); %OptimizeFunctionOnNextCall(foo); foo(); ';
var s2 = '%PrepareFunctionForOptimization(foo); ';
var s3 = 'foo(); foo(); %OptimizeFunctionOnNextCall(foo); foo(); ';
var sclose = '} wrapper(); ';
var s = sopen + s1 + s2 + sclose;
var s = sopen + s1 + s2 + s3 + sclose;
function bar(i){return i + 3};
%EnsureFeedbackVectorForFunction(bar);
for (var i = 0; i < 4; i++) {
eval(s);
......
......@@ -37,6 +37,7 @@ function unaryMinusTest(x) {
return (g & -g) - 1 | 0;
}
%PrepareFunctionForOptimization(unaryMinusTest);
unaryMinusTest(3);
unaryMinusTest(3);
%OptimizeFunctionOnNextCall(unaryMinusTest);
......@@ -47,6 +48,7 @@ assertOptimized(unaryMinusTest);
unaryMinusTest(31);
// The following is normally true, but not with --stress-opt. :-/
// assertUnoptimized(unaryMinusTest);
%PrepareFunctionForOptimization(unaryMinusTest);
// We should have learned something from the deopt.
unaryMinusTest(31);
......
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