[Test] Add PrepareForOptimization to some mjsunit tests.
Bug: v8:8801, v8:8394 Change-Id: I6bb46ecafe1bd94adbf0409f13c9b2e558da0823 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1594558 Commit-Queue: Ross McIlroy <rmcilroy@chromium.org> Commit-Queue: Mythri Alle <mythria@chromium.org> Auto-Submit: Ross McIlroy <rmcilroy@chromium.org> Reviewed-by: Mythri Alle <mythria@chromium.org> Cr-Commit-Position: refs/heads/master@{#61200}
This commit is contained in:
parent
3460e02064
commit
5b794a389b
@ -105,6 +105,8 @@ function get_standard_literal() {
|
||||
return literal;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(get_standard_literal);
|
||||
|
||||
// Case: [1,2,3] as allocation site
|
||||
obj = fastliteralcase(get_standard_literal(), 1);
|
||||
assertKind(elements_kind.fast_smi_only, obj);
|
||||
@ -321,6 +323,8 @@ function instanceof_check2(type) {
|
||||
assertTrue(new type(1,2,3) instanceof type);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(instanceof_check);
|
||||
|
||||
var realmBArray = Realm.eval(realmB, "Array");
|
||||
// Two calls with Array because ES6 instanceof desugars into a load of Array,
|
||||
// and load has a premonomorphic state.
|
||||
@ -354,10 +358,12 @@ assertOptimized(instanceof_check);
|
||||
// Try to optimize again, but first clear all type feedback, and allow it
|
||||
// to be monomorphic on first call. Only after optimizing do we introduce
|
||||
// realmBArray. This should deopt the method.
|
||||
%PrepareFunctionForOptimization(instanceof_check);
|
||||
%DeoptimizeFunction(instanceof_check);
|
||||
%ClearFunctionFeedback(instanceof_check);
|
||||
instanceof_check(Array);
|
||||
instanceof_check(Array);
|
||||
%PrepareFunctionForOptimization(instanceof_check);
|
||||
%OptimizeFunctionOnNextCall(instanceof_check);
|
||||
instanceof_check(Array);
|
||||
assertOptimized(instanceof_check);
|
||||
|
@ -16,11 +16,13 @@
|
||||
return f.apply(null, arguments);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(test1);
|
||||
assertEquals(test1(1, 2), 3);
|
||||
assertEquals(test1(1, 2, 3), 3);
|
||||
|
||||
%OptimizeFunctionOnNextCall(test1);
|
||||
assertEquals(test1(1, 2), 3);
|
||||
%PrepareFunctionForOptimization(test1);
|
||||
%OptimizeFunctionOnNextCall(test1);
|
||||
assertEquals(test1(1, 2, 3), 3);
|
||||
})();
|
||||
@ -35,11 +37,13 @@
|
||||
return f.apply(null, arguments);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(test2);
|
||||
assertEquals(test2(1, 2), 3);
|
||||
assertEquals(test2(1, 2, 3), 3);
|
||||
|
||||
%OptimizeFunctionOnNextCall(test2);
|
||||
assertEquals(test2(1, 2), 3);
|
||||
%PrepareFunctionForOptimization(test2);
|
||||
%OptimizeFunctionOnNextCall(test2);
|
||||
assertEquals(test2(1, 2, 3), 3);
|
||||
})();
|
||||
@ -57,11 +61,13 @@
|
||||
return f.apply(null, arguments);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(test3);
|
||||
assertEquals(test3(1, 2), 3);
|
||||
assertEquals(test3(1, 2, 3), 3);
|
||||
|
||||
%OptimizeFunctionOnNextCall(test3);
|
||||
assertEquals(test3(11, 12), 23);
|
||||
%PrepareFunctionForOptimization(test3);
|
||||
%OptimizeFunctionOnNextCall(test3);
|
||||
assertEquals(test3(11, 12, 13), 23);
|
||||
})();
|
||||
@ -80,11 +86,13 @@
|
||||
test4(1, 2);
|
||||
test4(3, 4, 5);
|
||||
|
||||
%PrepareFunctionForOptimization(test4);
|
||||
assertEquals(test4(1, 2), 6);
|
||||
assertEquals(test4(1, 2, 3), 6);
|
||||
|
||||
%OptimizeFunctionOnNextCall(test4);
|
||||
assertEquals(test4(1, 2), 6);
|
||||
%PrepareFunctionForOptimization(test4);
|
||||
%OptimizeFunctionOnNextCall(test4);
|
||||
assertEquals(test4(1, 2, 3), 6);
|
||||
})();
|
||||
@ -102,6 +110,7 @@
|
||||
return sum;
|
||||
};
|
||||
|
||||
%PrepareFunctionForOptimization(sum1);
|
||||
var args = []
|
||||
for (var i = 1; i < 30; ++i) {
|
||||
args.push(i);
|
||||
@ -121,6 +130,7 @@
|
||||
return sum;
|
||||
};
|
||||
|
||||
%PrepareFunctionForOptimization(sum2);
|
||||
var args = []
|
||||
for (var i = 1; i < 30; ++i) {
|
||||
args.push(i);
|
||||
@ -140,6 +150,7 @@
|
||||
return sum;
|
||||
};
|
||||
|
||||
%PrepareFunctionForOptimization(sum3);
|
||||
var args = []
|
||||
for (var i = 1; i < 30; ++i) {
|
||||
args.push(i);
|
||||
@ -159,6 +170,7 @@
|
||||
return sum;
|
||||
};
|
||||
|
||||
%PrepareFunctionForOptimization(sum4);
|
||||
var args = []
|
||||
for (var i = 1; i < 30; ++i) {
|
||||
args.push(i);
|
||||
@ -174,6 +186,7 @@
|
||||
return arguments[arguments.length-1];
|
||||
};
|
||||
|
||||
%PrepareFunctionForOptimization(read);
|
||||
var args = []
|
||||
for (var i = 1; i < 30; ++i) {
|
||||
args.push(i);
|
||||
|
@ -62,8 +62,9 @@ function assertKind(expected, obj, name_opt) {
|
||||
function get_literal(x) {
|
||||
var literal = [1, 2, x];
|
||||
return literal;
|
||||
}
|
||||
};
|
||||
|
||||
%PrepareFunctionForOptimization(get_literal);
|
||||
get_literal(3);
|
||||
// It's important to store a from before we crankshaft get_literal, because
|
||||
// mementos won't be created from crankshafted code at all.
|
||||
@ -84,6 +85,7 @@ assertEquals([1, 2, 3], b);
|
||||
assertUnoptimized(get_literal);
|
||||
|
||||
// Optimize again
|
||||
%PrepareFunctionForOptimization(get_literal);
|
||||
get_literal(3);
|
||||
%OptimizeFunctionOnNextCall(get_literal);
|
||||
b = get_literal(3);
|
||||
@ -109,7 +111,8 @@ assertOptimized(get_literal);
|
||||
(function changeOptimizedEmptyArrayKind() {
|
||||
function f() {
|
||||
return new Array();
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(f);
|
||||
var a = f();
|
||||
assertKind('packed smi elements', a);
|
||||
a = f();
|
||||
@ -125,7 +128,8 @@ assertOptimized(get_literal);
|
||||
(function changeOptimizedArrayLiteralKind() {
|
||||
function f() {
|
||||
return [1, 2];
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(f);
|
||||
var a = f();
|
||||
assertKind('packed smi elements', a);
|
||||
|
||||
@ -160,7 +164,8 @@ assertOptimized(get_literal);
|
||||
(function changeOptimizedEmptyArrayLiteralKind() {
|
||||
function f() {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(f);
|
||||
var a = f();
|
||||
assertKind('packed smi elements', a);
|
||||
assertFalse(isHoley(a));
|
||||
@ -190,7 +195,8 @@ assertOptimized(get_literal);
|
||||
var literal = [];
|
||||
%HeapObjectVerify(literal);
|
||||
return literal;
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(f);
|
||||
var a = f();
|
||||
assertKind('packed smi elements', a);
|
||||
assertFalse(isHoley(a));
|
||||
|
@ -80,6 +80,7 @@ function array_literal_test() {
|
||||
assertEquals(1, f0[0]);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(array_literal_test);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
array_literal_test();
|
||||
}
|
||||
@ -109,6 +110,7 @@ function test_large_literal() {
|
||||
new Object(), new Object(), new Object(), new Object()]);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(test_large_literal);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
test_large_literal();
|
||||
}
|
||||
@ -123,6 +125,7 @@ function deopt_array(use_literal) {
|
||||
}
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(deopt_array);
|
||||
deopt_array(false);
|
||||
deopt_array(false);
|
||||
deopt_array(false);
|
||||
@ -140,6 +143,7 @@ function deopt_array_literal_all_smis(a) {
|
||||
return [0, 1, a];
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(deopt_array_literal_all_smis);
|
||||
deopt_array_literal_all_smis(2);
|
||||
deopt_array_literal_all_smis(3);
|
||||
deopt_array_literal_all_smis(4);
|
||||
@ -165,6 +169,7 @@ function deopt_array_literal_all_doubles(a) {
|
||||
return [0.5, 1, a];
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(deopt_array_literal_all_doubles);
|
||||
deopt_array_literal_all_doubles(.5);
|
||||
deopt_array_literal_all_doubles(.5);
|
||||
deopt_array_literal_all_doubles(.5);
|
||||
|
@ -20,6 +20,7 @@ function testAdd(mode) {
|
||||
|
||||
if (mode == "fast properties") %ToFastProperties(a);
|
||||
|
||||
%PrepareFunctionForOptimization(push);
|
||||
check(push);
|
||||
check(push);
|
||||
check(push);
|
||||
@ -30,6 +31,7 @@ function testAdd(mode) {
|
||||
a.unshift(3);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(unshift);
|
||||
check(unshift);
|
||||
check(unshift);
|
||||
check(unshift);
|
||||
@ -40,6 +42,7 @@ function testAdd(mode) {
|
||||
a.splice(0, 0, 3);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(splice);
|
||||
check(splice);
|
||||
check(splice);
|
||||
check(splice);
|
||||
@ -65,6 +68,7 @@ function testRemove(a, mode) {
|
||||
a.pop();
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(pop);
|
||||
check(pop);
|
||||
check(pop);
|
||||
check(pop);
|
||||
@ -75,6 +79,7 @@ function testRemove(a, mode) {
|
||||
a.shift();
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(shift);
|
||||
check(shift);
|
||||
check(shift);
|
||||
check(shift);
|
||||
@ -85,6 +90,7 @@ function testRemove(a, mode) {
|
||||
a.splice(0, 1);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(splice);
|
||||
check(splice);
|
||||
check(splice);
|
||||
check(splice);
|
||||
|
@ -305,6 +305,7 @@ function array_natives_test() {
|
||||
assertEquals([1.1,{},2,3], a4);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(array_natives_test);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
array_natives_test();
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ function f() {
|
||||
g();
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(f);
|
||||
g();
|
||||
g();
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
|
@ -8,8 +8,9 @@ var array = [];
|
||||
|
||||
function push(array, value) {
|
||||
array.push(value);
|
||||
}
|
||||
};
|
||||
|
||||
%PrepareFunctionForOptimization(push);
|
||||
push(array, 0);
|
||||
push(array, 1);
|
||||
push(array, 2);
|
||||
|
@ -13,6 +13,7 @@ function test(array) {
|
||||
return array;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(test);
|
||||
var result = test(["0",,2]);
|
||||
assertEquals(["element 1","element 1"], result);
|
||||
assertTrue(result.hasOwnProperty("0"));
|
||||
|
@ -28,6 +28,8 @@
|
||||
}
|
||||
|
||||
assertPromiseResult((async () => {
|
||||
%PrepareFunctionForOptimization(thrower);
|
||||
%PrepareFunctionForOptimization(driver);
|
||||
await test(driver);
|
||||
await test(driver);
|
||||
%OptimizeFunctionOnNextCall(thrower);
|
||||
|
@ -47,6 +47,10 @@ Object.defineProperty(O.prototype, Symbol.toStringTag, {
|
||||
var obj1 = new O;
|
||||
var obj2 = new O;
|
||||
|
||||
%PrepareFunctionForOptimization(le);
|
||||
%PrepareFunctionForOptimization(lt);
|
||||
%PrepareFunctionForOptimization(ge);
|
||||
%PrepareFunctionForOptimization(gt);
|
||||
assertTrue(%HaveSameMap(obj1, obj2));
|
||||
test(obj1, obj2);
|
||||
test(obj1, obj2);
|
||||
|
@ -13,6 +13,7 @@ function opt(b) {
|
||||
return arr.slice();
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(opt);
|
||||
opt(false);
|
||||
opt(false);
|
||||
%OptimizeFunctionOnNextCall(opt);
|
||||
|
@ -45,6 +45,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));
|
||||
|
@ -37,6 +37,7 @@ function TestLoadFromConstantFieldOfAConstantObject(the_value, other_value) {
|
||||
// {constant_object} is known to the compiler via global property cell
|
||||
// tracking.
|
||||
var load = MakeFunctionWithUniqueSFI("return constant_object.a.v;");
|
||||
%PrepareFunctionForOptimization(load);
|
||||
load();
|
||||
load();
|
||||
%OptimizeFunctionOnNextCall(load);
|
||||
@ -105,6 +106,7 @@ function TestLoadFromConstantFieldOfAPrototype(the_value, other_value) {
|
||||
// map and therefore the compiler knows the prototype object and can
|
||||
// optimize load of "v".
|
||||
var load = MakeFunctionWithUniqueSFI("o", "return o.v;");
|
||||
%PrepareFunctionForOptimization(load);
|
||||
load(new O());
|
||||
load(new O());
|
||||
%OptimizeFunctionOnNextCall(load);
|
||||
@ -168,6 +170,7 @@ function TestStoreToConstantFieldOfConstantObject(the_value, other_value) {
|
||||
// {constant_object} is known to the compiler via global property cell
|
||||
// tracking.
|
||||
var store = MakeFunctionWithUniqueSFI("v", "constant_object.a.v = v;");
|
||||
%PrepareFunctionForOptimization(store);
|
||||
store(the_value);
|
||||
store(the_value);
|
||||
%OptimizeFunctionOnNextCall(store);
|
||||
|
@ -44,6 +44,7 @@ function clear_all_ics() {
|
||||
function f() { foo(1); }
|
||||
|
||||
// Drive to monomorphic
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f(); f(); f();
|
||||
|
||||
delete foo;
|
||||
@ -63,6 +64,7 @@ function clear_all_ics() {
|
||||
|
||||
foo = function(arg) { return arg * 3; }
|
||||
function g() { this.foo(1); }
|
||||
%PrepareFunctionForOptimization(g);
|
||||
g(); g(); g();
|
||||
delete foo;
|
||||
assertThrows(function() { g(); }, TypeError);
|
||||
@ -77,7 +79,8 @@ function clear_all_ics() {
|
||||
|
||||
// Test: verify that a load with IC does the right thing.
|
||||
(function() {
|
||||
var foo = function() { return a; }
|
||||
var foo = function() { return a; };
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
a = 3;
|
||||
foo(); foo(); foo();
|
||||
delete a;
|
||||
@ -100,7 +103,8 @@ function clear_all_ics() {
|
||||
// if the variable isn't found.
|
||||
(function() {
|
||||
var foo = function() { a = 3; }
|
||||
var bar = function() { "use strict"; a = 3; }
|
||||
var bar = function() { "use strict"; a = 3; };
|
||||
%PrepareFunctionForOptimization(bar);
|
||||
foo(); foo(); foo();
|
||||
delete a;
|
||||
assertThrows(function() { bar(); }, ReferenceError);
|
||||
|
@ -17,6 +17,7 @@ function foo(i, deopt = false) {
|
||||
|
||||
assertEquals(0, %GetDeoptCount(foo));
|
||||
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
foo(10);
|
||||
foo(10);
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
|
@ -151,6 +151,7 @@ function test_wrapper() {
|
||||
}
|
||||
var smi_only = new Array(1, 2, 3);
|
||||
assertKind(elements_kind.fast_smi_only, smi_only);
|
||||
%PrepareFunctionForOptimization(monomorphic);
|
||||
for (var i = 0; i < 3; i++) monomorphic(smi_only);
|
||||
%OptimizeFunctionOnNextCall(monomorphic);
|
||||
monomorphic(smi_only);
|
||||
@ -206,7 +207,8 @@ function convert_to_double(array) {
|
||||
array[1] = 2.5;
|
||||
assertKind(elements_kind.fast_double, array);
|
||||
assertEquals(2.5, array[1]);
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(convert_to_double);
|
||||
var smis = construct_smis();
|
||||
for (var i = 0; i < 3; i++) convert_to_double(smis);
|
||||
%OptimizeFunctionOnNextCall(convert_to_double);
|
||||
@ -218,7 +220,8 @@ function convert_to_fast(array) {
|
||||
array[1] = "two";
|
||||
assertKind(elements_kind.fast, array);
|
||||
assertEquals("two", array[1]);
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(convert_to_fast);
|
||||
smis = construct_smis();
|
||||
for (var i = 0; i < 3; i++) convert_to_fast(smis);
|
||||
var doubles = construct_doubles();
|
||||
|
@ -32,6 +32,7 @@ function f1(a, i) {
|
||||
}
|
||||
|
||||
var a1 = [,,,,,,,,,,,,,,,,,,0.5];
|
||||
%PrepareFunctionForOptimization(f1);
|
||||
assertEquals(undefined, f1(a1, 1));
|
||||
assertEquals(undefined, f1(a1, 1));
|
||||
%OptimizeFunctionOnNextCall(f1);
|
||||
@ -42,6 +43,7 @@ function f2(a, i) {
|
||||
return a[i] + 0.5;
|
||||
}
|
||||
var a2_b = [0.0,,];
|
||||
%PrepareFunctionForOptimization(f2);
|
||||
assertEquals(0.5, f2(a2_b, 0));
|
||||
assertEquals(0.5, f2(a2_b, 0));
|
||||
%OptimizeFunctionOnNextCall(f2);
|
||||
|
@ -8,6 +8,7 @@ function f1(a, i) {
|
||||
return a[i] + 0.5;
|
||||
}
|
||||
var arr = [,0.0,2.5];
|
||||
%PrepareFunctionForOptimization(f1);
|
||||
assertEquals(0.5, f1(arr, 1));
|
||||
assertEquals(0.5, f1(arr, 1));
|
||||
%OptimizeFunctionOnNextCall(f1);
|
||||
@ -28,6 +29,7 @@ function foo() {
|
||||
optopush(array_prototype);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
optopush([]);
|
||||
optopush([]);
|
||||
optopush([]);
|
||||
|
@ -10,6 +10,7 @@ function f1(a, i) {
|
||||
|
||||
var other_realm = Realm.create();
|
||||
var arr = [,0.0,2.5];
|
||||
%PrepareFunctionForOptimization(f1);
|
||||
assertEquals(0.5, f1(arr, 1));
|
||||
assertEquals(0.5, f1(arr, 1));
|
||||
%OptimizeFunctionOnNextCall(f1);
|
||||
|
@ -29,7 +29,8 @@
|
||||
|
||||
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));
|
||||
|
@ -31,6 +31,7 @@ function f1(a, i) {
|
||||
return a[i] + 0.5;
|
||||
}
|
||||
var arr = [0.0,,2.5];
|
||||
%PrepareFunctionForOptimization(f1);
|
||||
assertEquals(0.5, f1(arr, 0));
|
||||
assertEquals(0.5, f1(arr, 0));
|
||||
%OptimizeFunctionOnNextCall(f1);
|
||||
|
@ -31,6 +31,7 @@ function f1(a, i) {
|
||||
return a[i] + 0.5;
|
||||
}
|
||||
var arr = [0.0,,2.5];
|
||||
%PrepareFunctionForOptimization(f1);
|
||||
assertEquals(0.5, f1(arr, 0));
|
||||
assertEquals(0.5, f1(arr, 0));
|
||||
%OptimizeFunctionOnNextCall(f1);
|
||||
|
@ -18,6 +18,7 @@
|
||||
a[i] = 5.3;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
foo(a, 1);
|
||||
foo(a, 2);
|
||||
foo(a, 3);
|
||||
@ -36,6 +37,7 @@
|
||||
b[10000] = 5;
|
||||
assertTrue(%HasDictionaryElements(b));
|
||||
foo(b, 3);
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
foo(b, 50000);
|
||||
assertOptimized(foo);
|
||||
@ -55,6 +57,7 @@
|
||||
}
|
||||
|
||||
// The KeyedStoreIC will learn GROW_MODE.
|
||||
%PrepareFunctionForOptimization(foo2);
|
||||
foo2(a, 10);
|
||||
foo2(a, 12);
|
||||
foo2(a, 31);
|
||||
|
@ -10,6 +10,7 @@ var then = p.then = () => {};
|
||||
|
||||
function spread() { return { ...p }; }
|
||||
|
||||
%PrepareFunctionForOptimization(spread);
|
||||
assertEquals({ then }, spread());
|
||||
assertEquals({ then }, spread());
|
||||
assertEquals({ then }, spread());
|
||||
|
@ -10,8 +10,9 @@ function test() {
|
||||
try {
|
||||
assertEquals({}, spread());
|
||||
} catch (e) {}
|
||||
}
|
||||
};
|
||||
|
||||
%PrepareFunctionForOptimization(test);
|
||||
test();
|
||||
test();
|
||||
test();
|
||||
|
@ -77,6 +77,7 @@ function create(a) {
|
||||
function runTest(test, kind, holey_predicate) {
|
||||
|
||||
// Verify built-in implementation produces correct results.
|
||||
%PrepareFunctionForOptimization(test);
|
||||
let a = test();
|
||||
assertKind(kind, a);
|
||||
holey_predicate(a);
|
||||
|
@ -17,6 +17,7 @@ function test() {
|
||||
// Test PACKED SMI -> PACKED DOUBLE
|
||||
//
|
||||
|
||||
%PrepareFunctionForOptimization(transition1);
|
||||
const a1 = [0, 1, 2, 3, 4];
|
||||
transition1(a1, 0, 2.5);
|
||||
const a2 = [0, 1, 2, 3, 4];
|
||||
@ -59,6 +60,7 @@ function test() {
|
||||
a[i] = v;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(transition2);
|
||||
const b1 = [0, 1, 2, , 4];
|
||||
transition2(b1, 0, 2.5);
|
||||
const b2 = [0, 1, 2, , 4];
|
||||
@ -93,6 +95,7 @@ function test() {
|
||||
a[i] = v;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(transition3);
|
||||
const c1 = [0, 1, 2, 3.5, 4];
|
||||
transition3(c1, 0, new Object());
|
||||
const c2 = [0, 1, 2, 3.5, 4];
|
||||
@ -147,6 +150,7 @@ function test() {
|
||||
a[i] = v;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(transition4);
|
||||
const d1 = [0, 1, , 3.5, 4];
|
||||
transition4(d1, 0, new Object());
|
||||
const d2 = [0, 1, , 3.5, 4];
|
||||
|
@ -6,6 +6,7 @@
|
||||
"use strict";
|
||||
|
||||
function test(expected, f) {
|
||||
%PrepareFunctionForOptimization(f);
|
||||
assertEquals(expected, f());
|
||||
assertEquals(expected, f());
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
@ -14,6 +15,7 @@ function test(expected, f) {
|
||||
}
|
||||
|
||||
function testThrows(f) {
|
||||
%PrepareFunctionForOptimization(f);
|
||||
assertThrows(f);
|
||||
assertThrows(f);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
|
@ -6,6 +6,7 @@
|
||||
"use strict";
|
||||
|
||||
function test(expected, f) {
|
||||
%PrepareFunctionForOptimization(f);
|
||||
assertEquals(expected, f());
|
||||
assertEquals(expected, f());
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
@ -14,6 +15,7 @@ function test(expected, f) {
|
||||
}
|
||||
|
||||
function testThrows(f) {
|
||||
%PrepareFunctionForOptimization(f);
|
||||
assertThrows(f);
|
||||
assertThrows(f);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
|
@ -5,6 +5,7 @@
|
||||
// Flags: --allow-natives-syntax
|
||||
|
||||
function test(expected, f) {
|
||||
%PrepareFunctionForOptimization(f);
|
||||
assertEquals(expected, f());
|
||||
assertEquals(expected, f());
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
|
@ -9,6 +9,7 @@ function f(x, b) {
|
||||
else return Math.trunc(Number(x))
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f("1", true);
|
||||
f("2", true);
|
||||
f("2", false);
|
||||
|
@ -19,6 +19,7 @@ function test(f, {input, check}) {
|
||||
|
||||
function Test(f, ...cases) {
|
||||
for (let i = 0; i < cases.length; ++i) {
|
||||
%PrepareFunctionForOptimization(f);
|
||||
test(f, cases[i]);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
for (let j = 0; j < cases.length; ++j) {
|
||||
|
@ -8,6 +8,7 @@ var intarray = new BigInt64Array(8);
|
||||
var uintarray = new BigUint64Array(8);
|
||||
|
||||
function test(f) {
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f();
|
||||
f(); // Make sure we test ICs.
|
||||
f();
|
||||
|
@ -43,6 +43,7 @@ function f() {
|
||||
}
|
||||
|
||||
var o = f();
|
||||
%PrepareFunctionForOptimization(o);
|
||||
assertEquals(1, o());
|
||||
assertEquals(2, o());
|
||||
assertEquals(3, o());
|
||||
|
@ -8,6 +8,7 @@
|
||||
function* h() { try {yield 42} finally {yield 43} };
|
||||
function* g() { yield* h(); };
|
||||
|
||||
%PrepareFunctionForOptimization(g);
|
||||
let x = g();
|
||||
x.next();
|
||||
%OptimizeFunctionOnNextCall(g);
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
|
||||
function MaybeOptimizeOrDeoptimize(f) {
|
||||
%PrepareFunctionForOptimization(f);
|
||||
let x = Math.random(); // --random-seed makes this deterministic
|
||||
if (x <= 0.33) {
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
|
@ -12,6 +12,7 @@ function get() {
|
||||
return m.stringlife;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(get);
|
||||
assertEquals("42", get());
|
||||
assertEquals("42", get());
|
||||
assertEquals("42", get());
|
||||
|
@ -12,6 +12,7 @@ function* foo() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
g = foo();
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
g.next();
|
||||
|
@ -5,6 +5,7 @@
|
||||
// Flags: --allow-natives-syntax
|
||||
|
||||
async function* gen([[notIterable]] = [null]) {}
|
||||
%PrepareFunctionForOptimization(gen);
|
||||
assertThrows(() => gen(), TypeError);
|
||||
assertThrows(() => gen(), TypeError);
|
||||
%OptimizeFunctionOnNextCall(gen);
|
||||
|
@ -30,6 +30,7 @@
|
||||
"use strict";
|
||||
let unused_var = 1;
|
||||
function __f_12() { new Array(); }
|
||||
%PrepareFunctionForOptimization(__f_12);
|
||||
__f_12();
|
||||
__f_12();
|
||||
%OptimizeFunctionOnNextCall(__f_12);
|
||||
|
@ -16,6 +16,7 @@ function f() {
|
||||
g = function() {
|
||||
return y;
|
||||
};
|
||||
%PrepareFunctionForOptimization(h);
|
||||
assertEquals(5, h(g));
|
||||
assertEquals(5, h(g));
|
||||
%OptimizeFunctionOnNextCall(h);
|
||||
|
@ -100,6 +100,7 @@
|
||||
o.x = 0.1;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(g);
|
||||
g(c1);
|
||||
g(c2);
|
||||
g(c3);
|
||||
|
@ -27,6 +27,7 @@ function TestLargeObjectElements() {
|
||||
%HeapObjectVerify(object);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(TestLargeObjectElements);
|
||||
TestLargeObjectElements();
|
||||
TestLargeObjectElements();
|
||||
%OptimizeFunctionOnNextCall(TestLargeObjectElements);
|
||||
|
@ -59,24 +59,28 @@ function d() {
|
||||
return sum;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(a);
|
||||
a();
|
||||
a();
|
||||
%OptimizeFunctionOnNextCall(a);
|
||||
assertEquals(124750, a());
|
||||
assertEquals(124750, a());
|
||||
|
||||
%PrepareFunctionForOptimization(b);
|
||||
b();
|
||||
b();
|
||||
%OptimizeFunctionOnNextCall(b);
|
||||
assertEquals(-125250, b());
|
||||
assertEquals(-125250, b());
|
||||
|
||||
%PrepareFunctionForOptimization(c);
|
||||
c();
|
||||
c();
|
||||
%OptimizeFunctionOnNextCall(c);
|
||||
assertEquals(-1073741698750, c());
|
||||
assertEquals(-1073741698750, c());
|
||||
|
||||
%PrepareFunctionForOptimization(d);
|
||||
d();
|
||||
d();
|
||||
%OptimizeFunctionOnNextCall(d);
|
||||
|
@ -38,6 +38,7 @@ function foo(a, b) {
|
||||
return result / b;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
foo(700, 5);
|
||||
var r1 = foo(700, 5);
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
@ -50,6 +51,7 @@ function boo(value) {
|
||||
}
|
||||
|
||||
// Test deoptimization of MinInt / -1.
|
||||
%PrepareFunctionForOptimization(boo);
|
||||
assertEquals(2147483600, boo(-2147483600));
|
||||
assertEquals(2147483600, boo(-2147483600));
|
||||
%OptimizeFunctionOnNextCall(boo);
|
||||
|
@ -31,6 +31,7 @@ function foo(x) {
|
||||
return Math.exp(x);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
foo(12.3);
|
||||
var r1 = foo(12.3);
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
|
@ -45,6 +45,7 @@ function foo_int(a, b) {
|
||||
return result * a;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(foo_smi);
|
||||
foo_smi(10, 5);
|
||||
var r1 = foo_smi(10, 5);
|
||||
%OptimizeFunctionOnNextCall(foo_smi);
|
||||
@ -52,6 +53,7 @@ var r2 = foo_smi(10, 5);
|
||||
|
||||
assertEquals(r1, r2);
|
||||
|
||||
%PrepareFunctionForOptimization(foo_int);
|
||||
foo_int(10, 21474800);
|
||||
var r3 = foo_int(10, 21474800);
|
||||
%OptimizeFunctionOnNextCall(foo_int);
|
||||
@ -64,6 +66,7 @@ function foo2(value) {
|
||||
return value * -1;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(foo2);
|
||||
foo2(-2147483600);
|
||||
foo2(-2147483600);
|
||||
%OptimizeFunctionOnNextCall(foo2);
|
||||
|
@ -45,11 +45,13 @@ var A1_int = [12, 23];
|
||||
var A2_int = [12, 23];
|
||||
var A3_int = [12, 23];
|
||||
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
foo(A1, 1, 3.4);
|
||||
foo(A2, 1, 3.4);
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
foo(A3, 1, 3.4);
|
||||
|
||||
%PrepareFunctionForOptimization(foo_int);
|
||||
foo_int(A1_int, 1, 34);
|
||||
foo_int(A2_int, 1, 34);
|
||||
%OptimizeFunctionOnNextCall(foo_int);
|
||||
|
@ -72,26 +72,31 @@ var A1_double = new Float64Array(2);
|
||||
var A2_double = new Float64Array(2);
|
||||
var A3_double = new Float64Array(2);
|
||||
|
||||
%PrepareFunctionForOptimization(foo_pixel);
|
||||
foo_pixel(A1_pixel, 1, 34);
|
||||
foo_pixel(A2_pixel, 1, 34);
|
||||
%OptimizeFunctionOnNextCall(foo_pixel);
|
||||
foo_pixel(A3_pixel, 1, 34);
|
||||
|
||||
%PrepareFunctionForOptimization(foo_uint16);
|
||||
foo_uint16(A1_uint16, 1, 3.4);
|
||||
foo_uint16(A2_uint16, 1, 3.4);
|
||||
%OptimizeFunctionOnNextCall(foo_uint16);
|
||||
foo_uint16(A3_uint16, 1, 3.4);
|
||||
|
||||
%PrepareFunctionForOptimization(foo_uint32);
|
||||
foo_uint32(A1_uint32, 1, 3.4);
|
||||
foo_uint32(A2_uint32, 1, 3.4);
|
||||
%OptimizeFunctionOnNextCall(foo_uint32);
|
||||
foo_uint32(A3_uint32, 1, 3.4);
|
||||
|
||||
%PrepareFunctionForOptimization(foo_float);
|
||||
foo_float(A1_float, 1, 3.4);
|
||||
foo_float(A2_float, 1, 3.4);
|
||||
%OptimizeFunctionOnNextCall(foo_float);
|
||||
foo_float(A3_float, 1, 3.4);
|
||||
|
||||
%PrepareFunctionForOptimization(foo_double);
|
||||
foo_double(A1_double, 1, 3.4);
|
||||
foo_double(A2_double, 1, 3.4);
|
||||
%OptimizeFunctionOnNextCall(foo_double);
|
||||
|
@ -39,6 +39,7 @@ var deopt = false;
|
||||
var o2 = {x_tagged:{}};
|
||||
o2.x_tagged = 1;
|
||||
|
||||
%PrepareFunctionForOptimization(load);
|
||||
load({x:1}, o2);
|
||||
load({x:1}, o2);
|
||||
print(load(o, o2));
|
||||
|
@ -106,6 +106,7 @@ function foo(x) {
|
||||
for(var i = 0; i < 1000; i++) {
|
||||
foo(-i);
|
||||
}
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
assertEquals(42, foo(-42));
|
||||
%OptimizeFunctionOnNextCall(foo)
|
||||
assertEquals(42, foo(-42));
|
||||
@ -115,7 +116,8 @@ assertEquals(42, foo(-42));
|
||||
var a = [-1, -2];
|
||||
function foo2() {
|
||||
return Math.abs(a[0]);
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(foo2);
|
||||
assertEquals(1, foo2());
|
||||
assertEquals(1, foo2());
|
||||
%OptimizeFunctionOnNextCall(foo2);
|
||||
@ -132,6 +134,7 @@ function absHalf(bits) {
|
||||
// Create minimum integer input for abs() using bitwise operations
|
||||
// that should overflow.
|
||||
bits = 32;
|
||||
%PrepareFunctionForOptimization(absHalf);
|
||||
assertEquals(2147483648, absHalf(bits));
|
||||
assertEquals(2147483648, absHalf(bits));
|
||||
%OptimizeFunctionOnNextCall(absHalf);
|
||||
|
@ -18,6 +18,7 @@ function testCeil(expect, input) {
|
||||
var test_double_input = new Function(
|
||||
'n',
|
||||
'"' + (test_id++) + '";return Math.ceil(+n)');
|
||||
%PrepareFunctionForOptimization(test_double_input);
|
||||
assertEquals(expect, test_double_input(input));
|
||||
assertEquals(expect, test_double_input(input));
|
||||
assertEquals(expect, test_double_input(input));
|
||||
@ -27,6 +28,7 @@ function testCeil(expect, input) {
|
||||
var test_double_output = new Function(
|
||||
'n',
|
||||
'"' + (test_id++) + '";return Math.ceil(n) + -0.0');
|
||||
%PrepareFunctionForOptimization(test_double_output);
|
||||
assertEquals(expect, test_double_output(input));
|
||||
assertEquals(expect, test_double_output(input));
|
||||
assertEquals(expect, test_double_output(input));
|
||||
@ -36,6 +38,7 @@ function testCeil(expect, input) {
|
||||
var test_via_floor = new Function(
|
||||
'n',
|
||||
'"' + (test_id++) + '";return -Math.floor(-n)');
|
||||
%PrepareFunctionForOptimization(test_via_floor);
|
||||
assertEquals(expect, test_via_floor(input));
|
||||
assertEquals(expect, test_via_floor(input));
|
||||
assertEquals(expect, test_via_floor(input));
|
||||
@ -46,6 +49,7 @@ function testCeil(expect, input) {
|
||||
var test_via_trunc = new Function(
|
||||
'n',
|
||||
'"' + (test_id++) + '";return Math.trunc(n)');
|
||||
%PrepareFunctionForOptimization(test_via_trunc);
|
||||
assertEquals(expect, test_via_trunc(input));
|
||||
assertEquals(expect, test_via_trunc(input));
|
||||
assertEquals(expect, test_via_trunc(input));
|
||||
|
@ -8,10 +8,12 @@
|
||||
function f(a) {
|
||||
return Math.abs(a);
|
||||
}
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f(1);
|
||||
f(1);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("100");
|
||||
%PrepareFunctionForOptimization(f);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("100");
|
||||
assertOptimized(f);
|
||||
@ -21,10 +23,12 @@
|
||||
function f(a) {
|
||||
return Math.min(1,a);
|
||||
}
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f(1);
|
||||
f(1);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("100");
|
||||
%PrepareFunctionForOptimization(f);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("100");
|
||||
assertOptimized(f);
|
||||
@ -34,10 +38,12 @@
|
||||
function f(a) {
|
||||
return Math.pow(a,10);
|
||||
}
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f(1);
|
||||
f(1);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("100");
|
||||
%PrepareFunctionForOptimization(f);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("100");
|
||||
assertOptimized(f);
|
||||
@ -47,10 +53,12 @@
|
||||
function f(a) {
|
||||
return Math.clz32(a);
|
||||
}
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f(1);
|
||||
f(1);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("100");
|
||||
%PrepareFunctionForOptimization(f);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("100");
|
||||
assertOptimized(f);
|
||||
@ -60,10 +68,12 @@
|
||||
function f(a) {
|
||||
return Math.imul(a, 10);
|
||||
}
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f(1);
|
||||
f(1);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("100");
|
||||
%PrepareFunctionForOptimization(f);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("100");
|
||||
assertOptimized(f);
|
||||
|
@ -32,6 +32,7 @@ var test_id = 0;
|
||||
function testFloor(expect, input) {
|
||||
var test = new Function('n',
|
||||
'"' + (test_id++) + '";return Math.floor(n)');
|
||||
%PrepareFunctionForOptimization(test);
|
||||
assertEquals(expect, test(input));
|
||||
assertEquals(expect, test(input));
|
||||
assertEquals(expect, test(input));
|
||||
@ -41,6 +42,7 @@ function testFloor(expect, input) {
|
||||
var test_double_input = new Function(
|
||||
'n',
|
||||
'"' + (test_id++) + '";return Math.floor(+n)');
|
||||
%PrepareFunctionForOptimization(test_double_input);
|
||||
assertEquals(expect, test_double_input(input));
|
||||
assertEquals(expect, test_double_input(input));
|
||||
assertEquals(expect, test_double_input(input));
|
||||
@ -50,6 +52,7 @@ function testFloor(expect, input) {
|
||||
var test_double_output = new Function(
|
||||
'n',
|
||||
'"' + (test_id++) + '";return Math.floor(n) + -0.0');
|
||||
%PrepareFunctionForOptimization(test_double_output);
|
||||
assertEquals(expect, test_double_output(input));
|
||||
assertEquals(expect, test_double_output(input));
|
||||
assertEquals(expect, test_double_output(input));
|
||||
@ -59,6 +62,7 @@ function testFloor(expect, input) {
|
||||
var test_via_ceil = new Function(
|
||||
'n',
|
||||
'"' + (test_id++) + '";return -Math.ceil(-n)');
|
||||
%PrepareFunctionForOptimization(test_via_ceil);
|
||||
assertEquals(expect, test_via_ceil(input));
|
||||
assertEquals(expect, test_via_ceil(input));
|
||||
assertEquals(expect, test_via_ceil(input));
|
||||
@ -69,6 +73,7 @@ function testFloor(expect, input) {
|
||||
var test_via_trunc = new Function(
|
||||
'n',
|
||||
'"' + (test_id++) + '";return Math.trunc(n)');
|
||||
%PrepareFunctionForOptimization(test_via_trunc);
|
||||
assertEquals(expect, test_via_trunc(input));
|
||||
assertEquals(expect, test_via_trunc(input));
|
||||
assertEquals(expect, test_via_trunc(input));
|
||||
@ -88,6 +93,7 @@ function test() {
|
||||
function ifloor(x) {
|
||||
return 1 / Math.floor(x);
|
||||
}
|
||||
%PrepareFunctionForOptimization(ifloor);
|
||||
assertEquals(-Infinity, ifloor(-0));
|
||||
assertEquals(-Infinity, ifloor(-0));
|
||||
assertEquals(-Infinity, ifloor(-0));
|
||||
|
@ -32,6 +32,7 @@ var test_id = 0;
|
||||
function testFloor(expect, input) {
|
||||
var test = new Function('n',
|
||||
'"' + (test_id++) + '";return Math.floor(n)');
|
||||
%PrepareFunctionForOptimization(test);
|
||||
assertEquals(expect, test(input));
|
||||
assertEquals(expect, test(input));
|
||||
assertEquals(expect, test(input));
|
||||
@ -41,6 +42,7 @@ function testFloor(expect, input) {
|
||||
var test_double_input = new Function(
|
||||
'n',
|
||||
'"' + (test_id++) + '";return Math.floor(+n)');
|
||||
%PrepareFunctionForOptimization(test_double_input);
|
||||
assertEquals(expect, test_double_input(input));
|
||||
assertEquals(expect, test_double_input(input));
|
||||
assertEquals(expect, test_double_input(input));
|
||||
@ -50,6 +52,7 @@ function testFloor(expect, input) {
|
||||
var test_double_output = new Function(
|
||||
'n',
|
||||
'"' + (test_id++) + '";return Math.floor(n) + -0.0');
|
||||
%PrepareFunctionForOptimization(test_double_output);
|
||||
assertEquals(expect, test_double_output(input));
|
||||
assertEquals(expect, test_double_output(input));
|
||||
assertEquals(expect, test_double_output(input));
|
||||
@ -59,6 +62,7 @@ function testFloor(expect, input) {
|
||||
var test_via_ceil = new Function(
|
||||
'n',
|
||||
'"' + (test_id++) + '";return -Math.ceil(-n)');
|
||||
%PrepareFunctionForOptimization(test_via_ceil);
|
||||
assertEquals(expect, test_via_ceil(input));
|
||||
assertEquals(expect, test_via_ceil(input));
|
||||
assertEquals(expect, test_via_ceil(input));
|
||||
@ -69,6 +73,7 @@ function testFloor(expect, input) {
|
||||
var test_via_trunc = new Function(
|
||||
'n',
|
||||
'"' + (test_id++) + '";return Math.trunc(n)');
|
||||
%PrepareFunctionForOptimization(test_via_trunc);
|
||||
assertEquals(expect, test_via_trunc(input));
|
||||
assertEquals(expect, test_via_trunc(input));
|
||||
assertEquals(expect, test_via_trunc(input));
|
||||
@ -106,7 +111,8 @@ function floorsum(i, n) {
|
||||
ret += Math.floor(n);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(floorsum);
|
||||
assertEquals(-0, floorsum(1, -0));
|
||||
%OptimizeFunctionOnNextCall(floorsum);
|
||||
// The optimized function will deopt. Run it with enough iterations to try
|
||||
|
@ -167,6 +167,7 @@ function test() {
|
||||
(-1*(Math.pow(2,52))*(Math.pow(2,-1074))) === -2.2250738585072014e-308);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(test);
|
||||
test();
|
||||
test();
|
||||
%OptimizeFunctionOnNextCall(test);
|
||||
|
@ -33,6 +33,7 @@ function testRound(expect, input) {
|
||||
// sure it gets optimized each time.
|
||||
var doRound = new Function('input',
|
||||
'"' + (test_id++) + '";return Math.round(input)');
|
||||
%PrepareFunctionForOptimization(doRound);
|
||||
assertEquals(expect, doRound(input));
|
||||
assertEquals(expect, doRound(input));
|
||||
assertEquals(expect, doRound(input));
|
||||
@ -43,6 +44,7 @@ function testRound(expect, input) {
|
||||
// optimized code.
|
||||
var doRoundToDouble = new Function('input',
|
||||
'"' + (test_id++) + '";return Math.round(input) + -0.0');
|
||||
%PrepareFunctionForOptimization(doRoundToDouble);
|
||||
assertEquals(expect, doRoundToDouble(input));
|
||||
assertEquals(expect, doRoundToDouble(input));
|
||||
assertEquals(expect, doRoundToDouble(input));
|
||||
@ -64,7 +66,8 @@ function roundsum(i, n) {
|
||||
ret += Math.round(n);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(roundsum);
|
||||
assertEquals(-0, roundsum(1, -0));
|
||||
%OptimizeFunctionOnNextCall(roundsum);
|
||||
// The optimized function will deopt. Run it with enough iterations to try
|
||||
|
@ -11,6 +11,7 @@ function foo() { return x++ };
|
||||
|
||||
function gaga(f) { return f() };
|
||||
|
||||
%PrepareFunctionForOptimization(gaga);
|
||||
assertEquals(0, gaga(foo));
|
||||
assertEquals(1, gaga(foo));
|
||||
%OptimizeFunctionOnNextCall(gaga);
|
||||
|
@ -7,6 +7,7 @@
|
||||
(function() {
|
||||
function foo(x) { return Number.isNaN(x); }
|
||||
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
assertTrue(foo(+undefined));
|
||||
assertFalse(foo(undefined));
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
@ -17,6 +18,7 @@
|
||||
(function() {
|
||||
function foo(x) { return Number.isNaN(+x); }
|
||||
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
assertTrue(foo(+undefined));
|
||||
assertFalse(foo(0));
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
@ -27,6 +29,7 @@
|
||||
(function() {
|
||||
function foo(x) { return Number.isNaN(x|0); }
|
||||
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
assertFalse(foo(+undefined));
|
||||
assertFalse(foo(0));
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
@ -37,6 +40,7 @@
|
||||
(function() {
|
||||
function foo(x) { return Number.isNaN("" + x); }
|
||||
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
assertFalse(foo(undefined));
|
||||
assertFalse(foo(0));
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
@ -47,6 +51,7 @@
|
||||
(function() {
|
||||
function foo(x) { return Number.isNaN(0/0); }
|
||||
|
||||
%PrepareFunctionForOptimization(foo);
|
||||
assertTrue(foo());
|
||||
assertTrue(foo());
|
||||
%OptimizeFunctionOnNextCall(foo);
|
||||
|
@ -21,7 +21,8 @@
|
||||
result += v;
|
||||
};
|
||||
b.forEach(sum);
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f();
|
||||
f();
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
|
@ -14,7 +14,8 @@
|
||||
result += i;
|
||||
};
|
||||
b.forEach(sum);
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f();
|
||||
f();
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
|
@ -107,6 +107,7 @@ function runTests(tests, func) {
|
||||
for (test in tests) {
|
||||
%DeoptimizeFunction(func);
|
||||
%ClearFunctionFeedback(func);
|
||||
%PrepareFunctionForOptimization(func);
|
||||
tests[test]();
|
||||
%OptimizeFunctionOnNextCall(func);
|
||||
tests[test]();
|
||||
|
2
test/mjsunit/prototype-non-existing.js
vendored
2
test/mjsunit/prototype-non-existing.js
vendored
@ -34,6 +34,7 @@
|
||||
var result = c.z;
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f("a");
|
||||
f("a");
|
||||
f("a");
|
||||
@ -74,6 +75,7 @@
|
||||
var result = c.z;
|
||||
assertEquals(expected, result);
|
||||
}
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f("a");
|
||||
f("a");
|
||||
f("a");
|
||||
|
@ -9,6 +9,7 @@ C.__proto__ = null;
|
||||
|
||||
function f(c) { return 0 instanceof c; }
|
||||
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f(C);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
assertThrows(() => f(0));
|
||||
|
@ -32,6 +32,7 @@ function mul(a, b) {
|
||||
}
|
||||
|
||||
|
||||
%PrepareFunctionForOptimization(mul);
|
||||
mul(-1, 2);
|
||||
mul(-1, 2);
|
||||
%OptimizeFunctionOnNextCall(mul);
|
||||
@ -47,6 +48,7 @@ function mul2(a, b) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(mul2);
|
||||
mul2(-1, 2);
|
||||
mul2(-1, 2);
|
||||
%OptimizeFunctionOnNextCall(mul2);
|
||||
|
@ -7,11 +7,13 @@
|
||||
(()=> {
|
||||
function f(a, b, c) {
|
||||
return a.indexOf(b, c);
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f("abc", "de", 1);
|
||||
f("abc", "de", 1);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("abc", "de", {});
|
||||
%PrepareFunctionForOptimization(f);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("abc", "de", {});
|
||||
assertOptimized(f);
|
||||
@ -20,11 +22,13 @@
|
||||
(()=> {
|
||||
function f(a, b, c) {
|
||||
return a.indexOf(b, c);
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f("abc", "de", 1);
|
||||
f("abc", "de", 1);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("abc", {}, 1);
|
||||
%PrepareFunctionForOptimization(f);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("abc", {}, 1);
|
||||
assertOptimized(f);
|
||||
@ -33,11 +37,13 @@
|
||||
(()=> {
|
||||
function f(a, b, c) {
|
||||
return a.substring(b, c);
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f("abcde", 1, 4);
|
||||
f("abcde", 1, 4);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("abcde", 1, {});
|
||||
%PrepareFunctionForOptimization(f);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("abcde", 1, {});
|
||||
assertOptimized(f);
|
||||
@ -46,11 +52,13 @@
|
||||
(()=> {
|
||||
function f(a, b, c) {
|
||||
return a.substring(b, c);
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(f);
|
||||
f("abcde", 1, 4);
|
||||
f("abcde", 1, 4);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("abcde", {}, 4);
|
||||
%PrepareFunctionForOptimization(f);
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f("abcde", {}, 4);
|
||||
assertOptimized(f);
|
||||
|
@ -350,6 +350,7 @@ function switch_gen(clause_type, feedback, optimize) {
|
||||
var values = clause_values[clause_type];
|
||||
|
||||
function opt(fn) {
|
||||
if (optimize) %PrepareFunctionForOptimization(fn);
|
||||
if (feedback === 'all') {
|
||||
values.forEach(fn);
|
||||
} else if (Array.isArray(feedback)) {
|
||||
|
@ -114,6 +114,7 @@ of1.field = {};
|
||||
var of2 = {b:0};
|
||||
of2.field = 10;
|
||||
|
||||
%PrepareFunctionForOptimization(poly_load);
|
||||
poly_load(of1, false);
|
||||
poly_load(of1, false);
|
||||
poly_load(of2, true);
|
||||
@ -132,6 +133,7 @@ function load_poly(o) {
|
||||
return o.a;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(load_poly);
|
||||
var o10 = { "a": 1.6 };
|
||||
var o11 = { "b": 1, "a": 1.7 };
|
||||
load_poly(o10);
|
||||
@ -150,6 +152,7 @@ function load_mono(o) {
|
||||
return o.a1;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(load_mono);
|
||||
var object = {"x": 1};
|
||||
var o10 = { "a1": 1.6 };
|
||||
var o11 = { "a1": object, "b": 1 };
|
||||
@ -164,6 +167,7 @@ function load_mono2(o) {
|
||||
return o.a2;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(load_mono2);
|
||||
var o12 = { "a2": 5 };
|
||||
var o13 = { "a2": object, "b": 1 };
|
||||
load_mono2(o12);
|
||||
@ -177,6 +181,7 @@ function load_mono3(o) {
|
||||
return o.a3;
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(load_mono3);
|
||||
var o14 = { "a3": 1.6 };
|
||||
var o15 = { "a3": 1.8, "b": 1 };
|
||||
load_mono3(o14);
|
||||
@ -331,7 +336,8 @@ read_first_double(df1);
|
||||
// Test boilerplates with computed values.
|
||||
function none_boilerplate(a) {
|
||||
return {"a_none":a};
|
||||
}
|
||||
};
|
||||
%PrepareFunctionForOptimization(none_boilerplate);
|
||||
%OptimizeFunctionOnNextCall(none_boilerplate);
|
||||
var none_double1 = none_boilerplate(1.7);
|
||||
var none_double2 = none_boilerplate(1.9);
|
||||
@ -346,6 +352,7 @@ function none_to_smi(a) {
|
||||
return {"a_smi":a};
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(none_to_smi);
|
||||
var none_smi1 = none_to_smi(1);
|
||||
var none_smi2 = none_to_smi(2);
|
||||
%OptimizeFunctionOnNextCall(none_to_smi);
|
||||
@ -360,6 +367,7 @@ function none_to_double(a) {
|
||||
return {"a_double":a};
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(none_to_double);
|
||||
var none_to_double1 = none_to_double(1.5);
|
||||
var none_to_double2 = none_to_double(2.8);
|
||||
%OptimizeFunctionOnNextCall(none_to_double);
|
||||
@ -374,6 +382,7 @@ function none_to_object(a) {
|
||||
return {"an_object":a};
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(none_to_object);
|
||||
var none_to_object1 = none_to_object(true);
|
||||
var none_to_object2 = none_to_object(false);
|
||||
%OptimizeFunctionOnNextCall(none_to_object);
|
||||
|
@ -149,6 +149,13 @@ function testOneArrayType(allocator) {
|
||||
assertTrue(%HasDoubleElements(a));
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(test_various_loads);
|
||||
%PrepareFunctionForOptimization(test_various_loads2);
|
||||
%PrepareFunctionForOptimization(test_various_loads3);
|
||||
%PrepareFunctionForOptimization(test_various_loads6);
|
||||
%PrepareFunctionForOptimization(test_various_loads7);
|
||||
%PrepareFunctionForOptimization(test_various_stores);
|
||||
|
||||
// Test double and integer values
|
||||
test_various_loads(large_array,
|
||||
expected_array_value(5),
|
||||
@ -463,6 +470,7 @@ function call_apply() {
|
||||
called_by_apply.apply({}, large_array3);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(call_apply);
|
||||
call_apply();
|
||||
call_apply();
|
||||
call_apply();
|
||||
@ -483,6 +491,7 @@ function test_for_in() {
|
||||
assertTrue(next_expected == 96);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(test_for_in);
|
||||
test_for_in();
|
||||
test_for_in();
|
||||
test_for_in();
|
||||
@ -503,6 +512,7 @@ function test_getter() {
|
||||
assertEquals(expected_array_value(10), large_array3[2]);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(test_getter);
|
||||
test_getter();
|
||||
test_getter();
|
||||
test_getter();
|
||||
@ -531,6 +541,7 @@ function test_setter() {
|
||||
assertEquals(expected_array_value(2), large_array4[2]);
|
||||
}
|
||||
|
||||
%PrepareFunctionForOptimization(test_setter);
|
||||
test_setter();
|
||||
test_setter();
|
||||
test_setter();
|
||||
|
Loading…
Reference in New Issue
Block a user