Commit 41ef63df 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: I81918f174b2f97cbaa8b8ef2e459080c2581f535
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1588415
Commit-Queue: Mythri Alle <mythria@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61122}
parent 397f53ed
......@@ -29,6 +29,7 @@ function CreateManyClosures_Setup() {
// Create a closure and optimize.
var f = g();
%PrepareFunctionForOptimization(f);
f(0);
f(0);
%OptimizeFunctionOnNextCall(f);
......
......@@ -20,6 +20,7 @@ function Inline() {
function Middle() { Inner(); }
function Outer() { Middle(); }
%PrepareFunctionForOptimization(Outer);
Outer();
Outer();
%OptimizeFunctionOnNextCall(Outer);
......
......@@ -31,6 +31,7 @@ function InlineSetup() {
function Middle() { return Inner(); }
function Outer() { return Middle(); }
%PrepareFunctionForOptimization(Outer);
Outer();
Outer();
%OptimizeFunctionOnNextCall(Outer);
......
......@@ -29,6 +29,7 @@
// Flags: --allow-natives-syntax --nostress-opt --opt
function test(f, iterations) {
%PrepareFunctionForOptimization(f);
f();
f();
// Some of the tests need to learn until they stabilize.
......
......@@ -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));
......
......@@ -101,6 +101,7 @@ let tests = {
let { array, expected, array2, expected2 } = tests[key];
// Warmup:
%PrepareFunctionForOptimization(fn);
fn(array);
fn(array);
%OptimizeFunctionOnNextCall(fn);
......@@ -203,6 +204,7 @@ let tests = {
};
// Warmup
%PrepareFunctionForOptimization(sum);
sum(array);
sum(array);
%OptimizeFunctionOnNextCall(sum);
......
......@@ -34,6 +34,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) {
......@@ -315,6 +316,7 @@ function TestThrow() {
throw x;
}
}
%PrepareFunctionForOptimization(f);
for (var i = 0; i < 5; i++) {
try {
f();
......@@ -339,6 +341,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) {
......@@ -361,6 +364,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) {
......@@ -387,6 +391,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) {
......@@ -409,6 +414,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) {
......
......@@ -15,6 +15,7 @@
return maxWithZero(x, y);
}
%PrepareFunctionForOptimization(testMax);
testMax(1, 2);
testMax(1, 2);
%OptimizeFunctionOnNextCall(testMax);
......
......@@ -728,6 +728,9 @@ function assertAccessorDescriptor(object, name) {
function invoke_constructor() { A() }
function call_constructor() { A.call() }
function apply_constructor() { A.apply() }
%PrepareFunctionForOptimization(invoke_constructor);
%PrepareFunctionForOptimization(call_constructor);
%PrepareFunctionForOptimization(apply_constructor);
for (var i=0; i<3; i++) {
assertThrows(invoke_constructor);
......@@ -1106,6 +1109,7 @@ function testClassRestrictedProperties(C) {
" return new clazz(i); })";
let fn = eval(evalString);
%PrepareFunctionForOptimization(fn);
assertEquals(fn(1).value, 1);
assertEquals(fn(2).value, 2);
assertEquals(fn(3).value, 3);
......@@ -1138,6 +1142,7 @@ function testClassRestrictedProperties(C) {
let fn = eval(evalString);
%PrepareFunctionForOptimization(fn);
assertEquals(fn(1).value, 1);
assertEquals(fn(2).value, 2);
assertEquals(fn(3).value, 3);
......@@ -1174,6 +1179,7 @@ function testClassRestrictedProperties(C) {
" return (new clazz(i)); })";
let fn = eval(evalString);
%PrepareFunctionForOptimization(fn);
assertEquals(fn(1).value, 1);
assertEquals(fn(2).value, 2);
assertEquals(fn(3).value, 3);
......
......@@ -5,6 +5,7 @@
// Flags: --allow-natives-syntax
function test(f) {
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);
......
......@@ -25,6 +25,7 @@ function TestSetWithModifiedIterator(ctor) {
arrayIteratorProto.next = originalNext;
}
%PrepareFunctionForOptimization(TestSetWithModifiedIterator);
TestSetWithModifiedIterator(Set);
TestSetWithModifiedIterator(Set);
TestSetWithModifiedIterator(Set);
......@@ -33,6 +34,7 @@ TestSetWithModifiedIterator(Set);
assertOptimized(TestSetWithModifiedIterator);
%DeoptimizeFunction(TestSetWithModifiedIterator);
%PrepareFunctionForOptimization(TestSetWithModifiedIterator);
TestSetWithModifiedIterator(WeakSet);
TestSetWithModifiedIterator(WeakSet);
TestSetWithModifiedIterator(WeakSet);
......@@ -63,6 +65,7 @@ function TestMapWithModifiedIterator(ctor) {
arrayIteratorProto.next = originalNext;
}
%PrepareFunctionForOptimization(TestMapWithModifiedIterator);
TestMapWithModifiedIterator(Map);
TestMapWithModifiedIterator(Map);
TestMapWithModifiedIterator(Map);
......@@ -71,6 +74,7 @@ TestMapWithModifiedIterator(Map);
assertOptimized(TestMapWithModifiedIterator);
%DeoptimizeFunction(TestMapWithModifiedIterator);
%PrepareFunctionForOptimization(TestMapWithModifiedIterator);
TestMapWithModifiedIterator(WeakMap);
TestMapWithModifiedIterator(WeakMap);
TestMapWithModifiedIterator(WeakMap);
......
......@@ -20,6 +20,7 @@ function TestSetWithCustomIterator(ctor) {
assertTrue(set.has(k2));
assertEquals(2, callCount);
}
%PrepareFunctionForOptimization(TestSetWithCustomIterator);
TestSetWithCustomIterator(Set);
TestSetWithCustomIterator(Set);
TestSetWithCustomIterator(Set);
......@@ -28,6 +29,7 @@ TestSetWithCustomIterator(Set);
assertOptimized(TestSetWithCustomIterator);
TestSetWithCustomIterator(WeakSet);
%PrepareFunctionForOptimization(TestSetWithCustomIterator);
TestSetWithCustomIterator(WeakSet);
TestSetWithCustomIterator(WeakSet);
%OptimizeFunctionOnNextCall(TestSetWithCustomIterator);
......@@ -50,6 +52,7 @@ function TestMapWithCustomIterator(ctor) {
assertEquals(2, map.get(k2));
assertEquals(2, callCount);
}
%PrepareFunctionForOptimization(TestMapWithCustomIterator);
TestMapWithCustomIterator(Map);
TestMapWithCustomIterator(Map);
TestMapWithCustomIterator(Map);
......@@ -58,6 +61,7 @@ TestMapWithCustomIterator(Map);
assertOptimized(TestMapWithCustomIterator);
TestMapWithCustomIterator(WeakMap);
%PrepareFunctionForOptimization(TestMapWithCustomIterator);
TestMapWithCustomIterator(WeakMap);
TestMapWithCustomIterator(WeakMap);
%OptimizeFunctionOnNextCall(TestMapWithCustomIterator);
......
......@@ -24,6 +24,7 @@ function TestSetPrototypeModified(ctor) {
ctor.prototype.add = originalPrototypeAdd;
}
%PrepareFunctionForOptimization(TestSetPrototypeModified);
TestSetPrototypeModified(Set);
TestSetPrototypeModified(Set);
TestSetPrototypeModified(Set);
......@@ -32,6 +33,7 @@ TestSetPrototypeModified(Set);
assertOptimized(TestSetPrototypeModified);
%DeoptimizeFunction(TestSetPrototypeModified);
%PrepareFunctionForOptimization(TestSetPrototypeModified);
TestSetPrototypeModified(WeakSet);
TestSetPrototypeModified(WeakSet);
TestSetPrototypeModified(WeakSet);
......@@ -60,6 +62,7 @@ function TestMapPrototypeModified(ctor) {
ctor.prototype.set = originalPrototypeSet;
}
%PrepareFunctionForOptimization(TestMapPrototypeModified);
TestMapPrototypeModified(Map);
TestMapPrototypeModified(Map);
TestMapPrototypeModified(Map);
......@@ -68,6 +71,7 @@ TestMapPrototypeModified(Map);
assertOptimized(TestMapPrototypeModified);
%DeoptimizeFunction(TestMapPrototypeModified);
%PrepareFunctionForOptimization(TestMapPrototypeModified);
TestMapPrototypeModified(WeakMap);
TestMapPrototypeModified(WeakMap);
TestMapPrototypeModified(WeakMap);
......
......@@ -23,6 +23,7 @@
return { [name]: value, __proto__: deoptMe() };
}
%PrepareFunctionForOptimization(f);
checkObject("a", 1, f("a", 1));
checkObject("b", 2, f("b", 2));
%OptimizeFunctionOnNextCall(f);
......
......@@ -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({},{});
......@@ -49,6 +49,7 @@ check();
function f() { return array["-1"]; }
%PrepareFunctionForOptimization(f);
for (var i = 0; i < 3; i++) {
assertEquals(undefined, f());
}
......
......@@ -38,6 +38,7 @@ function TestMapConstructorEntrySideEffect(ctor) {
ctor.prototype.set = originalPrototypeSet;
}
%PrepareFunctionForOptimization(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(Map);
TestMapConstructorEntrySideEffect(Map);
TestMapConstructorEntrySideEffect(Map);
......@@ -45,7 +46,9 @@ TestMapConstructorEntrySideEffect(Map);
TestMapConstructorEntrySideEffect(Map);
assertOptimized(TestMapConstructorEntrySideEffect);
// This call would deopt
TestMapConstructorEntrySideEffect(WeakMap);
%PrepareFunctionForOptimization(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(WeakMap);
TestMapConstructorEntrySideEffect(WeakMap);
%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
......
......@@ -38,6 +38,7 @@ function TestMapConstructorEntrySideEffect(ctor) {
assertEquals(3, col.get(k3));
}
%PrepareFunctionForOptimization(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(Map);
TestMapConstructorEntrySideEffect(Map);
TestMapConstructorEntrySideEffect(Map);
......@@ -45,7 +46,9 @@ TestMapConstructorEntrySideEffect(Map);
TestMapConstructorEntrySideEffect(Map);
assertOptimized(TestMapConstructorEntrySideEffect);
// This call would deopt
TestMapConstructorEntrySideEffect(WeakMap);
%PrepareFunctionForOptimization(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(WeakMap);
TestMapConstructorEntrySideEffect(WeakMap);
%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
......
......@@ -30,6 +30,7 @@ function f(e) {
}
}
%PrepareFunctionForOptimization(f);
f(5);
f(5);
%OptimizeFunctionOnNextCall(f);
......
......@@ -19,6 +19,7 @@ assertTrue(isNaN(Math.fround({ valueOf: function() { return "abc"; } })));
function unopt(x) { return Math.fround(x); }
function opt(y) { return Math.fround(y); }
%PrepareFunctionForOptimization(opt);
opt(0.1);
opt(0.1);
unopt(0.1);
......
......@@ -35,12 +35,14 @@ function testTrunc(expected, input) {
assertEquals(expected, test(input));
assertEquals(expected, test(input));
assertEquals(expected, test(input));
%PrepareFunctionForOptimization(test);
%OptimizeFunctionOnNextCall(test);
assertEquals(expected, test(input));
var test_double_input = new Function(
'n',
'"' + (test_id++) + '";return Math.trunc(+n)');
%PrepareFunctionForOptimization(test_double_input);
assertEquals(expected, test_double_input(input));
assertEquals(expected, test_double_input(input));
assertEquals(expected, test_double_input(input));
......@@ -50,6 +52,7 @@ function testTrunc(expected, input) {
var test_double_output = new Function(
'n',
'"' + (test_id++) + '";return Math.trunc(n) + -0.0');
%PrepareFunctionForOptimization(test_double_output);
assertEquals(expected, test_double_output(input));
assertEquals(expected, test_double_output(input));
assertEquals(expected, test_double_output(input));
......@@ -63,6 +66,7 @@ function test() {
function itrunc(x) {
return 1 / Math.trunc(x);
}
%PrepareFunctionForOptimization(itrunc);
assertEquals(Infinity, itrunc(0));
assertEquals(-Infinity, itrunc(-0));
assertEquals(Infinity, itrunc(Math.PI / 4));
......
......@@ -144,6 +144,7 @@
var object = {
method() { return 42; }
};
%PrepareFunctionForOptimization(object.method);
assertEquals(42, object.method());
assertEquals(42, object.method());
%OptimizeFunctionOnNextCall(object.method);
......
......@@ -966,6 +966,7 @@ assertTrue(
obj2 = Object.create(obj1);
obj3 = Object.create(obj2);
%PrepareFunctionForOptimization(testGetterOnProto);
testGetterOnProto(111, obj3);
testGetterOnProto(111, obj3);
%OptimizeFunctionOnNextCall(testGetterOnProto);
......@@ -974,6 +975,7 @@ testGetterOnProto(111, obj3);
assertTrue(Reflect.defineProperty(obj1, "quebec", { get: anotherGetter }));
%PrepareFunctionForOptimization(testGetterOnProto);
testGetterOnProto(222, obj3);
testGetterOnProto(222, obj3);
%OptimizeFunctionOnNextCall(testGetterOnProto);
......@@ -997,6 +999,7 @@ assertTrue(
obj2 = Object.create(obj1);
obj3 = Object.create(obj2);
%PrepareFunctionForOptimization(testSetterOnProto);
testSetterOnProto(445, obj3);
testSetterOnProto(445, obj3);
%OptimizeFunctionOnNextCall(testSetterOnProto);
......@@ -1005,6 +1008,7 @@ testSetterOnProto(445, obj3);
assertTrue(Reflect.defineProperty(obj1, "romeo", { set: anotherSetter }));
%PrepareFunctionForOptimization(testSetterOnProto);
testSetterOnProto(446, obj3);
testSetterOnProto(446, obj3);
%OptimizeFunctionOnNextCall(testSetterOnProto);
......@@ -1023,6 +1027,7 @@ assertTrue(Reflect.defineProperty(obj1, "sierra",
obj2 = Object.create(obj1);
obj3 = Object.create(obj2);
%PrepareFunctionForOptimization(testSetterOnProtoStrict);
testSetterOnProtoStrict(obj3);
testSetterOnProtoStrict(obj3);
%OptimizeFunctionOnNextCall(testSetterOnProtoStrict);
......@@ -1051,6 +1056,7 @@ function Assign(o) {
function C() {}
%PrepareFunctionForOptimization(Assign);
Assign(new C);
Assign(new C);
%OptimizeFunctionOnNextCall(Assign);
......
......@@ -8,6 +8,7 @@ function foo() {
return Math.clz32(12.34);
}
%PrepareFunctionForOptimization(foo);
foo();
foo();
%OptimizeFunctionOnNextCall(foo);
......
......@@ -19,6 +19,7 @@ function f24(deopt) {
}
%PrepareFunctionForOptimization(f24);
for (var j = 0; j < 10; ++j) {
f24(12);
}
......
......@@ -4,6 +4,7 @@
// Flags: --allow-natives-syntax
%PrepareFunctionForOptimization(print);
try {
%OptimizeFunctionOnNextCall(print);
} catch(e) { }
......@@ -11,5 +12,6 @@ try {
try {
function* f() {
}
%PrepareFunctionForOptimization(f);
%OptimizeFunctionOnNextCall(f);
} catch(e) { }
......@@ -7,6 +7,7 @@
(function(x) {
(function(x) {
var boom = (() => eval(x));
%PrepareFunctionForOptimization(boom);
assertEquals(23, boom());
assertEquals(23, boom());
%OptimizeFunctionOnNextCall(boom);
......@@ -19,6 +20,7 @@
(function(x) {
(function(x) {
var boom = (() => (eval("var x = 66"), x));
%PrepareFunctionForOptimization(boom);
assertEquals(66, boom());
assertEquals(66, boom());
%OptimizeFunctionOnNextCall(boom);
......
......@@ -17,6 +17,7 @@ function g() {
f(6, 5, 4, 3, 2, 1);
};
%PrepareFunctionForOptimization(g);
g();
g();
g();
......
......@@ -9,6 +9,7 @@ function fn(a) {
return b;
}
%PrepareFunctionForOptimization(fn);
fn('a');
fn('a');
%OptimizeFunctionOnNextCall(fn);
......
......@@ -22,6 +22,7 @@ function testArray() {
} catch (e) {
}
}
%PrepareFunctionForOptimization(testArray);
testArray();
testArray();
%OptimizeFunctionOnNextCall(testArray);
......@@ -33,6 +34,7 @@ function testTypedArray() {
} catch (e) {
}
}
%PrepareFunctionForOptimization(testTypedArray);
testTypedArray();
testTypedArray();
%OptimizeFunctionOnNextCall(testTypedArray);
......
......@@ -8,6 +8,7 @@ function bar() {}
bar({ a: new Proxy({}, {}) });
function foo(x) { x.a.b == ""; }
var x = {a: {b: "" }};
%PrepareFunctionForOptimization(foo);
foo(x);
foo(x);
%OptimizeFunctionOnNextCall(foo);
......
......@@ -7,6 +7,7 @@
function g() { return { val: new.target }; }
function f() { return (new g()).val; }
%PrepareFunctionForOptimization(f);
assertEquals(g, f());
assertEquals(g, f());
%OptimizeFunctionOnNextCall(f);
......
......@@ -160,6 +160,7 @@ function id(v) {
function f() {
return [...'abc'];
}
%PrepareFunctionForOptimization(f);
assertArrayEquals(['a', 'b', 'c'], f());
%OptimizeFunctionOnNextCall(f);
assertArrayEquals(['a', 'b', 'c'], f());
......@@ -194,6 +195,7 @@ function id(v) {
return ['a', ...['b', 'c', 'd'], 'e']
}
%PrepareFunctionForOptimization(f);
assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
%OptimizeFunctionOnNextCall(f);
assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
......@@ -211,6 +213,7 @@ function id(v) {
return ['a', ...['b', 'c', 'd'], 'e']
}
%PrepareFunctionForOptimization(f);
assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
%OptimizeFunctionOnNextCall(f);
assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
......@@ -228,6 +231,7 @@ function id(v) {
return ['a', ...['b', 'c', 'd'], 'e']
}
%PrepareFunctionForOptimization(f);
assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
%OptimizeFunctionOnNextCall(f);
assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
......
......@@ -157,6 +157,7 @@ function id(v) {
function f() {
return [...'abc'];
}
%PrepareFunctionForOptimization(f);
assertArrayEquals(['a', 'b', 'c'], f());
%OptimizeFunctionOnNextCall(f);
assertArrayEquals(['a', 'b', 'c'], f());
......
......@@ -13,6 +13,7 @@
return ['a', ...['b', 'c', 'd'], 'e']
}
%PrepareFunctionForOptimization(f);
assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
%OptimizeFunctionOnNextCall(f);
assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
......
......@@ -13,6 +13,7 @@
return ['a', ...['b', 'c', 'd'], 'e']
}
%PrepareFunctionForOptimization(f);
assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
%OptimizeFunctionOnNextCall(f);
assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
......
......@@ -13,6 +13,7 @@
return ['a', ...['b', 'c', 'd'], 'e']
}
%PrepareFunctionForOptimization(f);
assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
%OptimizeFunctionOnNextCall(f);
assertArrayEquals(['a', 'b', 'c', 'd', 'e'], f());
......
......@@ -161,6 +161,7 @@ function testSpreadCallsStrict() {
assertEquals(36, O.sum(0, ...[1], 2, 3, ...[4, 5], 6, 7, 8));
assertEquals(45, O.sum(0, ...[1], 2, 3, ...[4, 5], 6, 7, 8, ...[9]));
};
%PrepareFunctionForOptimization(testSpreadCallsStrict);
testSpreadCallsStrict();
%OptimizeFunctionOnNextCall(testSpreadCallsStrict);
testSpreadCallsStrict();
......
......@@ -43,6 +43,7 @@ function isValidSymbolString(s) {
function TestNew() {
function indirectSymbol() { return Symbol() }
function indirect() { return indirectSymbol() }
%PrepareFunctionForOptimization(indirect);
for (var i = 0; i < 2; ++i) {
for (var j = 0; j < 5; ++j) {
symbols.push(Symbol())
......@@ -519,6 +520,7 @@ function TestComparison() {
var throwFuncs = [lt, gt, le, ge, lt_same, gt_same, le_same, ge_same];
for (var f of throwFuncs) {
%PrepareFunctionForOptimization(f);
assertThrows(f, TypeError);
%OptimizeFunctionOnNextCall(f);
assertThrows(f, TypeError);
......
......@@ -23,7 +23,8 @@
return true;
}
return a.filter(callback);
}
};
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled();
eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled);
......@@ -43,7 +44,8 @@
return i == 0 ? false : true;
}
return a.filter(callback);
}
};
%PrepareFunctionForOptimization(eagerDeoptInCalled);
var like_a = [1,2,3,4,5,6,7,8,9,10];
assertEquals(like_a.slice(1), eagerDeoptInCalled());
eagerDeoptInCalled();
......@@ -66,7 +68,8 @@
return true;
}
return a.filter(callback);
}
};
%PrepareFunctionForOptimization(lazyChanger);
assertEquals(a, lazyChanger());
lazyChanger();
%OptimizeFunctionOnNextCall(lazyChanger);
......@@ -88,7 +91,8 @@
return true;
}
return a.filter(callback);
}
};
%PrepareFunctionForOptimization(lazyDeselection);
assertEquals(a, lazyDeselection());
lazyDeselection();
%OptimizeFunctionOnNextCall(lazyDeselection);
......@@ -111,7 +115,8 @@
return true;
}
a_noescape.filter(callback);
}
};
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled();
eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled);
......@@ -138,7 +143,8 @@
};
%NeverOptimizeFunction(callback);
b.filter(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -160,7 +166,8 @@
return true;
}
a.filter(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -184,7 +191,8 @@
};
%NeverOptimizeFunction(callback);
a.filter(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -209,7 +217,8 @@
return true;
}
a.filter(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -238,7 +247,8 @@
} catch (e) {
caught = true;
}
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -268,7 +278,8 @@
} catch (e) {
caught = true;
}
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -299,7 +310,8 @@
result = "nope";
}
return result;
}
};
%PrepareFunctionForOptimization(lazyDeopt);
assertEquals([1,2,3,4], lazyDeopt(false));
assertEquals([1,2,3,4], lazyDeopt(false));
assertEquals("nope", lazyDeopt(true));
......@@ -326,7 +338,8 @@
};
var o = [1,2,3];
b.filter(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -351,7 +364,8 @@
%NeverOptimizeFunction(callback);
var o = [1,2,3];
b.filter(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -377,7 +391,8 @@
};
var o = [1,2,3];
b.filter(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt();
lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt);
......@@ -401,7 +416,8 @@
return true;
};
a.filter(callback);
}
};
%PrepareFunctionForOptimization(lazyDeopt);
assertThrows(() => lazyDeopt());
assertThrows(() => lazyDeopt());
try {
......@@ -428,6 +444,7 @@
return true;
});
}
%PrepareFunctionForOptimization(withHoles);
withHoles();
withHoles();
%OptimizeFunctionOnNextCall(withHoles);
......@@ -445,6 +462,7 @@
return true;
});
}
%PrepareFunctionForOptimization(withHoles);
withHoles();
withHoles();
%OptimizeFunctionOnNextCall(withHoles);
......@@ -461,6 +479,7 @@
return a.filter(x => x % 2 === 0, side_effect(a, b));
}
%PrepareFunctionForOptimization(unreliable);
let a = [1, 2, 3];
unreliable(a, false);
unreliable(a, false);
......@@ -480,7 +499,8 @@
return true;
}
a.filter(callback);
}
};
%PrepareFunctionForOptimization(species_breakage);
species_breakage();
species_breakage();
%OptimizeFunctionOnNextCall(species_breakage);
......
......@@ -19,7 +19,8 @@ var e = [,,,,0.5,3,4];
result += i;
}
arg.forEach(sum);
}
};
%PrepareFunctionForOptimization(polymorph1);
polymorph1(a);
polymorph1(a);
polymorph1(b);
......@@ -39,7 +40,8 @@ var e = [,,,,0.5,3,4];
result += i;
}
arg.forEach(sum);
}
};
%PrepareFunctionForOptimization(polymorph1);
polymorph1(a);
polymorph1(a);
polymorph1(b);
......@@ -61,7 +63,8 @@ var e = [,,,,0.5,3,4];
result += i;
}
arg.forEach(sum);
}
};
%PrepareFunctionForOptimization(polymorph1);
polymorph1(a);
polymorph1(a);
polymorph1(b);
......@@ -82,7 +85,8 @@ var e = [,,,,0.5,3,4];
result += v;
}
arg.forEach(sum);
}
};
%PrepareFunctionForOptimization(polymorph1);
polymorph1(d);
polymorph1(d);
polymorph1(d);
......@@ -100,7 +104,8 @@ var e = [,,,,0.5,3,4];
result += v;
}
arg.forEach(sum);
}
};
%PrepareFunctionForOptimization(polymorph1);
polymorph1(d);
polymorph1(e);
polymorph1(d);
......
......@@ -39,6 +39,7 @@ function f() {
return pixels[1] + pixels[6];
}
%PrepareFunctionForOptimization(f);
f();
f();
assertEquals(6, pixels[5]);
......
......@@ -19,7 +19,8 @@ assertFalse(isNeverOptimize());
for (var i = 0; i < 3; ++i) {
var f = function(x) {
return 2 * x;
}
};
%PrepareFunctionForOptimization(f);
sum += f(i);
if (i == 1) {
......
......@@ -11,6 +11,7 @@ function foo(s) {
var extern = "internalized dummy";
extern = "1234567890qiaipppiúöäöáœba"+"jalsdjasldjasdlasjdalsdjasldk";
externalizeString(extern, true /* force two-byte */);
%PrepareFunctionForOptimization(foo);
assertEquals(97, foo(extern));
assertEquals(97, foo(extern));
%OptimizeFunctionOnNextCall(foo);
......
......@@ -97,6 +97,7 @@ TEST_F(LapContextTest, CurrentContextInLazyAccessorOnPrototype) {
caller_context->Global()->Set(caller_context, object_key, object).ToChecked();
const char script[] =
"function f() { object.property; object.property = 0; } "
"%PrepareFunctionForOptimization(f); "
"f(); f(); "
"%OptimizeFunctionOnNextCall(f); "
"f();";
......
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