[cleanup] Add missing %PrepareFunctionForOptimize in mjsunit tests

Bug: v8:8801,v8:8394,v8:9183
Change-Id: I55027b3ba0c78f40d82aaf2d160aaf957d02cab5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1662292
Auto-Submit: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62214}
This commit is contained in:
Ross McIlroy 2019-06-17 12:48:08 +01:00 committed by Commit Bot
parent df202cfe7e
commit 994db73210
36 changed files with 68 additions and 1 deletions

View File

@ -19,6 +19,7 @@ class B extends A {
}
}
}
%PrepareFunctionForOptimization(B);
var thrower = new Proxy(A, {
get(target, property, receiver) {

View File

@ -18,6 +18,7 @@ class B extends A {
construction_counter++;
}
}
%PrepareFunctionForOptimization(B);
var superclass_counter = 0;

View File

@ -7,5 +7,6 @@
"use strict";
eval();
var f = ({x}) => { };
%PrepareFunctionForOptimization(f);
%OptimizeFunctionOnNextCall(f);
assertThrows(f);

View File

@ -9,10 +9,12 @@ function foo(a) {
if (a) return arguments[1];
}
%PrepareFunctionForOptimization(foo);
foo(false);
foo(false);
%OptimizeFunctionOnNextCall(foo);
foo(true, 1);
%PrepareFunctionForOptimization(foo);
foo(true, 1);
%OptimizeFunctionOnNextCall(foo);
foo(false);

View File

@ -9,11 +9,13 @@
var o = { [Symbol.toPrimitive]: () => "o" };
%PrepareFunctionForOptimization(eq);
assertTrue(eq(o, o));
assertTrue(eq(o, o));
%OptimizeFunctionOnNextCall(eq);
assertTrue(eq(o, o));
assertTrue(eq("o", o));
%PrepareFunctionForOptimization(eq);
assertTrue(eq(o, "o"));
%OptimizeFunctionOnNextCall(eq);
assertTrue(eq(o, o));
@ -27,11 +29,13 @@
var o = { [Symbol.toPrimitive]: () => "o" };
%PrepareFunctionForOptimization(ne);
assertFalse(ne(o, o));
assertFalse(ne(o, o));
%OptimizeFunctionOnNextCall(ne);
assertFalse(ne(o, o));
assertFalse(ne("o", o));
%PrepareFunctionForOptimization(ne);
assertFalse(ne(o, "o"));
%OptimizeFunctionOnNextCall(ne);
assertFalse(ne(o, o));
@ -47,6 +51,7 @@
var b = {b};
var u = %GetUndetectable();
%PrepareFunctionForOptimization(eq);
assertTrue(eq(a, a));
assertTrue(eq(b, b));
assertFalse(eq(a, b));
@ -61,6 +66,7 @@
assertFalse(eq(a, b));
assertFalse(eq(b, a));
assertTrue(eq(null, u));
%PrepareFunctionForOptimization(eq);
assertTrue(eq(undefined, u));
assertTrue(eq(u, null));
assertTrue(eq(u, undefined));
@ -83,6 +89,7 @@
var b = {b};
var u = %GetUndetectable();
%PrepareFunctionForOptimization(ne);
assertFalse(ne(a, a));
assertFalse(ne(b, b));
assertTrue(ne(a, b));
@ -97,6 +104,7 @@
assertTrue(ne(a, b));
assertTrue(ne(b, a));
assertFalse(ne(null, u));
%PrepareFunctionForOptimization(ne);
assertFalse(ne(undefined, u));
assertFalse(ne(u, null));
assertFalse(ne(u, undefined));

View File

@ -6,5 +6,6 @@
with ({}) {}
f = ({x}) => { };
%PrepareFunctionForOptimization(f);
%OptimizeFunctionOnNextCall(f);
f({});

View File

@ -14,6 +14,7 @@ function foo() {
var f1 = foo();
var f2 = foo();
%PrepareFunctionForOptimization(f1);
// Both closures point to full code.
f1(false);

View File

@ -12,6 +12,7 @@ function foo(o) {
return true;
}
}
%PrepareFunctionForOptimization(foo);
var o = new Proxy({a:1},{
getOwnPropertyDescriptor(target, property) { throw target; }

View File

@ -16,6 +16,8 @@ class C extends Object {
}
}
}
%PrepareFunctionForOptimization(C);
Object.setPrototypeOf(C, parseInt);
assertSame(sentinelObject, new C());
assertSame(sentinelObject, new C());

View File

@ -5,6 +5,7 @@
// Flags: --allow-natives-syntax
function test(f) {
%PrepareFunctionForOptimization(f);
f(0);
f(NaN);
%OptimizeFunctionOnNextCall(f);

View File

@ -8,6 +8,7 @@
var g = (async () => { return JSON.stringify() });
%PrepareFunctionForOptimization(g);
g();
g();
%OptimizeFunctionOnNextCall(g);

View File

@ -16,6 +16,7 @@ class SubClass extends SuperClass {
}
}
%PrepareFunctionForOptimization(SubClass);
new SubClass();
new SubClass();
%OptimizeFunctionOnNextCall(SubClass);

View File

@ -13,6 +13,7 @@ function f(deopt) {
}
}
%PrepareFunctionForOptimization(f);
f(false);
f(false);
%OptimizeFunctionOnNextCall(f);

View File

@ -13,7 +13,8 @@
try { throw 0 } catch(e) {
return b.forEach(callback);
}
}
};
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);

View File

@ -24,6 +24,7 @@ function TestDontSelfHealWithDeoptedCode(run_unoptimized, ClosureFactory) {
// so that the closure doesn't leak in a dead register).
(() => {
var optimized_closure = ClosureFactory();
%PrepareFunctionForOptimization(optimized_closure);
// Use .call to avoid the CallIC retaining the JSFunction in the
// feedback vector via a weak map, which would mean it wouldn't be
// collected in the minor gc below.
@ -40,6 +41,7 @@ function TestDontSelfHealWithDeoptedCode(run_unoptimized, ClosureFactory) {
// old->new remember set.
(() => {
var dummy = function() { return 1; };
%PrepareFunctionForOptimization(dummy);
%OptimizeFunctionOnNextCall(dummy);
dummy();
})();

View File

@ -7,5 +7,6 @@
function f() {}
var src = 'f(' + '0,'.repeat(0x201f) + ')';
var boom = new Function(src);
%PrepareFunctionForOptimization(boom);
%OptimizeFunctionOnNextCall(boom);
boom();

View File

@ -12,6 +12,7 @@ function f() {
g(r);
}
%PrepareFunctionForOptimization(f);
f(); f(); %OptimizeFunctionOnNextCall(f); // Warm-up.
var re;

View File

@ -10,10 +10,12 @@ function foo(a) {
}
}
%PrepareFunctionForOptimization(foo);
foo([1]);
foo([1]);
%OptimizeFunctionOnNextCall(foo);
foo([1]);
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo);
foo([1]);
assertOptimized(foo);

View File

@ -14,6 +14,7 @@ function f(b) {
%_DeoptimizeNow();
return o.t;
}
%PrepareFunctionForOptimization(f);
// Finish slack tracking for C.
for (var i = 0; i < 1000; i++) new C();

View File

@ -9,6 +9,7 @@ function f(a) {
}
x = { [Symbol.toPrimitive]: () => FAIL };
%PrepareFunctionForOptimization(f);
f(1);
f(1);
%OptimizeFunctionOnNextCall(f);
@ -19,6 +20,7 @@ function f(a) {
}
x = { [Symbol.toPrimitive]: () => FAIL };
%PrepareFunctionForOptimization(f);
f(1);
f(1);
%OptimizeFunctionOnNextCall(f);
@ -29,6 +31,7 @@ function f(a) {
}
x = { [Symbol.toPrimitive]: () => FAIL };
%PrepareFunctionForOptimization(f);
f(1);
f(1);
%OptimizeFunctionOnNextCall(f);

View File

@ -11,6 +11,7 @@ foo(1);
foo(1);
%OptimizeFunctionOnNextCall(foo);
foo(1);
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo);
foo(1);
assertOptimized(foo);

View File

@ -52,6 +52,7 @@ F.prototype.foo = function () {
var ctx = new F;
%PrepareFunctionForOptimization(F.prototype.foo);
for (var i = 0; i < 5; i++) ctx.foo();
%OptimizeFunctionOnNextCall(F.prototype.foo);
ctx.foo();

View File

@ -15,6 +15,7 @@ function f(a, i, bool) {
}
return result;
}
%PrepareFunctionForOptimization(f);
function f2(a, c, x, i, d) {
return a[x + c] + a[x - 0] + a[i - d];

View File

@ -37,6 +37,7 @@ assertEquals(e31, -e31*(-1));
var x = {toString : function() {return 1}}
function add(a,b){return a+b;}
%PrepareFunctionForOptimization(add);
add(1,x);
add(1,x);
%OptimizeFunctionOnNextCall(add);
@ -85,6 +86,7 @@ function test(fun,check_fun,a,b,does_throw) {
function minus(a,b) { return a-b };
function check_minus(a,b) { return a-b };
function mod(a,b) { return a%b };
%PrepareFunctionForOptimization(mod);
function check_mod(a,b) { return a%b };
test(minus,check_minus,1,2);
@ -124,16 +126,20 @@ test(mod,check_mod,1,2);
test(mod,check_mod,1,2);
test(mod,check_mod,1<<30,1);
%PrepareFunctionForOptimization(mod);
%OptimizeFunctionOnNextCall(mod);
test(mod,check_mod,1<<30,1);
test(mod,check_mod,1,1<<30);
%PrepareFunctionForOptimization(mod);
%OptimizeFunctionOnNextCall(mod);
test(mod,check_mod,1,1<<30);
test(mod,check_mod,1<<30,-(1<<30));
%PrepareFunctionForOptimization(mod);
%OptimizeFunctionOnNextCall(mod);
test(mod,check_mod,1<<30,-(1<<30));
test(mod,check_mod,1,{},2);
%PrepareFunctionForOptimization(mod);
%OptimizeFunctionOnNextCall(mod);
test(mod,check_mod,1,{},2);
@ -172,6 +178,7 @@ function string_add(a,i) {
var d = [0.1, ,0.3];
return a + d[i];
}
%PrepareFunctionForOptimization(string_add);
string_add(1.1, 0);
string_add("", 0);

View File

@ -15,6 +15,7 @@ function f() {
return result;
}
%PrepareFunctionForOptimization(f);
f();
f();
%OptimizeFunctionOnNextCall(f);

View File

@ -51,6 +51,7 @@ function prepare(base) {
right = 0.5 * base;
}
%PrepareFunctionForOptimization(foo);
prepare(21);
assertEquals("ok", foo());
assertEquals("ok", foo());

View File

@ -43,6 +43,7 @@ function f_store(test, test2, a, i) {
}
var a1 = [0, 0, 0, {}];
%PrepareFunctionForOptimization(f_store);
f_store(true, false, a1, 0);
f_store(true, true, a1, 0);
f_store(false, false, a1, 1);
@ -72,6 +73,7 @@ function f_call(f, test, test2, i) {
return d;
}
%PrepareFunctionForOptimization(f_call);
f_call(test_arg(1.5), true, false, 0);
f_call(test_arg(2.5), true, true, 0);
f_call(test_arg(1), false, false, 1);
@ -100,6 +102,7 @@ function f_external(test, test2, test3, a, i) {
}
var a2 = new Int32Array(10);
%PrepareFunctionForOptimization(f_external);
f_external(true, false, true, a2, 0);
f_external(true, true, true, a2, 0);
f_external(false, false, true, a2, 1);

View File

@ -34,6 +34,7 @@ function f(a, i, l) {
return l + v;
}
%PrepareFunctionForOptimization(f);
assertEquals("test1.5", f(a, 0, "test"));
assertEquals("test1.5", f(a, 0, "test"));
%OptimizeFunctionOnNextCall(f);
@ -51,6 +52,7 @@ function f2(b, a1, a2) {
return "test" + v + x;
}
%PrepareFunctionForOptimization(f2);
f2(true, [1.4,1.8,,1.9], [1.4,1.8,,1.9]);
f2(true, [1.4,1.8,,1.9], [1.4,1.8,,1.9]);
f2(false, [1.4,1.8,,1.9], [1.4,1.8,,1.9]);
@ -63,6 +65,7 @@ function t_smi(a) {
a[0] = 1.5;
}
%PrepareFunctionForOptimization(t_smi);
t_smi([1,,3]);
t_smi([1,,3]);
t_smi([1,,3]);
@ -77,6 +80,7 @@ function t(b) {
b[1] = {};
}
%PrepareFunctionForOptimization(t);
t([1.4, 1.6,,1.8, NaN]);
t([1.4, 1.6,,1.8, NaN]);
%OptimizeFunctionOnNextCall(t);

View File

@ -44,6 +44,7 @@ C = Object.create(B);
function bar(x) { return x.foo(); }
%PrepareFunctionForOptimization(bar);
assertEquals(111, bar(C));
assertEquals(111, bar(C));
ToDictionaryMode(B);
@ -61,6 +62,7 @@ C = Object.create(B);
function boo(x) { return x.baz; }
%PrepareFunctionForOptimization(boo);
assertEquals(111, boo(C));
assertEquals(111, boo(C));
ToDictionaryMode(B);
@ -83,6 +85,7 @@ function fuu(x) {
return setterValue;
}
%PrepareFunctionForOptimization(fuu);
assertEquals(111, fuu(C));
assertEquals(111, fuu(C));
ToDictionaryMode(B);

View File

@ -40,6 +40,8 @@ function factory(worker) {
var f1 = factory(worker1);
var f2 = factory(f1);
%PrepareFunctionForOptimization(f1);
%PrepareFunctionForOptimization(f2);
assertEquals(11, f2(1)); // Result: 1 + f1(0) == 1 + 10.
assertEquals(11, f2(1));
%OptimizeFunctionOnNextCall(f1);

View File

@ -40,6 +40,8 @@ function factory(worker) {
var f1 = factory(worker1);
var f2 = factory(f1);
%PrepareFunctionForOptimization(f1);
%PrepareFunctionForOptimization(f2);
assertEquals(11, f2(1));
%OptimizeFunctionOnNextCall(f1);
assertEquals(10, f1(0));

View File

@ -44,6 +44,7 @@
return arguments.length;
};
%PrepareFunctionForOptimization(object.a);
assertSame(0, object.a());
assertSame(0, object.a());
%OptimizeFunctionOnNextCall(object.a);
@ -71,6 +72,7 @@
return arguments.length;
};
%PrepareFunctionForOptimization(object.a);
assertSame(8, object.a());
assertSame(8, object.a());
%OptimizeFunctionOnNextCall(object.a);

View File

@ -40,6 +40,7 @@ function foo(x, fun) {
return 0;
}
%PrepareFunctionForOptimization(foo);
assertEquals(0, foo(1, funky));
assertEquals(0, foo(1, funky));
%OptimizeFunctionOnNextCall(foo);

View File

@ -32,6 +32,7 @@ function f(o) {
if (true) return o.v && a;
}
%PrepareFunctionForOptimization(f);
f({});
f({});
%OptimizeFunctionOnNextCall(f);
@ -43,6 +44,8 @@ function f2() { return 1 || 2; };
function f3() { return 0 && 2; };
function f4() { return 0 || 2; };
[f1, f2, f3, f4].forEach(function(f) { %PrepareFunctionForOptimization(f); });
function test() {
assertEquals(2, f1());
assertEquals(1, f2());

View File

@ -27,6 +27,7 @@ function g() {
return h(b);
}
%PrepareFunctionForOptimization(g);
g();
g();
%OptimizeFunctionOnNextCall(g);

View File

@ -10,6 +10,7 @@ function f(foo) {
if (null != g) {}
};
%PrepareFunctionForOptimization(f);
f(1.4);
f(1.4);
%OptimizeFunctionOnNextCall(f);