Upgrade V8 to 5.1.281.57 DO NOT MERGE
FPIIM-449
Change-Id: Id981b686b4d587ac31697662eb98bb34be42ad90
(cherry picked from commit 3b9bc31999c9787eb726ecdbfd5796bfdec32a18)
diff --git a/test/mjsunit/es6/tail-call.js b/test/mjsunit/es6/tail-call.js
index e9539c3..d0d00f4 100644
--- a/test/mjsunit/es6/tail-call.js
+++ b/test/mjsunit/es6/tail-call.js
@@ -20,6 +20,8 @@
assertEquals(expected[i].name, stack[i + 1].getFunctionName());
}
}
+%NeverOptimizeFunction(CheckStackTrace);
+
function f(expected_call_stack, a, b) {
CheckStackTrace(expected_call_stack);
@@ -69,6 +71,7 @@
assertEquals(12, g4(1));
}
test();
+ test();
%OptimizeFunctionOnNextCall(test);
test();
})();
@@ -111,6 +114,7 @@
assertEquals(12, g4());
}
test();
+ test();
%OptimizeFunctionOnNextCall(test);
test();
})();
@@ -162,6 +166,7 @@
assertEquals(12, g4(1));
}
test();
+ test();
%OptimizeFunctionOnNextCall(test);
test();
})();
@@ -212,6 +217,89 @@
assertEquals(12, g4());
}
test();
+ test();
+ %OptimizeFunctionOnNextCall(test);
+ test();
+})();
+
+
+// Tail calling from getter.
+(function() {
+ function g(v) {
+ CheckStackTrace([g, test]);
+ %DeoptimizeFunction(test);
+ return 153;
+ }
+ %NeverOptimizeFunction(g);
+
+ function f(v) {
+ return g();
+ }
+ %SetForceInlineFlag(f);
+
+ function test() {
+ var o = {};
+ o.__defineGetter__('p', f);
+ assertEquals(153, o.p);
+ }
+
+ test();
+ test();
+ %OptimizeFunctionOnNextCall(test);
+ test();
+})();
+
+
+// Tail calling from setter.
+(function() {
+ function g() {
+ CheckStackTrace([g, test]);
+ %DeoptimizeFunction(test);
+ return 153;
+ }
+ %NeverOptimizeFunction(g);
+
+ var context = 10;
+ function f(v) {
+ return g(context);
+ }
+ %SetForceInlineFlag(f);
+
+ function test() {
+ var o = {};
+ o.__defineSetter__('q', f);
+ assertEquals(1, o.q = 1);
+ }
+
+ test();
+ test();
+ %OptimizeFunctionOnNextCall(test);
+ test();
+})();
+
+
+// Tail calling from constructor.
+(function() {
+ function g(context) {
+ CheckStackTrace([g, test]);
+ %DeoptimizeFunction(test);
+ return {x: 153};
+ }
+ %NeverOptimizeFunction(g);
+
+ function A() {
+ this.x = 42;
+ return g();
+ }
+
+ function test() {
+ var o = new A();
+ %DebugPrint(o);
+ assertEquals(153, o.x);
+ }
+
+ test();
+ test();
%OptimizeFunctionOnNextCall(test);
test();
})();
@@ -237,6 +325,53 @@
assertEquals(153, g3());
}
test();
+ test();
+ %OptimizeFunctionOnNextCall(test);
+ test();
+})();
+
+
+// Tail calling from various statements.
+(function() {
+ function g1() {
+ for (var v in {a:0}) {
+ return f_153([f_153, g1, test]);
+ }
+ }
+
+ function g2() {
+ for (var v of [1, 2, 3]) {
+ return f_153([f_153, g2, test]);
+ }
+ }
+
+ function g3() {
+ for (var i = 0; i < 10; i++) {
+ return f_153([f_153, test]);
+ }
+ }
+
+ function g4() {
+ while (true) {
+ return f_153([f_153, test]);
+ }
+ }
+
+ function g5() {
+ do {
+ return f_153([f_153, test]);
+ } while (true);
+ }
+
+ function test() {
+ assertEquals(153, g1());
+ assertEquals(153, g2());
+ assertEquals(153, g3());
+ assertEquals(153, g4());
+ assertEquals(153, g5());
+ }
+ test();
+ test();
%OptimizeFunctionOnNextCall(test);
test();
})();
@@ -280,6 +415,7 @@
assertEquals(153, tc3());
}
test();
+ test();
%OptimizeFunctionOnNextCall(test);
test();
})();
@@ -321,6 +457,7 @@
assertEquals(153, tf3());
}
test();
+ test();
%OptimizeFunctionOnNextCall(test);
test();
})();
@@ -381,6 +518,28 @@
assertEquals(153, tcf4());
}
test();
+ test();
+ %OptimizeFunctionOnNextCall(test);
+ test();
+})();
+
+
+// Test tail calls from arrow functions.
+(function () {
+ function g1(a) {
+ return (() => { return f_153([f_153, test]); })();
+ }
+
+ function g2(a) {
+ return (() => f_153([f_153, test]))();
+ }
+
+ function test() {
+ assertEquals(153, g1());
+ assertEquals(153, g2());
+ }
+ test();
+ test();
%OptimizeFunctionOnNextCall(test);
test();
})();