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

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

Issue 1439613003: [turbofan] Better and more sane support for tail calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Skip test in ignition configuration Created 5 years, 1 month 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 | « src/runtime/runtime-function.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
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --allow-natives-syntax --nostress-opt --turbo
6 // Flags: --nonative-context-specialization
7
8 var p0 = new Object();
9 var p1 = new Object();
10 var p2 = new Object();
11
12 // Ensure 1 parameter passed straight-through is handled correctly
13 var count1 = 100000;
14 tailee1 = function() {
15 "use strict";
16 if (count1-- == 0) {
17 return this;
18 }
19 return %_Call(tailee1, this);
20 };
21
22 %OptimizeFunctionOnNextCall(tailee1);
23 assertEquals(p0, tailee1.call(p0));
24
25 // Ensure 2 parameters passed straight-through trigger a tail call are handled
26 // correctly and don't cause a stack overflow.
27 var count2 = 100000;
28 tailee2 = function(px) {
29 "use strict";
30 assertEquals(p2, px);
31 assertEquals(p1, this);
32 count2 = ((count2 | 0) - 1) | 0;
33 if ((count2 | 0) === 0) {
34 return this;
35 }
36 return %_Call(tailee2, this, px);
37 };
38
39 %OptimizeFunctionOnNextCall(tailee2);
40 assertEquals(p1, tailee2.call(p1, p2));
41
42 // Ensure swapped 2 parameters don't trigger a tail call (parameter swizzling
43 // for the tail call isn't supported yet).
44 var count3 = 100000;
45 tailee3 = function(px) {
46 "use strict";
47 if (count3-- == 0) {
48 return this;
49 }
50 return %_Call(tailee3, px, this);
51 };
52
53 %OptimizeFunctionOnNextCall(tailee3);
54 assertThrows(function() { tailee3.call(p1, p2); });
55
56 // Ensure too many parameters defeats the tail call optimization (currently
57 // unsupported).
58 var count4 = 1000000;
59 tailee4 = function(px) {
60 "use strict";
61 if (count4-- == 0) {
62 return this;
63 }
64 return %_Call(tailee4, this, px, undefined);
65 };
66
67 %OptimizeFunctionOnNextCall(tailee4);
68 assertThrows(function() { tailee4.call(p1, p2); });
69
70 // Ensure too few parameters defeats the tail call optimization (currently
71 // unsupported).
72 var count5 = 1000000;
73 tailee5 = function(px) {
74 "use strict";
75 if (count5-- == 0) {
76 return this;
77 }
78 return %_Call(tailee5, this);
79 };
80
81 %OptimizeFunctionOnNextCall(tailee5);
82 assertThrows(function() { tailee5.call(p1, p2); });
OLDNEW
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698