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() { ...@@ -38,6 +38,7 @@ function f() {
return elem2; return elem2;
} }
%PrepareFunctionForOptimization(f);
f(); f(); f(); f(); f(); f();
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
var result = f(); var result = f();
...@@ -54,6 +55,7 @@ function doubles() { ...@@ -54,6 +55,7 @@ function doubles() {
return elem2; return elem2;
} }
%PrepareFunctionForOptimization(doubles);
doubles(); doubles(); doubles(); doubles(); doubles(); doubles();
%OptimizeFunctionOnNextCall(doubles); %OptimizeFunctionOnNextCall(doubles);
result = doubles(); result = doubles();
...@@ -70,6 +72,7 @@ function doubles_int() { ...@@ -70,6 +72,7 @@ function doubles_int() {
return elem2; return elem2;
} }
%PrepareFunctionForOptimization(doubles_int);
doubles_int(); doubles_int(); doubles_int(); doubles_int(); doubles_int(); doubles_int();
%OptimizeFunctionOnNextCall(doubles_int); %OptimizeFunctionOnNextCall(doubles_int);
result = doubles_int(); result = doubles_int();
...@@ -91,6 +94,7 @@ function branch_int(left) { ...@@ -91,6 +94,7 @@ function branch_int(left) {
return elem2; return elem2;
} }
%PrepareFunctionForOptimization(branch_int);
branch_int(1); branch_int(1); branch_int(1); branch_int(1); branch_int(1); branch_int(1);
%OptimizeFunctionOnNextCall(branch_int); %OptimizeFunctionOnNextCall(branch_int);
result = branch_int(1); result = branch_int(1);
...@@ -110,6 +114,7 @@ function boom() { ...@@ -110,6 +114,7 @@ function boom() {
return [ a1, a2, a3 ]; return [ a1, a2, a3 ];
} }
%PrepareFunctionForOptimization(boom);
boom(); boom(); boom(); boom(); boom(); boom();
%OptimizeFunctionOnNextCall(boom); %OptimizeFunctionOnNextCall(boom);
boom(); boom();
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
} }
var y = invoker(m, selfOf); var y = invoker(m, selfOf);
%PrepareFunctionForOptimization(y);
function selfOf(c) { function selfOf(c) {
var sssss = c.self_; var sssss = c.self_;
...@@ -67,6 +68,7 @@ ...@@ -67,6 +68,7 @@
return f.apply(deopt(), arguments); return f.apply(deopt(), arguments);
}; };
%PrepareFunctionForOptimization(XXXXX);
XXXXX(); XXXXX();
XXXXX(); XXXXX();
XXXXX(); XXXXX();
......
...@@ -45,6 +45,7 @@ function test_do_not_assert_on_non_int32(vector, base) { ...@@ -45,6 +45,7 @@ function test_do_not_assert_on_non_int32(vector, base) {
} }
return r; 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,1); test_do_not_assert_on_non_int32(v,1);
test_do_not_assert_on_non_int32(v,"a"); test_do_not_assert_on_non_int32(v,"a");
...@@ -86,7 +87,7 @@ function check_test_base(a, base, condition) { ...@@ -86,7 +87,7 @@ function check_test_base(a, base, condition) {
} }
} }
%PrepareFunctionForOptimization(test_base);
test_base(a, 1, true); test_base(a, 1, true);
test_base(a, 2, true); test_base(a, 2, true);
test_base(a, 1, false); test_base(a, 1, false);
...@@ -153,6 +154,7 @@ function check_test_minus(base,cond) { ...@@ -153,6 +154,7 @@ function check_test_minus(base,cond) {
} }
} }
%PrepareFunctionForOptimization(test_minus);
test_minus(5,true); test_minus(5,true);
test_minus(6,true); test_minus(6,true);
%OptimizeFunctionOnNextCall(test_minus); %OptimizeFunctionOnNextCall(test_minus);
...@@ -190,6 +192,7 @@ function test_phi(a, base, check) { ...@@ -190,6 +192,7 @@ function test_phi(a, base, check) {
result += a[index - 1]; result += a[index - 1];
return result; return result;
} }
%PrepareFunctionForOptimization(test_phi);
var result_phi = 0; var result_phi = 0;
result_phi = test_phi(data_phi, 3, true); result_phi = test_phi(data_phi, 3, true);
assertEquals(12, result_phi); assertEquals(12, result_phi);
...@@ -218,6 +221,7 @@ function test_composition(a, base0, check) { ...@@ -218,6 +221,7 @@ function test_composition(a, base0, check) {
return result; return result;
} }
%PrepareFunctionForOptimization(test_composition);
var result_composition = 0; var result_composition = 0;
result_composition = test_composition(data_composition_long, 2); result_composition = test_composition(data_composition_long, 2);
assertEquals(19, result_composition); assertEquals(19, result_composition);
......
...@@ -32,6 +32,8 @@ function TestNonSmiArrayLength() { ...@@ -32,6 +32,8 @@ function TestNonSmiArrayLength() {
return a.length+1; return a.length+1;
} }
%PrepareFunctionForOptimization(f);
var a = []; var a = [];
a.length = 0xFFFF; a.length = 0xFFFF;
assertSame(0x10000, f(a)); assertSame(0x10000, f(a));
......
...@@ -131,6 +131,7 @@ ...@@ -131,6 +131,7 @@
return v; return v;
} }
%PrepareFunctionForOptimization(f);
var a = [true, true, true, true] var a = [true, true, true, true]
assertEquals(1, f(a, false)); assertEquals(1, f(a, false));
assertEquals(1, f(a, false)); assertEquals(1, f(a, false));
......
...@@ -135,7 +135,7 @@ ...@@ -135,7 +135,7 @@
function f(a, i) { function f(a, i) {
a.push(i); a.push(i);
} }
%PrepareFunctionForOptimization(f);
var a = [1,2,3]; var a = [1,2,3];
a.f = function() { return 10; } a.f = function() { return 10; }
f(a, 4); f(a, 4);
......
...@@ -42,6 +42,7 @@ v = 0; ...@@ -42,6 +42,7 @@ v = 0;
function push_wrapper_1(array, value) { function push_wrapper_1(array, value) {
array.push(value); array.push(value);
} }
%PrepareFunctionForOptimization(push_wrapper_1);
array = []; array = [];
array.__proto__ = my_array_proto; array.__proto__ = my_array_proto;
push_wrapper_1(array, 100); push_wrapper_1(array, 100);
......
...@@ -8,6 +8,8 @@ function push_wrapper(array, value) { ...@@ -8,6 +8,8 @@ function push_wrapper(array, value) {
array.push(value); array.push(value);
} }
%PrepareFunctionForOptimization(push_wrapper);
// Test that optimization of Array.push() for non-Arrays works correctly. // Test that optimization of Array.push() for non-Arrays works correctly.
var object = { x : 8, length: 3 }; var object = { x : 8, length: 3 };
object[18] = 5; object[18] = 5;
......
...@@ -7,9 +7,12 @@ ...@@ -7,9 +7,12 @@
function push_wrapper(array, value) { function push_wrapper(array, value) {
array.push(value); array.push(value);
} }
%PrepareFunctionForOptimization(push_wrapper);
function pop_wrapper(array) { function pop_wrapper(array) {
return array.pop(); return array.pop();
} }
%PrepareFunctionForOptimization(pop_wrapper);
// Test the frzon arrays throw an exception if you try to push to them, both in // Test the frzon arrays throw an exception if you try to push to them, both in
// optimized and non-optimized code. // optimized and non-optimized code.
......
...@@ -571,7 +571,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -571,7 +571,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
let f = (a,current) => a + current; let f = (a,current) => a + current;
let g = function(a) { let g = function(a) {
return a.reduce(f); return a.reduce(f);
} };
%PrepareFunctionForOptimization(g);
let a = [1,2,3,4,5,6,7,8,9,10]; let a = [1,2,3,4,5,6,7,8,9,10];
g(a); g(a); g(a); g(a);
let total = g(a); let total = g(a);
...@@ -583,7 +584,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -583,7 +584,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
let f = (a,current) => a + current; let f = (a,current) => a + current;
let g = function(a) { let g = function(a) {
return a.reduce(f); return a.reduce(f);
} };
%PrepareFunctionForOptimization(g);
let a = [1,2,3,4,5,6,7,8,9,10]; let a = [1,2,3,4,5,6,7,8,9,10];
g(a); g(a); g(a); g(a); g(a); g(a);
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -596,7 +598,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -596,7 +598,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
let f = (a,current) => { if (deopt) %DeoptimizeNow(); return a + current; }; let f = (a,current) => { if (deopt) %DeoptimizeNow(); return a + current; };
let g = function(a) { let g = function(a) {
return a.reduce(f); return a.reduce(f);
} };
%PrepareFunctionForOptimization(g);
let a = [1,2,3,4,5,6,7,8,9,10]; let a = [1,2,3,4,5,6,7,8,9,10];
g(a); g(a); g(a); g(a);
let total = g(a); let total = g(a);
...@@ -614,7 +617,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -614,7 +617,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
}; };
let g = function(a) { let g = function(a) {
return a.reduce(f); return a.reduce(f);
} };
%PrepareFunctionForOptimization(g);
let a = [11,22,33,45,56,6,77,84,93,101]; let a = [11,22,33,45,56,6,77,84,93,101];
g(a); g(a); g(a); g(a);
let total = g(a); let total = g(a);
...@@ -633,7 +637,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -633,7 +637,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
}; };
let g = function() { let g = function() {
return array.reduce(f); return array.reduce(f);
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -657,7 +662,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -657,7 +662,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
}; };
let g = function() { let g = function() {
return array.reduce(f); return array.reduce(f);
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -675,7 +681,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -675,7 +681,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
(function TriggerReduceRightPreLoopDeopt() { (function TriggerReduceRightPreLoopDeopt() {
function f(a) { function f(a) {
a.reduceRight((x) => { return x + 1 }); a.reduceRight((x) => { return x + 1 });
} };
%PrepareFunctionForOptimization(f);
f([1,2,]); f([1,2,]);
f([1,2,]); f([1,2,]);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
...@@ -691,7 +698,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -691,7 +698,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
}; };
let g = function() { let g = function() {
return array.reduceRight(f); return array.reduceRight(f);
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -715,7 +723,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -715,7 +723,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
return array.reduce(f); return array.reduce(f);
} catch (e) { } catch (e) {
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -737,7 +746,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -737,7 +746,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
} catch (e) { } catch (e) {
return null; return null;
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -768,7 +778,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -768,7 +778,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
} catch (e) { } catch (e) {
return null; return null;
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -799,7 +810,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -799,7 +810,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
} finally { } finally {
if (done) return null; if (done) return null;
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -831,7 +843,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -831,7 +843,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
} finally { } finally {
if (done) return null; if (done) return null;
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -856,7 +869,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -856,7 +869,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
let array = [1,2,3]; let array = [1,2,3];
let g = function() { let g = function() {
return array.reduce(f); return array.reduce(f);
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -882,7 +896,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -882,7 +896,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
} catch (e) { } catch (e) {
if (done) return null; if (done) return null;
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -916,7 +931,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -916,7 +931,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
} finally { } finally {
if (done) return null; if (done) return null;
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -939,7 +955,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -939,7 +955,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
let g = function(a) { let g = function(a) {
count = 0; count = 0;
return a.reduceRight(f); return a.reduceRight(f);
} };
%PrepareFunctionForOptimization(g);
let a = [1,2,3,4,5,6,7,8,9,10]; let a = [1,2,3,4,5,6,7,8,9,10];
g(a); g(a); g(a); g(a);
let total = g(a); let total = g(a);
...@@ -953,7 +970,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -953,7 +970,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
let g = function(a) { let g = function(a) {
count = 0; count = 0;
return a.reduceRight(f); return a.reduceRight(f);
} };
%PrepareFunctionForOptimization(g);
let a = [1,2,3,4,5,6,7,8,9,10]; let a = [1,2,3,4,5,6,7,8,9,10];
g(a); g(a); g(a); g(a); g(a); g(a);
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -966,7 +984,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -966,7 +984,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
let f = (a,current) => { if (deopt) %DeoptimizeNow(); return a + current; }; let f = (a,current) => { if (deopt) %DeoptimizeNow(); return a + current; };
let g = function(a) { let g = function(a) {
return a.reduceRight(f); return a.reduceRight(f);
} };
%PrepareFunctionForOptimization(g);
let a = [1,2,3,4,5,6,7,8,9,10]; let a = [1,2,3,4,5,6,7,8,9,10];
g(a); g(a); g(a); g(a);
let total = g(a); let total = g(a);
...@@ -984,7 +1003,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -984,7 +1003,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
}; };
let g = function(a) { let g = function(a) {
return a.reduceRight(f); return a.reduceRight(f);
} };
%PrepareFunctionForOptimization(g);
let a = [11,22,33,45,56,6,77,84,93,101]; let a = [11,22,33,45,56,6,77,84,93,101];
g(a); g(a); g(a); g(a);
let total = g(a); let total = g(a);
...@@ -1003,7 +1023,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1003,7 +1023,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
}; };
let g = function() { let g = function() {
return array.reduceRight(f); return array.reduceRight(f);
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -1027,7 +1048,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1027,7 +1048,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
return array.reduceRight(f); return array.reduceRight(f);
} catch (e) { } catch (e) {
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -1049,7 +1071,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1049,7 +1071,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
} catch (e) { } catch (e) {
return null; return null;
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -1080,7 +1103,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1080,7 +1103,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
} catch (e) { } catch (e) {
return null; return null;
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -1111,7 +1135,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1111,7 +1135,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
} finally { } finally {
if (done) return null; if (done) return null;
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -1143,7 +1168,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1143,7 +1168,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
} finally { } finally {
if (done) return null; if (done) return null;
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -1168,7 +1194,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1168,7 +1194,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
let array = [1,2,3]; let array = [1,2,3];
let g = function() { let g = function() {
return array.reduceRight(f); return array.reduceRight(f);
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -1194,7 +1221,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1194,7 +1221,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
} catch (e) { } catch (e) {
if (done) return null; if (done) return null;
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -1228,7 +1256,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1228,7 +1256,8 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
} finally { } finally {
if (done) return null; if (done) return null;
} }
} };
%PrepareFunctionForOptimization(g);
g(); g(); g(); g();
let total = g(); let total = g();
%OptimizeFunctionOnNextCall(g); %OptimizeFunctionOnNextCall(g);
...@@ -1246,71 +1275,76 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val })); ...@@ -1246,71 +1275,76 @@ assertEquals(undefined, arr.reduceRight(function(val) { return val }));
})(); })();
(function ReduceHoleyArrayWithDefaultAccumulator() { (function ReduceHoleyArrayWithDefaultAccumulator() {
var __v_12258 = new Array(10); var holey = new Array(10);
function __f_3253(a) { function reduce(a) {
let __f_3252 = function(accumulator, currentValue) { let callback = function(accumulator, currentValue) {
return currentValue; return currentValue;
} };
return a.reduce(__f_3252, 13); return a.reduce(callback, 13);
} };
assertEquals(13, __f_3253(__v_12258)); %PrepareFunctionForOptimization(reduce);
assertEquals(13, __f_3253(__v_12258)); assertEquals(13, reduce(holey));
assertEquals(13, __f_3253(__v_12258)); assertEquals(13, reduce(holey));
%OptimizeFunctionOnNextCall(__f_3253); assertEquals(13, reduce(holey));
assertEquals(13, __f_3253(__v_12258)); %OptimizeFunctionOnNextCall(reduce);
assertEquals(13, reduce(holey));
})(); })();
(function ReduceRightHoleyArrayWithDefaultAccumulator() { (function ReduceRightHoleyArrayWithDefaultAccumulator() {
var __v_12258 = new Array(10); var holey = new Array(10);
function __f_3253(a) { function reduce(a) {
let __f_3252 = function(accumulator, currentValue) { let callback = function(accumulator, currentValue) {
return currentValue; return currentValue;
} };
return a.reduceRight(__f_3252, 13); return a.reduceRight(callback, 13);
} };
assertEquals(13, __f_3253(__v_12258)); %PrepareFunctionForOptimization(reduce);
assertEquals(13, __f_3253(__v_12258)); assertEquals(13, reduce(holey));
assertEquals(13, __f_3253(__v_12258)); assertEquals(13, reduce(holey));
%OptimizeFunctionOnNextCall(__f_3253); assertEquals(13, reduce(holey));
assertEquals(13, __f_3253(__v_12258)); %OptimizeFunctionOnNextCall(reduce);
assertEquals(13, reduce(holey));
})(); })();
(function ReduceHoleyArrayOneElementWithDefaultAccumulator() { (function ReduceHoleyArrayOneElementWithDefaultAccumulator() {
var __v_12258 = new Array(10); var holey = new Array(10);
__v_12258[1] = 5; holey[1] = 5;
function __f_3253(a) { function reduce(a) {
let __f_3252 = function(accumulator, currentValue) { let callback = function(accumulator, currentValue) {
return currentValue + accumulator; return currentValue + accumulator;
} };
return a.reduce(__f_3252, 13); return a.reduce(callback, 13);
} };
assertEquals(18, __f_3253(__v_12258)); %PrepareFunctionForOptimization(reduce);
assertEquals(18, __f_3253(__v_12258)); assertEquals(18, reduce(holey));
assertEquals(18, __f_3253(__v_12258)); assertEquals(18, reduce(holey));
%OptimizeFunctionOnNextCall(__f_3253); assertEquals(18, reduce(holey));
assertEquals(18, __f_3253(__v_12258)); %OptimizeFunctionOnNextCall(reduce);
assertEquals(18, reduce(holey));
})(); })();
(function ReduceRightHoleyArrayOneElementWithDefaultAccumulator() { (function ReduceRightHoleyArrayOneElementWithDefaultAccumulator() {
var __v_12258 = new Array(10); var holey = new Array(10);
__v_12258[1] = 5; holey[1] = 5;
function __f_3253(a) { function reduce(a) {
let __f_3252 = function(accumulator, currentValue) { let callback = function(accumulator, currentValue) {
return currentValue + accumulator; return currentValue + accumulator;
} };
return a.reduceRight(__f_3252, 13); return a.reduceRight(callback, 13);
} };
assertEquals(18, __f_3253(__v_12258)); %PrepareFunctionForOptimization(reduce);
assertEquals(18, __f_3253(__v_12258)); assertEquals(18, reduce(holey));
assertEquals(18, __f_3253(__v_12258)); assertEquals(18, reduce(holey));
%OptimizeFunctionOnNextCall(__f_3253); assertEquals(18, reduce(holey));
assertEquals(18, __f_3253(__v_12258)); %OptimizeFunctionOnNextCall(reduce);
assertEquals(18, reduce(holey));
})(); })();
(function ReduceMixedHoleyArrays() { (function ReduceMixedHoleyArrays() {
function r(a) { function r(a) {
return a.reduce((acc, i) => {acc[0]}); return a.reduce((acc, i) => {acc[0]});
} };
%PrepareFunctionForOptimization(r);
r([[0]]); r([[0]]);
r([[0]]); r([[0]]);
r([0,,]); r([0,,]);
......
...@@ -12,9 +12,11 @@ var f = (function() { ...@@ -12,9 +12,11 @@ var f = (function() {
return foo; return foo;
})(); })();
%PrepareFunctionForOptimization(f);
function deopt(f) { function deopt(f) {
return { return {
toString : function() { toString: function() {
%DeoptimizeFunction(f); %DeoptimizeFunction(f);
return "2"; return "2";
} }
......
...@@ -70,6 +70,7 @@ function f(x, len) { ...@@ -70,6 +70,7 @@ function f(x, len) {
} }
} }
%PrepareFunctionForOptimization(f);
f(0, 10); f(0, 10);
f(0, 10); f(0, 10);
%OptimizeFunctionOnNextCall(f); %OptimizeFunctionOnNextCall(f);
......
...@@ -10,13 +10,15 @@ function __f_2(o) { ...@@ -10,13 +10,15 @@ function __f_2(o) {
return o.field.b.x; return o.field.b.x;
} }
%PrepareFunctionForOptimization(__f_2);
try { try {
%OptimizeFunctionOnNextCall(__f_2); %OptimizeFunctionOnNextCall(__f_2);
__v_1 = __f_2(); __v_1 = __f_2();
} catch(e) { } } catch (e) { }
function __f_3() { __f_3(/./.test()); }; function __f_3() { __f_3(/./.test()); };
try { try {
__f_3(); __f_3();
} catch(e) { } } catch (e) { }
...@@ -12,6 +12,7 @@ function __f_17(__v_16, base) { ...@@ -12,6 +12,7 @@ function __f_17(__v_16, base) {
__v_16[base + 1] = 1; __v_16[base + 1] = 1;
__v_16[base + 4] = base + 4; __v_16[base + 4] = base + 4;
} }
%PrepareFunctionForOptimization(__f_17);
__f_17(__v_16, true); __f_17(__v_16, true);
__f_17(__v_16, 14); __f_17(__v_16, 14);
%OptimizeFunctionOnNextCall(__f_17); %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