Commit ab99a74c authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[cleanup] Add %PrepareForOptimization to some more mjsunit tests.

Bug=v8:8801,v8:8394,v8:9183

Change-Id: I5bd3505938a49dab0299f1d1d022e8a31cc806c5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1660479
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Auto-Submit: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62178}
parent 7e7c1b10
...@@ -36,6 +36,7 @@ function isLittleEndian() { ...@@ -36,6 +36,7 @@ function isLittleEndian() {
// Test that both kinds of NaNs (signaling or quiet) do not signal // Test that both kinds of NaNs (signaling or quiet) do not signal
function TestAllModes(f) { function TestAllModes(f) {
%PrepareFunctionForOptimization(f);
f(); // Runtime f(); // Runtime
f(); // IC f(); // IC
f(); // IC second time f(); // IC second time
......
...@@ -1053,12 +1053,14 @@ function anotherGetter() { return 222; } ...@@ -1053,12 +1053,14 @@ function anotherGetter() { return 222; }
function testGetterOnProto(expected, o) { function testGetterOnProto(expected, o) {
assertEquals(expected, o.quebec); assertEquals(expected, o.quebec);
} }
%PrepareFunctionForOptimization(testGetterOnProto);
obj1 = {}; obj1 = {};
Object.defineProperty(obj1, "quebec", { get: getter, configurable: true }); Object.defineProperty(obj1, "quebec", { get: getter, configurable: true });
obj2 = Object.create(obj1); obj2 = Object.create(obj1);
obj3 = Object.create(obj2); obj3 = Object.create(obj2);
%PrepareFunctionForOptimization(testGetterOnProto);
testGetterOnProto(111, obj3); testGetterOnProto(111, obj3);
testGetterOnProto(111, obj3); testGetterOnProto(111, obj3);
%OptimizeFunctionOnNextCall(testGetterOnProto); %OptimizeFunctionOnNextCall(testGetterOnProto);
...@@ -1069,6 +1071,7 @@ Object.defineProperty(obj1, "quebec", { get: anotherGetter }); ...@@ -1069,6 +1071,7 @@ Object.defineProperty(obj1, "quebec", { get: anotherGetter });
testGetterOnProto(222, obj3); testGetterOnProto(222, obj3);
testGetterOnProto(222, obj3); testGetterOnProto(222, obj3);
%PrepareFunctionForOptimization(testGetterOnProto);
%OptimizeFunctionOnNextCall(testGetterOnProto); %OptimizeFunctionOnNextCall(testGetterOnProto);
testGetterOnProto(222, obj3); testGetterOnProto(222, obj3);
testGetterOnProto(222, obj3); testGetterOnProto(222, obj3);
...@@ -1083,6 +1086,7 @@ function testSetterOnProto(expected, o) { ...@@ -1083,6 +1086,7 @@ function testSetterOnProto(expected, o) {
o.romeo = 444; o.romeo = 444;
assertEquals(expected, modifyMe); assertEquals(expected, modifyMe);
} }
%PrepareFunctionForOptimization(testSetterOnProto);
obj1 = {}; obj1 = {};
Object.defineProperty(obj1, "romeo", { set: setter, configurable: true }); Object.defineProperty(obj1, "romeo", { set: setter, configurable: true });
...@@ -1099,6 +1103,7 @@ Object.defineProperty(obj1, "romeo", { set: anotherSetter }); ...@@ -1099,6 +1103,7 @@ Object.defineProperty(obj1, "romeo", { set: anotherSetter });
testSetterOnProto(446, obj3); testSetterOnProto(446, obj3);
testSetterOnProto(446, obj3); testSetterOnProto(446, obj3);
%PrepareFunctionForOptimization(testSetterOnProto);
%OptimizeFunctionOnNextCall(testSetterOnProto); %OptimizeFunctionOnNextCall(testSetterOnProto);
testSetterOnProto(446, obj3); testSetterOnProto(446, obj3);
testSetterOnProto(446, obj3); testSetterOnProto(446, obj3);
...@@ -1108,6 +1113,7 @@ function testSetterOnProtoStrict(o) { ...@@ -1108,6 +1113,7 @@ function testSetterOnProtoStrict(o) {
"use strict"; "use strict";
o.sierra = 12345; o.sierra = 12345;
} }
%PrepareFunctionForOptimization(testSetterOnProtoStrict);
obj1 = {}; obj1 = {};
Object.defineProperty(obj1, "sierra", Object.defineProperty(obj1, "sierra",
...@@ -1140,6 +1146,7 @@ assertTrue(exception); ...@@ -1140,6 +1146,7 @@ assertTrue(exception);
function Assign(o) { function Assign(o) {
o.blubb = 123; o.blubb = 123;
} }
%PrepareFunctionForOptimization(Assign);
function C() {} function C() {}
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
// Flags: --allow-natives-syntax // Flags: --allow-natives-syntax
function runLiteralsTest(fn) { function runLiteralsTest(fn) {
%PrepareFunctionForOptimization(fn);
// The first run creates an copy directly from the boilerplate decsription. // The first run creates an copy directly from the boilerplate decsription.
fn(); fn();
// The second run will create the boilerplate. // The second run will create the boilerplate.
...@@ -531,6 +532,7 @@ runLiteralsTest(function TestSlowLiteralOptimized() { ...@@ -531,6 +532,7 @@ runLiteralsTest(function TestSlowLiteralOptimized() {
function f() { function f() {
return {__proto__:null, bar:"barValue"}; return {__proto__:null, bar:"barValue"};
} }
%PrepareFunctionForOptimization(f);
let obj = f(); let obj = f();
assertFalse(%HasFastProperties(obj)); assertFalse(%HasFastProperties(obj));
assertEquals(Object.getPrototypeOf(obj), null); assertEquals(Object.getPrototypeOf(obj), null);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
return v < 2; return v < 2;
}); });
} }
%PrepareFunctionForOptimization(earlyExit);
assertFalse(earlyExit()); assertFalse(earlyExit());
earlyExit(); earlyExit();
%OptimizeFunctionOnNextCall(earlyExit); %OptimizeFunctionOnNextCall(earlyExit);
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
return v < 8; return v < 8;
}); });
} }
%PrepareFunctionForOptimization(softyPlusEarlyExit);
assertFalse(softyPlusEarlyExit(false)); assertFalse(softyPlusEarlyExit(false));
softyPlusEarlyExit(false); softyPlusEarlyExit(false);
%OptimizeFunctionOnNextCall(softyPlusEarlyExit); %OptimizeFunctionOnNextCall(softyPlusEarlyExit);
...@@ -81,6 +83,7 @@ ...@@ -81,6 +83,7 @@
return true; return true;
}); });
} }
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled(); eagerDeoptInCalled();
eagerDeoptInCalled(); eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled); %OptimizeFunctionOnNextCall(eagerDeoptInCalled);
...@@ -102,6 +105,7 @@ ...@@ -102,6 +105,7 @@
return true; return true;
}); });
} }
%PrepareFunctionForOptimization(eagerDeoptInCalled);
assertTrue(eagerDeoptInCalled()); assertTrue(eagerDeoptInCalled());
assertArrayEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], called_values); assertArrayEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], called_values);
eagerDeoptInCalled(); eagerDeoptInCalled();
...@@ -125,6 +129,7 @@ ...@@ -125,6 +129,7 @@
return true; return true;
}); });
} }
%PrepareFunctionForOptimization(lazyChanger);
assertTrue(lazyChanger()); assertTrue(lazyChanger());
lazyChanger(); lazyChanger();
%OptimizeFunctionOnNextCall(lazyChanger); %OptimizeFunctionOnNextCall(lazyChanger);
...@@ -144,6 +149,7 @@ ...@@ -144,6 +149,7 @@
return true; return true;
}); });
} }
%PrepareFunctionForOptimization(lazyChanger);
assertTrue(lazyChanger()); assertTrue(lazyChanger());
lazyChanger(); lazyChanger();
%OptimizeFunctionOnNextCall(lazyChanger); %OptimizeFunctionOnNextCall(lazyChanger);
...@@ -164,6 +170,7 @@ ...@@ -164,6 +170,7 @@
return true; return true;
}); });
} }
%PrepareFunctionForOptimization(lazyChanger);
assertTrue(lazyChanger()); assertTrue(lazyChanger());
lazyChanger(); lazyChanger();
%OptimizeFunctionOnNextCall(lazyChanger); %OptimizeFunctionOnNextCall(lazyChanger);
...@@ -184,6 +191,7 @@ ...@@ -184,6 +191,7 @@
return true; return true;
}); });
} }
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled(); eagerDeoptInCalled();
eagerDeoptInCalled(); eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled); %OptimizeFunctionOnNextCall(eagerDeoptInCalled);
...@@ -207,6 +215,7 @@ ...@@ -207,6 +215,7 @@
return true; return true;
}); });
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -232,6 +241,7 @@ ...@@ -232,6 +241,7 @@
%NeverOptimizeFunction(callback); %NeverOptimizeFunction(callback);
a.every(callback); a.every(callback);
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -259,6 +269,7 @@ ...@@ -259,6 +269,7 @@
caught = true; caught = true;
} }
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -287,6 +298,7 @@ ...@@ -287,6 +298,7 @@
caught = true; caught = true;
} }
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -318,6 +330,7 @@ ...@@ -318,6 +330,7 @@
} }
return result; return result;
} }
%PrepareFunctionForOptimization(lazyDeopt);
assertEquals(true, lazyDeopt(false)); assertEquals(true, lazyDeopt(false));
assertEquals(true, lazyDeopt(false)); assertEquals(true, lazyDeopt(false));
assertEquals("nope", lazyDeopt(true)); assertEquals("nope", lazyDeopt(true));
...@@ -343,6 +356,7 @@ ...@@ -343,6 +356,7 @@
return true; return true;
}); });
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -370,6 +384,7 @@ ...@@ -370,6 +384,7 @@
b.every(callback); b.every(callback);
return did_assert_error; return did_assert_error;
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -397,6 +412,7 @@ ...@@ -397,6 +412,7 @@
}); });
return did_assert_error; return did_assert_error;
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -420,6 +436,7 @@ ...@@ -420,6 +436,7 @@
return true; return true;
}); });
} }
%PrepareFunctionForOptimization(lazyDeopt);
assertThrows(() => lazyDeopt()); assertThrows(() => lazyDeopt());
assertThrows(() => lazyDeopt()); assertThrows(() => lazyDeopt());
try { try {
...@@ -446,6 +463,7 @@ ...@@ -446,6 +463,7 @@
}); });
return callback_values; return callback_values;
} }
%PrepareFunctionForOptimization(withHoles);
withHoles(); withHoles();
withHoles(); withHoles();
%OptimizeFunctionOnNextCall(withHoles); %OptimizeFunctionOnNextCall(withHoles);
...@@ -462,6 +480,7 @@ ...@@ -462,6 +480,7 @@
}); });
return callback_values; return callback_values;
} }
%PrepareFunctionForOptimization(withHoles);
withHoles(); withHoles();
withHoles(); withHoles();
%OptimizeFunctionOnNextCall(withHoles); %OptimizeFunctionOnNextCall(withHoles);
...@@ -476,6 +495,7 @@ ...@@ -476,6 +495,7 @@
function unreliable(a, b) { function unreliable(a, b) {
return a.every(x => true, side_effect(a, b)); return a.every(x => true, side_effect(a, b));
} }
%PrepareFunctionForOptimization(unreliable);
let a = [1, 2, 3]; let a = [1, 2, 3];
unreliable(a, false); unreliable(a, false);
...@@ -492,6 +512,7 @@ ...@@ -492,6 +512,7 @@
function notCallable() { function notCallable() {
return a.every(undefined); return a.every(undefined);
} }
%PrepareFunctionForOptimization(notCallable);
assertThrows(notCallable, TypeError); assertThrows(notCallable, TypeError);
try { notCallable(); } catch(e) { } try { notCallable(); } catch(e) { }
...@@ -509,6 +530,7 @@ ...@@ -509,6 +530,7 @@
return true; return true;
}); });
} }
%PrepareFunctionForOptimization(prototypeChanged);
prototypeChanged(); prototypeChanged();
prototypeChanged(); prototypeChanged();
%OptimizeFunctionOnNextCall(prototypeChanged); %OptimizeFunctionOnNextCall(prototypeChanged);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
return v === 20; return v === 20;
}); });
} }
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled(); eagerDeoptInCalled();
eagerDeoptInCalled(); eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled); %OptimizeFunctionOnNextCall(eagerDeoptInCalled);
...@@ -41,6 +42,7 @@ ...@@ -41,6 +42,7 @@
return v === 9; return v === 9;
}); });
} }
%PrepareFunctionForOptimization(eagerDeoptInCalled);
assertEquals(9, eagerDeoptInCalled()); assertEquals(9, eagerDeoptInCalled());
assertArrayEquals([1, 2, 3, 4, 5, 6, 7, 8, 9], called_values); assertArrayEquals([1, 2, 3, 4, 5, 6, 7, 8, 9], called_values);
eagerDeoptInCalled(); eagerDeoptInCalled();
...@@ -65,6 +67,7 @@ ...@@ -65,6 +67,7 @@
return v > 3; return v > 3;
}); });
} }
%PrepareFunctionForOptimization(lazyChanger);
assertEquals(4, lazyChanger()); assertEquals(4, lazyChanger());
lazyChanger(); lazyChanger();
%OptimizeFunctionOnNextCall(lazyChanger); %OptimizeFunctionOnNextCall(lazyChanger);
...@@ -84,6 +87,7 @@ ...@@ -84,6 +87,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyChanger);
assertEquals(undefined, lazyChanger()); assertEquals(undefined, lazyChanger());
lazyChanger(); lazyChanger();
%OptimizeFunctionOnNextCall(lazyChanger); %OptimizeFunctionOnNextCall(lazyChanger);
...@@ -104,6 +108,7 @@ ...@@ -104,6 +108,7 @@
return v > 3; return v > 3;
}); });
} }
%PrepareFunctionForOptimization(lazyChanger);
assertEquals(4, lazyChanger()); assertEquals(4, lazyChanger());
lazyChanger(); lazyChanger();
%OptimizeFunctionOnNextCall(lazyChanger); %OptimizeFunctionOnNextCall(lazyChanger);
...@@ -124,6 +129,7 @@ ...@@ -124,6 +129,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled(); eagerDeoptInCalled();
eagerDeoptInCalled(); eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled); %OptimizeFunctionOnNextCall(eagerDeoptInCalled);
...@@ -147,6 +153,7 @@ ...@@ -147,6 +153,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -172,6 +179,7 @@ ...@@ -172,6 +179,7 @@
%NeverOptimizeFunction(callback); %NeverOptimizeFunction(callback);
a.find(callback); a.find(callback);
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -199,6 +207,7 @@ ...@@ -199,6 +207,7 @@
caught = true; caught = true;
} }
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -227,6 +236,7 @@ ...@@ -227,6 +236,7 @@
caught = true; caught = true;
} }
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -258,6 +268,7 @@ ...@@ -258,6 +268,7 @@
} }
return result; return result;
} }
%PrepareFunctionForOptimization(lazyDeopt);
assertEquals(3, lazyDeopt(false)); assertEquals(3, lazyDeopt(false));
assertEquals(3, lazyDeopt(false)); assertEquals(3, lazyDeopt(false));
assertEquals("nope", lazyDeopt(true)); assertEquals("nope", lazyDeopt(true));
...@@ -283,6 +294,7 @@ ...@@ -283,6 +294,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -310,6 +322,7 @@ ...@@ -310,6 +322,7 @@
b.find(callback); b.find(callback);
return did_assert_error; return did_assert_error;
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -337,6 +350,7 @@ ...@@ -337,6 +350,7 @@
}); });
return did_assert_error; return did_assert_error;
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -360,6 +374,7 @@ ...@@ -360,6 +374,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyDeopt);
assertThrows(() => lazyDeopt()); assertThrows(() => lazyDeopt());
assertThrows(() => lazyDeopt()); assertThrows(() => lazyDeopt());
try { try {
...@@ -385,6 +400,7 @@ ...@@ -385,6 +400,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(prototypeChanged);
prototypeChanged(); prototypeChanged();
prototypeChanged(); prototypeChanged();
%OptimizeFunctionOnNextCall(prototypeChanged); %OptimizeFunctionOnNextCall(prototypeChanged);
...@@ -406,6 +422,7 @@ ...@@ -406,6 +422,7 @@
}); });
return callback_values; return callback_values;
} }
%PrepareFunctionForOptimization(withHoles);
withHoles(); withHoles();
withHoles(); withHoles();
%OptimizeFunctionOnNextCall(withHoles); %OptimizeFunctionOnNextCall(withHoles);
...@@ -422,6 +439,7 @@ ...@@ -422,6 +439,7 @@
}); });
return callback_values; return callback_values;
} }
%PrepareFunctionForOptimization(withHoles);
withHoles(); withHoles();
withHoles(); withHoles();
%OptimizeFunctionOnNextCall(withHoles); %OptimizeFunctionOnNextCall(withHoles);
...@@ -436,6 +454,7 @@ ...@@ -436,6 +454,7 @@
function unreliable(a, b) { function unreliable(a, b) {
return a.find(x => false, side_effect(a, b)); return a.find(x => false, side_effect(a, b));
} }
%PrepareFunctionForOptimization(unreliable);
let a = [1, 2, 3]; let a = [1, 2, 3];
unreliable(a, false); unreliable(a, false);
...@@ -452,6 +471,7 @@ ...@@ -452,6 +471,7 @@
function notCallable() { function notCallable() {
return a.find(undefined); return a.find(undefined);
} }
%PrepareFunctionForOptimization(notCallable);
assertThrows(notCallable, TypeError); assertThrows(notCallable, TypeError);
try { notCallable(); } catch(e) { } try { notCallable(); } catch(e) { }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
return v === 20; return v === 20;
}); });
} }
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled(); eagerDeoptInCalled();
eagerDeoptInCalled(); eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled); %OptimizeFunctionOnNextCall(eagerDeoptInCalled);
...@@ -41,6 +42,7 @@ ...@@ -41,6 +42,7 @@
return v === 9; return v === 9;
}); });
} }
%PrepareFunctionForOptimization(eagerDeoptInCalled);
assertEquals(8, eagerDeoptInCalled()); assertEquals(8, eagerDeoptInCalled());
assertArrayEquals([1, 2, 3, 4, 5, 6, 7, 8, 9], called_values); assertArrayEquals([1, 2, 3, 4, 5, 6, 7, 8, 9], called_values);
eagerDeoptInCalled(); eagerDeoptInCalled();
...@@ -65,6 +67,7 @@ ...@@ -65,6 +67,7 @@
return v > 3; return v > 3;
}); });
} }
%PrepareFunctionForOptimization(lazyChanger);
assertEquals(3, lazyChanger()); assertEquals(3, lazyChanger());
lazyChanger(); lazyChanger();
%OptimizeFunctionOnNextCall(lazyChanger); %OptimizeFunctionOnNextCall(lazyChanger);
...@@ -84,6 +87,7 @@ ...@@ -84,6 +87,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyChanger);
assertEquals(-1, lazyChanger()); assertEquals(-1, lazyChanger());
lazyChanger(); lazyChanger();
%OptimizeFunctionOnNextCall(lazyChanger); %OptimizeFunctionOnNextCall(lazyChanger);
...@@ -104,6 +108,7 @@ ...@@ -104,6 +108,7 @@
return v > 3; return v > 3;
}); });
} }
%PrepareFunctionForOptimization(lazyChanger);
assertEquals(3, lazyChanger()); assertEquals(3, lazyChanger());
lazyChanger(); lazyChanger();
%OptimizeFunctionOnNextCall(lazyChanger); %OptimizeFunctionOnNextCall(lazyChanger);
...@@ -124,6 +129,7 @@ ...@@ -124,6 +129,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled(); eagerDeoptInCalled();
eagerDeoptInCalled(); eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled); %OptimizeFunctionOnNextCall(eagerDeoptInCalled);
...@@ -147,6 +153,7 @@ ...@@ -147,6 +153,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -172,6 +179,7 @@ ...@@ -172,6 +179,7 @@
%NeverOptimizeFunction(callback); %NeverOptimizeFunction(callback);
a.findIndex(callback); a.findIndex(callback);
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -199,6 +207,7 @@ ...@@ -199,6 +207,7 @@
caught = true; caught = true;
} }
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -227,6 +236,7 @@ ...@@ -227,6 +236,7 @@
caught = true; caught = true;
} }
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -258,6 +268,7 @@ ...@@ -258,6 +268,7 @@
} }
return result; return result;
} }
%PrepareFunctionForOptimization(lazyDeopt);
assertEquals(2, lazyDeopt(false)); assertEquals(2, lazyDeopt(false));
assertEquals(2, lazyDeopt(false)); assertEquals(2, lazyDeopt(false));
assertEquals("nope", lazyDeopt(true)); assertEquals("nope", lazyDeopt(true));
...@@ -283,6 +294,7 @@ ...@@ -283,6 +294,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -310,6 +322,7 @@ ...@@ -310,6 +322,7 @@
b.findIndex(callback); b.findIndex(callback);
return did_assert_error; return did_assert_error;
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -337,6 +350,7 @@ ...@@ -337,6 +350,7 @@
}); });
return did_assert_error; return did_assert_error;
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -360,6 +374,7 @@ ...@@ -360,6 +374,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyDeopt);
assertThrows(() => lazyDeopt()); assertThrows(() => lazyDeopt());
assertThrows(() => lazyDeopt()); assertThrows(() => lazyDeopt());
try { try {
...@@ -385,6 +400,7 @@ ...@@ -385,6 +400,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(prototypeChanged);
prototypeChanged(); prototypeChanged();
prototypeChanged(); prototypeChanged();
%OptimizeFunctionOnNextCall(prototypeChanged); %OptimizeFunctionOnNextCall(prototypeChanged);
...@@ -406,6 +422,7 @@ ...@@ -406,6 +422,7 @@
}); });
return callback_values; return callback_values;
} }
%PrepareFunctionForOptimization(withHoles);
withHoles(); withHoles();
withHoles(); withHoles();
%OptimizeFunctionOnNextCall(withHoles); %OptimizeFunctionOnNextCall(withHoles);
...@@ -422,6 +439,7 @@ ...@@ -422,6 +439,7 @@
}); });
return callback_values; return callback_values;
} }
%PrepareFunctionForOptimization(withHoles);
withHoles(); withHoles();
withHoles(); withHoles();
%OptimizeFunctionOnNextCall(withHoles); %OptimizeFunctionOnNextCall(withHoles);
...@@ -436,6 +454,7 @@ ...@@ -436,6 +454,7 @@
function unreliable(a, b) { function unreliable(a, b) {
return a.findIndex(x => false, side_effect(a, b)); return a.findIndex(x => false, side_effect(a, b));
} }
%PrepareFunctionForOptimization(unreliable);
let a = [1, 2, 3]; let a = [1, 2, 3];
unreliable(a, false); unreliable(a, false);
...@@ -452,6 +471,7 @@ ...@@ -452,6 +471,7 @@
function notCallable() { function notCallable() {
return a.findIndex(undefined); return a.findIndex(undefined);
} }
%PrepareFunctionForOptimization(notCallable);
assertThrows(notCallable, TypeError); assertThrows(notCallable, TypeError);
try { notCallable(); } catch(e) { } try { notCallable(); } catch(e) { }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
return v > 2; return v > 2;
}); });
} }
%PrepareFunctionForOptimization(earlyExit);
assertTrue(earlyExit()); assertTrue(earlyExit());
earlyExit(); earlyExit();
%OptimizeFunctionOnNextCall(earlyExit); %OptimizeFunctionOnNextCall(earlyExit);
...@@ -35,6 +36,7 @@ ...@@ -35,6 +36,7 @@
return v > 7; return v > 7;
}); });
} }
%PrepareFunctionForOptimization(softyPlusEarlyExit);
assertTrue(softyPlusEarlyExit(false)); assertTrue(softyPlusEarlyExit(false));
softyPlusEarlyExit(false); softyPlusEarlyExit(false);
%OptimizeFunctionOnNextCall(softyPlusEarlyExit); %OptimizeFunctionOnNextCall(softyPlusEarlyExit);
...@@ -58,6 +60,7 @@ ...@@ -58,6 +60,7 @@
return v > 7; return v > 7;
}); });
} }
%PrepareFunctionForOptimization(softyPlusEarlyExit);
assertTrue(softyPlusEarlyExit(false)); assertTrue(softyPlusEarlyExit(false));
assertArrayEquals([1, 2, 3, 4, 5, 6, 7, 8], called_values); assertArrayEquals([1, 2, 3, 4, 5, 6, 7, 8], called_values);
softyPlusEarlyExit(false); softyPlusEarlyExit(false);
...@@ -81,6 +84,7 @@ ...@@ -81,6 +84,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled(); eagerDeoptInCalled();
eagerDeoptInCalled(); eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled); %OptimizeFunctionOnNextCall(eagerDeoptInCalled);
...@@ -102,6 +106,7 @@ ...@@ -102,6 +106,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(eagerDeoptInCalled);
assertFalse(eagerDeoptInCalled()); assertFalse(eagerDeoptInCalled());
assertArrayEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], called_values); assertArrayEquals([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], called_values);
eagerDeoptInCalled(); eagerDeoptInCalled();
...@@ -125,6 +130,7 @@ ...@@ -125,6 +130,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyChanger);
assertFalse(lazyChanger()); assertFalse(lazyChanger());
lazyChanger(); lazyChanger();
%OptimizeFunctionOnNextCall(lazyChanger); %OptimizeFunctionOnNextCall(lazyChanger);
...@@ -144,6 +150,7 @@ ...@@ -144,6 +150,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyChanger);
assertFalse(lazyChanger()); assertFalse(lazyChanger());
lazyChanger(); lazyChanger();
%OptimizeFunctionOnNextCall(lazyChanger); %OptimizeFunctionOnNextCall(lazyChanger);
...@@ -164,6 +171,7 @@ ...@@ -164,6 +171,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyChanger);
assertFalse(lazyChanger()); assertFalse(lazyChanger());
lazyChanger(); lazyChanger();
%OptimizeFunctionOnNextCall(lazyChanger); %OptimizeFunctionOnNextCall(lazyChanger);
...@@ -184,6 +192,7 @@ ...@@ -184,6 +192,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(eagerDeoptInCalled);
eagerDeoptInCalled(); eagerDeoptInCalled();
eagerDeoptInCalled(); eagerDeoptInCalled();
%OptimizeFunctionOnNextCall(eagerDeoptInCalled); %OptimizeFunctionOnNextCall(eagerDeoptInCalled);
...@@ -207,6 +216,7 @@ ...@@ -207,6 +216,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -232,6 +242,7 @@ ...@@ -232,6 +242,7 @@
%NeverOptimizeFunction(callback); %NeverOptimizeFunction(callback);
a.some(callback); a.some(callback);
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -259,6 +270,7 @@ ...@@ -259,6 +270,7 @@
caught = true; caught = true;
} }
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -287,6 +299,7 @@ ...@@ -287,6 +299,7 @@
caught = true; caught = true;
} }
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -318,6 +331,7 @@ ...@@ -318,6 +331,7 @@
} }
return result; return result;
} }
%PrepareFunctionForOptimization(lazyDeopt);
assertEquals(false, lazyDeopt(false)); assertEquals(false, lazyDeopt(false));
assertEquals(false, lazyDeopt(false)); assertEquals(false, lazyDeopt(false));
assertEquals("nope", lazyDeopt(true)); assertEquals("nope", lazyDeopt(true));
...@@ -343,6 +357,7 @@ ...@@ -343,6 +357,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -370,6 +385,7 @@ ...@@ -370,6 +385,7 @@
b.some(callback); b.some(callback);
return did_assert_error; return did_assert_error;
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -397,6 +413,7 @@ ...@@ -397,6 +413,7 @@
}); });
return did_assert_error; return did_assert_error;
} }
%PrepareFunctionForOptimization(lazyDeopt);
lazyDeopt(); lazyDeopt();
lazyDeopt(); lazyDeopt();
%OptimizeFunctionOnNextCall(lazyDeopt); %OptimizeFunctionOnNextCall(lazyDeopt);
...@@ -420,6 +437,7 @@ ...@@ -420,6 +437,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(lazyDeopt);
assertThrows(() => lazyDeopt()); assertThrows(() => lazyDeopt());
assertThrows(() => lazyDeopt()); assertThrows(() => lazyDeopt());
try { try {
...@@ -445,6 +463,7 @@ ...@@ -445,6 +463,7 @@
return false; return false;
}); });
} }
%PrepareFunctionForOptimization(prototypeChanged);
prototypeChanged(); prototypeChanged();
prototypeChanged(); prototypeChanged();
%OptimizeFunctionOnNextCall(prototypeChanged); %OptimizeFunctionOnNextCall(prototypeChanged);
...@@ -466,6 +485,7 @@ ...@@ -466,6 +485,7 @@
}); });
return callback_values; return callback_values;
} }
%PrepareFunctionForOptimization(withHoles);
withHoles(); withHoles();
withHoles(); withHoles();
%OptimizeFunctionOnNextCall(withHoles); %OptimizeFunctionOnNextCall(withHoles);
...@@ -482,6 +502,7 @@ ...@@ -482,6 +502,7 @@
}); });
return callback_values; return callback_values;
} }
%PrepareFunctionForOptimization(withHoles);
withHoles(); withHoles();
withHoles(); withHoles();
%OptimizeFunctionOnNextCall(withHoles); %OptimizeFunctionOnNextCall(withHoles);
...@@ -494,6 +515,7 @@ ...@@ -494,6 +515,7 @@
function notCallable() { function notCallable() {
return a.some(undefined); return a.some(undefined);
} }
%PrepareFunctionForOptimization(notCallable);
assertThrows(notCallable, TypeError); assertThrows(notCallable, TypeError);
try { notCallable(); } catch(e) { } try { notCallable(); } catch(e) { }
......
...@@ -60,6 +60,7 @@ function test_props(a) { ...@@ -60,6 +60,7 @@ function test_props(a) {
} }
} }
%PrepareFunctionForOptimization(test_props);
test_props(z); test_props(z);
test_props(z); test_props(z);
%OptimizeFunctionOnNextCall(test_props); %OptimizeFunctionOnNextCall(test_props);
......
...@@ -94,6 +94,7 @@ function test6() { ...@@ -94,6 +94,7 @@ function test6() {
function test_with_optimization(f) { function test_with_optimization(f) {
// Run tests in a loop to make sure that inlined Array() constructor runs out // Run tests in a loop to make sure that inlined Array() constructor runs out
// of new space memory and must fall back on runtime impl. // of new space memory and must fall back on runtime impl.
%PrepareFunctionForOptimization(f);
for (i = 0; i < 25000; ++i) f(); for (i = 0; i < 25000; ++i) f();
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
for (i = 0; i < 25000; ++i) f(); // Make sure GC happens for (i = 0; i < 25000; ++i) f(); // Make sure GC happens
......
...@@ -45,6 +45,7 @@ function testPolymorphicLoads() { ...@@ -45,6 +45,7 @@ function testPolymorphicLoads() {
function load(a, i) { function load(a, i) {
return a[i]; return a[i];
} }
%PrepareFunctionForOptimization(load);
var object_array = new Object; var object_array = new Object;
var sparse_object_array = new Object; var sparse_object_array = new Object;
...@@ -110,6 +111,7 @@ function testPolymorphicStores() { ...@@ -110,6 +111,7 @@ function testPolymorphicStores() {
function store(a, i, val) { function store(a, i, val) {
a[i] = val; a[i] = val;
} }
%PrepareFunctionForOptimization(store);
var object_array = new Object; var object_array = new Object;
var sparse_object_array = new Object; var sparse_object_array = new Object;
......
...@@ -35,6 +35,7 @@ var deopt_setter = false; ...@@ -35,6 +35,7 @@ var deopt_setter = false;
function f_mono(o) { function f_mono(o) {
return 5 + o.x++; return 5 + o.x++;
} }
%PrepareFunctionForOptimization(f_mono);
var to_deopt = f_mono; var to_deopt = f_mono;
...@@ -75,6 +76,7 @@ assertEquals(3, s); ...@@ -75,6 +76,7 @@ assertEquals(3, s);
function f_poly(o) { function f_poly(o) {
return 5 + o.x++; return 5 + o.x++;
} }
%PrepareFunctionForOptimization(f_poly);
v = 1; v = 1;
to_deopt = f_poly; to_deopt = f_poly;
...@@ -93,6 +95,7 @@ assertEquals(8, f_poly(o2)); ...@@ -93,6 +95,7 @@ assertEquals(8, f_poly(o2));
assertEquals(6, g); assertEquals(6, g);
assertEquals(6, s); assertEquals(6, s);
%PrepareFunctionForOptimization(f_poly);
%OptimizeFunctionOnNextCall(f_poly); %OptimizeFunctionOnNextCall(f_poly);
v = undefined; v = undefined;
assertEquals(NaN, f_poly(o2)); assertEquals(NaN, f_poly(o2));
...@@ -102,6 +105,7 @@ assertEquals(7, s); ...@@ -102,6 +105,7 @@ assertEquals(7, s);
function f_pre(o) { function f_pre(o) {
return 5 + ++o.x; return 5 + ++o.x;
} }
%PrepareFunctionForOptimization(f_pre);
v = 1; v = 1;
to_deopt = f_pre; to_deopt = f_pre;
...@@ -120,6 +124,7 @@ assertEquals(9, f_pre(o2)); ...@@ -120,6 +124,7 @@ assertEquals(9, f_pre(o2));
assertEquals(10, g); assertEquals(10, g);
assertEquals(10, s); assertEquals(10, s);
%PrepareFunctionForOptimization(f_pre);
%OptimizeFunctionOnNextCall(f_pre); %OptimizeFunctionOnNextCall(f_pre);
v = undefined; v = undefined;
assertEquals(NaN, f_pre(o2)); assertEquals(NaN, f_pre(o2));
...@@ -130,6 +135,7 @@ assertEquals(11, s); ...@@ -130,6 +135,7 @@ assertEquals(11, s);
function f_get(o) { function f_get(o) {
return 5 + o.x++; return 5 + o.x++;
} }
%PrepareFunctionForOptimization(f_get);
v = 1; v = 1;
to_deopt = f_get; to_deopt = f_get;
...@@ -148,6 +154,7 @@ assertEquals(8, f_get(o2)); ...@@ -148,6 +154,7 @@ assertEquals(8, f_get(o2));
assertEquals(14, g); assertEquals(14, g);
assertEquals(14, s); assertEquals(14, s);
%PrepareFunctionForOptimization(f_get);
%OptimizeFunctionOnNextCall(f_get); %OptimizeFunctionOnNextCall(f_get);
v = undefined; v = undefined;
assertEquals(NaN, f_get(o2)); assertEquals(NaN, f_get(o2));
......
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