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

Side by Side Diff: test/mjsunit/es6/tail-call-simple.js

Issue 1698273003: [es6] [interpreter] Add tail calls support to Ignition. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@tco-turbo-2
Patch Set: Fixed Bytecodes::IsCallOrNew() 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 unified diff | Download patch
« no previous file with comments | « test/cctest/interpreter/test-interpreter.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --allow-natives-syntax --harmony-tailcalls --stack-size=100 5 // Flags: --allow-natives-syntax --harmony-tailcalls --stack-size=100
6 6
7 // 7 //
8 // Tail calls work only in strict mode. 8 // Tail calls work only in strict mode.
9 // 9 //
10 (function() { 10 (function() {
11 function f(n) { 11 function f(n) {
12 if (n <= 0) { 12 if (n <= 0) {
13 return "foo"; 13 return "foo";
14 } 14 }
15 return f(n - 1); 15 return f(n - 1);
16 } 16 }
17 assertThrows(()=>{ f(1e6) }); 17 assertThrows(()=>{ f(1e5) });
18 %OptimizeFunctionOnNextCall(f); 18 %OptimizeFunctionOnNextCall(f);
19 assertThrows(()=>{ f(1e6) }); 19 assertThrows(()=>{ f(1e5) });
20 })(); 20 })();
21 21
22 22
23 // 23 //
24 // Tail call normal functions. 24 // Tail call normal functions.
25 // 25 //
26 (function() { 26 (function() {
27 "use strict"; 27 "use strict";
28 function f(n) { 28 function f(n) {
29 if (n <= 0) { 29 if (n <= 0) {
30 return "foo"; 30 return "foo";
31 } 31 }
32 return f(n - 1); 32 return f(n - 1);
33 } 33 }
34 assertEquals("foo", f(1e6)); 34 assertEquals("foo", f(1e5));
35 %OptimizeFunctionOnNextCall(f); 35 %OptimizeFunctionOnNextCall(f);
36 assertEquals("foo", f(1e6)); 36 assertEquals("foo", f(1e5));
37 })(); 37 })();
38 38
39 39
40 (function() { 40 (function() {
41 "use strict"; 41 "use strict";
42 function f(n){ 42 function f(n){
43 if (n <= 0) { 43 if (n <= 0) {
44 return "foo"; 44 return "foo";
45 } 45 }
46 return g(n - 1); 46 return g(n - 1);
47 } 47 }
48 function g(n){ 48 function g(n){
49 if (n <= 0) { 49 if (n <= 0) {
50 return "bar"; 50 return "bar";
51 } 51 }
52 return f(n - 1); 52 return f(n - 1);
53 } 53 }
54 assertEquals("foo", f(1e6)); 54 assertEquals("foo", f(1e5));
55 assertEquals("bar", f(1e6 + 1)); 55 assertEquals("bar", f(1e5 + 1));
56 %OptimizeFunctionOnNextCall(f); 56 %OptimizeFunctionOnNextCall(f);
57 assertEquals("foo", f(1e6)); 57 assertEquals("foo", f(1e5));
58 assertEquals("bar", f(1e6 + 1)); 58 assertEquals("bar", f(1e5 + 1));
59 })(); 59 })();
60 60
61 61
62 // 62 //
63 // Tail call bound functions. 63 // Tail call bound functions.
64 // 64 //
65 (function() { 65 (function() {
66 "use strict"; 66 "use strict";
67 function f0(n) { 67 function f0(n) {
68 if (n <= 0) { 68 if (n <= 0) {
69 return "foo"; 69 return "foo";
70 } 70 }
71 return f_bound(n - 1); 71 return f_bound(n - 1);
72 } 72 }
73 var f_bound = f0.bind({}); 73 var f_bound = f0.bind({});
74 function f(n) { 74 function f(n) {
75 return f_bound(n); 75 return f_bound(n);
76 } 76 }
77 assertEquals("foo", f(1e6)); 77 assertEquals("foo", f(1e5));
78 %OptimizeFunctionOnNextCall(f); 78 %OptimizeFunctionOnNextCall(f);
79 assertEquals("foo", f(1e6)); 79 assertEquals("foo", f(1e5));
80 })(); 80 })();
81 81
82 82
83 (function() { 83 (function() {
84 "use strict"; 84 "use strict";
85 function f0(n){ 85 function f0(n){
86 if (n <= 0) { 86 if (n <= 0) {
87 return "foo"; 87 return "foo";
88 } 88 }
89 return g_bound(n - 1); 89 return g_bound(n - 1);
90 } 90 }
91 function g0(n){ 91 function g0(n){
92 if (n <= 0) { 92 if (n <= 0) {
93 return "bar"; 93 return "bar";
94 } 94 }
95 return f_bound(n - 1); 95 return f_bound(n - 1);
96 } 96 }
97 var f_bound = f0.bind({}); 97 var f_bound = f0.bind({});
98 var g_bound = g0.bind({}); 98 var g_bound = g0.bind({});
99 function f(n) { 99 function f(n) {
100 return f_bound(n); 100 return f_bound(n);
101 } 101 }
102 assertEquals("foo", f(1e6)); 102 assertEquals("foo", f(1e5));
103 assertEquals("bar", f(1e6 + 1)); 103 assertEquals("bar", f(1e5 + 1));
104 %OptimizeFunctionOnNextCall(f); 104 %OptimizeFunctionOnNextCall(f);
105 assertEquals("foo", f(1e6)); 105 assertEquals("foo", f(1e5));
106 assertEquals("bar", f(1e6 + 1)); 106 assertEquals("bar", f(1e5 + 1));
107 })(); 107 })();
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-interpreter.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698