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

Unified Diff: test/mjsunit/es6/tail-call.js

Issue 1693523002: [es6] More efficient way of marking AST call expressions in tail positions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Removed MarkTail() from Statement Created 4 years, 10 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 | « src/parsing/parser-base.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/tail-call.js
diff --git a/test/mjsunit/es6/tail-call.js b/test/mjsunit/es6/tail-call.js
index a728a2ce41cb010b6040e1d89be6287d5e6dd4fd..82919ae62e9d40e010a879a9f4019e032cf88c18 100644
--- a/test/mjsunit/es6/tail-call.js
+++ b/test/mjsunit/es6/tail-call.js
@@ -15,6 +15,16 @@ function CheckStackTrace(expected) {
}
}
+function f(expected_call_stack, a, b) {
+ CheckStackTrace(expected_call_stack);
+ return a;
+}
+
+function f_153(expected_call_stack, a) {
+ CheckStackTrace(expected_call_stack);
+ return 153;
+}
+
// Tail call when caller does not have an arguments adaptor frame.
(function test() {
@@ -175,3 +185,149 @@ function CheckStackTrace(expected) {
function g4(a) { return b4(2); }
assertEquals(12, g4());
})();
+
+
+// Tail calling via various expressions.
+(function test() {
+ function g1(a) {
+ return f([f, g1, test], false) || f([f, test], true);
+ }
+ assertEquals(true, g1());
+
+ function g2(a) {
+ return f([f, g2, test], true) && f([f, test], true);
+ }
+ assertEquals(true, g2());
+
+ function g3(a) {
+ return f([f, g3, test], 13), f([f, test], 153);
+ }
+ assertEquals(153, g3());
+})();
+
+
+// Test tail calls from try-catch-finally constructs.
+(function test() {
+ //
+ // try-catch
+ //
+ function tc1(a) {
+ try {
+ f_153([f_153, tc1, test]);
+ return f_153([f_153, tc1, test]);
+ } catch(e) {
+ f_153([f_153, tc1, test]);
+ }
+ }
+ assertEquals(153, tc1());
+
+ function tc2(a) {
+ try {
+ f_153([f_153, tc2, test]);
+ throw new Error("boom");
+ } catch(e) {
+ f_153([f_153, tc2, test]);
+ return f_153([f_153, test]);
+ }
+ }
+ assertEquals(153, tc2());
+
+ function tc3(a) {
+ try {
+ f_153([f_153, tc3, test]);
+ throw new Error("boom");
+ } catch(e) {
+ f_153([f_153, tc3, test]);
+ }
+ f_153([f_153, tc3, test]);
+ return f_153([f_153, test]);
+ }
+ assertEquals(153, tc3());
+
+ //
+ // try-finally
+ //
+ function tf1(a) {
+ try {
+ f_153([f_153, tf1, test]);
+ return f_153([f_153, tf1, test]);
+ } finally {
+ f_153([f_153, tf1, test]);
+ }
+ }
+ assertEquals(153, tf1());
+
+ function tf2(a) {
+ try {
+ f_153([f_153, tf2, test]);
+ throw new Error("boom");
+ } finally {
+ f_153([f_153, tf2, test]);
+ return f_153([f_153, test]);
+ }
+ }
+ assertEquals(153, tf2());
+
+ function tf3(a) {
+ try {
+ f_153([f_153, tf3, test]);
+ } finally {
+ f_153([f_153, tf3, test]);
+ }
+ return f_153([f_153, test]);
+ }
+ assertEquals(153, tf3());
+
+ //
+ // try-catch-finally
+ //
+ function tcf1(a) {
+ try {
+ f_153([f_153, tcf1, test]);
+ return f_153([f_153, tcf1, test]);
+ } catch(e) {
+ } finally {
+ f_153([f_153, tcf1, test]);
+ }
+ }
+ assertEquals(153, tcf1());
+
+ function tcf2(a) {
+ try {
+ f_153([f_153, tcf2, test]);
+ throw new Error("boom");
+ } catch(e) {
+ f_153([f_153, tcf2, test]);
+ return f_153([f_153, tcf2, test]);
+ } finally {
+ f_153([f_153, tcf2, test]);
+ }
+ }
+ assertEquals(153, tcf2());
+
+ function tcf3(a) {
+ try {
+ f_153([f_153, tcf3, test]);
+ throw new Error("boom");
+ } catch(e) {
+ f_153([f_153, tcf3, test]);
+ } finally {
+ f_153([f_153, tcf3, test]);
+ return f_153([f_153, test]);
+ }
+ }
+ assertEquals(153, tcf3());
+
+ function tcf4(a) {
+ try {
+ f_153([f_153, tcf4, test]);
+ throw new Error("boom");
+ } catch(e) {
+ f_153([f_153, tcf4, test]);
+ } finally {
+ f_153([f_153, tcf4, test]);
+ }
+ return f_153([f_153, test]);
+ }
+ assertEquals(153, tcf4());
+})();
« no previous file with comments | « src/parsing/parser-base.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698