Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1396)

Unified Diff: test/mjsunit/es8/syntactic-tail-call.js

Issue 1955393002: [es8] Throw SyntaxError when tail call expressions occur in non-strict mode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/es6/tail-call.js ('k') | test/mjsunit/es8/syntactic-tail-call-parsing.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es8/syntactic-tail-call.js
diff --git a/test/mjsunit/es8/syntactic-tail-call.js b/test/mjsunit/es8/syntactic-tail-call.js
index f45caf21835c045ab3f5b25e055efc794d886891..44936a4b22015a16775c0b5f34c42d215cb2991e 100644
--- a/test/mjsunit/es8/syntactic-tail-call.js
+++ b/test/mjsunit/es8/syntactic-tail-call.js
@@ -5,6 +5,8 @@
// Flags: --allow-natives-syntax --harmony-explicit-tailcalls
// Flags: --harmony-do-expressions
+"use strict";
+
Error.prepareStackTrace = (error,stack) => {
error.strace = stack;
return error.message + "\n at " + stack.join("\n at ");
@@ -20,6 +22,8 @@ function CheckStackTrace(expected) {
assertEquals(expected[i].name, stack[i + 1].getFunctionName());
}
}
+%NeverOptimizeFunction(CheckStackTrace);
+
function f(expected_call_stack, a, b) {
CheckStackTrace(expected_call_stack);
@@ -221,6 +225,87 @@ function f_153(expected_call_stack, a) {
})();
+// Tail calling from getter.
+(function() {
+ function g(v) {
+ CheckStackTrace([g, test]);
+ %DeoptimizeFunction(test);
+ return 153;
+ }
+ %NeverOptimizeFunction(g);
+
+ function f(v) {
+ return continue 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);
+
+ function f(v) {
+ return continue g();
+ }
+ %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 continue g();
+ }
+
+ function test() {
+ var o = new A();
+ %DebugPrint(o);
+ assertEquals(153, o.x);
+ }
+
+ test();
+ test();
+ %OptimizeFunctionOnNextCall(test);
+ test();
+})();
+
+
// Tail calling via various expressions.
(function() {
function g1(a) {
@@ -294,6 +379,38 @@ function f_153(expected_call_stack, a) {
})();
+// Tail calling from various statements.
+(function() {
+ function g3() {
+ for (var i = 0; i < 10; i++) {
+ return continue f_153([f_153, test]);
+ }
+ }
+
+ function g4() {
+ while (true) {
+ return continue f_153([f_153, test]);
+ }
+ }
+
+ function g5() {
+ do {
+ return continue f_153([f_153, test]);
+ } while (true);
+ }
+
+ function test() {
+ assertEquals(153, g3());
+ assertEquals(153, g4());
+ assertEquals(153, g5());
+ }
+ test();
+ test();
+ %OptimizeFunctionOnNextCall(test);
+ test();
+})();
+
+
// Test tail calls from try-catch constructs.
(function() {
function tc1(a) {
« no previous file with comments | « test/mjsunit/es6/tail-call.js ('k') | test/mjsunit/es8/syntactic-tail-call-parsing.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698