Commit 61ce45c9 authored by Mathias Bynens's avatar Mathias Bynens Committed by Commit Bot

[test] Add %PrepareForOptimization to more tests

With bytecode flushing and lazy feedback allocation, we need to call
%PrepareForOptimization before we call %OptimizeFunctionOnNextCall,
ideally after declaring the function.

Bug: v8:8801, v8:8394, v8:9183
Change-Id: I6bf119e726426df8527d97546b6ce806112c894d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1643167
Auto-Submit: Mathias Bynens <mathias@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61988}
parent 003473e6
......@@ -38,6 +38,7 @@ function f() {
return elem2;
}
%PrepareFunctionForOptimization(f);
f(); f(); f();
%OptimizeFunctionOnNextCall(f);
var result = f();
......@@ -54,6 +55,7 @@ function doubles() {
return elem2;
}
%PrepareFunctionForOptimization(doubles);
doubles(); doubles(); doubles();
%OptimizeFunctionOnNextCall(doubles);
result = doubles();
......@@ -70,6 +72,7 @@ function doubles_int() {
return elem2;
}
%PrepareFunctionForOptimization(doubles_int);
doubles_int(); doubles_int(); doubles_int();
%OptimizeFunctionOnNextCall(doubles_int);
result = doubles_int();
......@@ -91,6 +94,7 @@ function branch_int(left) {
return elem2;
}
%PrepareFunctionForOptimization(branch_int);
branch_int(1); branch_int(1); branch_int(1);
%OptimizeFunctionOnNextCall(branch_int);
result = branch_int(1);
......@@ -110,6 +114,7 @@ function boom() {
return [ a1, a2, a3 ];
}
%PrepareFunctionForOptimization(boom);
boom(); boom(); boom();
%OptimizeFunctionOnNextCall(boom);
boom();
......@@ -36,6 +36,7 @@
}
var y = invoker(m, selfOf);
%PrepareFunctionForOptimization(y);
function selfOf(c) {
var sssss = c.self_;
......@@ -67,6 +68,7 @@
return f.apply(deopt(), arguments);
};
%PrepareFunctionForOptimization(XXXXX);
XXXXX();
XXXXX();
XXXXX();
......
......@@ -45,6 +45,7 @@ function test_do_not_assert_on_non_int32(vector, base) {
}
return r;
}
%PrepareFunctionForOptimization(test_do_not_assert_on_non_int32);
test_do_not_assert_on_non_int32(v,1);
test_do_not_assert_on_non_int32(v,1);
test_do_not_assert_on_non_int32(v,"a");
......@@ -86,7 +87,7 @@ function check_test_base(a, base, condition) {
}
}
%PrepareFunctionForOptimization(test_base);
test_base(a, 1, true);
test_base(a, 2, true);
test_base(a, 1, false);
......@@ -153,6 +154,7 @@ function check_test_minus(base,cond) {
}
}
%PrepareFunctionForOptimization(test_minus);
test_minus(5,true);
test_minus(6,true);
%OptimizeFunctionOnNextCall(test_minus);
......@@ -190,6 +192,7 @@ function test_phi(a, base, check) {
result += a[index - 1];
return result;
}
%PrepareFunctionForOptimization(test_phi);
var result_phi = 0;
result_phi = test_phi(data_phi, 3, true);
assertEquals(12, result_phi);
......@@ -218,6 +221,7 @@ function test_composition(a, base0, check) {
return result;
}
%PrepareFunctionForOptimization(test_composition);
var result_composition = 0;
result_composition = test_composition(data_composition_long, 2);
assertEquals(19, result_composition);
......
......@@ -32,6 +32,8 @@ function TestNonSmiArrayLength() {
return a.length+1;
}
%PrepareFunctionForOptimization(f);
var a = [];
a.length = 0xFFFF;
assertSame(0x10000, f(a));
......
......@@ -131,6 +131,7 @@
return v;
}
%PrepareFunctionForOptimization(f);
var a = [true, true, true, true]
assertEquals(1, f(a, false));
assertEquals(1, f(a, false));
......
......@@ -135,7 +135,7 @@
function f(a, i) {
a.push(i);
}
%PrepareFunctionForOptimization(f);
var a = [1,2,3];
a.f = function() { return 10; }
f(a, 4);
......
......@@ -42,6 +42,7 @@ v = 0;
function push_wrapper_1(array, value) {
array.push(value);
}
%PrepareFunctionForOptimization(push_wrapper_1);
array = [];
array.__proto__ = my_array_proto;
push_wrapper_1(array, 100);
......
......@@ -8,6 +8,8 @@ function push_wrapper(array, value) {
array.push(value);
}
%PrepareFunctionForOptimization(push_wrapper);
// Test that optimization of Array.push() for non-Arrays works correctly.
var object = { x : 8, length: 3 };
object[18] = 5;
......
......@@ -7,9 +7,12 @@
function push_wrapper(array, value) {
array.push(value);
}
%PrepareFunctionForOptimization(push_wrapper);
function pop_wrapper(array) {
return array.pop();
}
%PrepareFunctionForOptimization(pop_wrapper);
// Test the frzon arrays throw an exception if you try to push to them, both in
// optimized and non-optimized code.
......
This diff is collapsed.
......@@ -12,9 +12,11 @@ var f = (function() {
return foo;
})();
%PrepareFunctionForOptimization(f);
function deopt(f) {
return {
toString : function() {
toString: function() {
%DeoptimizeFunction(f);
return "2";
}
......
......@@ -70,6 +70,7 @@ function f(x, len) {
}
}
%PrepareFunctionForOptimization(f);
f(0, 10);
f(0, 10);
%OptimizeFunctionOnNextCall(f);
......
......@@ -10,13 +10,15 @@ function __f_2(o) {
return o.field.b.x;
}
%PrepareFunctionForOptimization(__f_2);
try {
%OptimizeFunctionOnNextCall(__f_2);
__v_1 = __f_2();
} catch(e) { }
} catch (e) { }
function __f_3() { __f_3(/./.test()); };
try {
__f_3();
} catch(e) { }
__f_3();
} catch (e) { }
......@@ -12,6 +12,7 @@ function __f_17(__v_16, base) {
__v_16[base + 1] = 1;
__v_16[base + 4] = base + 4;
}
%PrepareFunctionForOptimization(__f_17);
__f_17(__v_16, true);
__f_17(__v_16, 14);
%OptimizeFunctionOnNextCall(__f_17);
......
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