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

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

Issue 1739233002: [runtime] Remove obsolete %Apply and %TailCall runtime entries. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/mjsunit/strong/function-arity.js ('k') | no next file » | 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 %_TailCall(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 %_TailCall(tailee2, this, px);
37 };
38
39 %OptimizeFunctionOnNextCall(tailee2);
40 assertEquals(p1, tailee2.call(p1, p2));
41
42 // Ensure swapped 2 parameters trigger a tail call and do the appropriate
43 // parameters swapping
44 var count3 = 999999;
45 tailee3 = function(px) {
46 "use strict";
47 if (count3-- == 0) {
48 return this;
49 }
50 return %_TailCall(tailee3, px, this);
51 };
52
53 %OptimizeFunctionOnNextCall(tailee3);
54 assertEquals(p2, 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 %_TailCall(tailee4, this, px, undefined);
65 };
66
67 %OptimizeFunctionOnNextCall(tailee4);
68 assertThrows(function() { tailee4.call(p1, p2); });
69
70 // Ensure that calling the arguments adapter defeats the tail call optimization.
71 var count5 = 1000000;
72 tailee5 = function(px) {
73 "use strict";
74 if (count5-- == 0) {
75 return this;
76 }
77 return %_TailCall(tailee5, this);
78 };
79
80 %OptimizeFunctionOnNextCall(tailee5);
81 assertThrows(function() { tailee5.call(p1, p2); });
82
83 // Ensure tail calls with fewer stack parameters properly re-arranges the stack.
84 tailee6 = function(px) {
85 return px;
86 }
87
88 tailee7 = function(px, py, pz, pa, pb, pc) {
89 "use strict";
90 return %_TailCall(tailee6, this, pc);
91 };
92
93 %OptimizeFunctionOnNextCall(tailee6);
94 %OptimizeFunctionOnNextCall(tailee7);
95 assertEquals(110, tailee7.call(null, 15, 16, 17, 18, 0, 110));
96
97 tailee8 = function(px, py, pz, pa, pb) {
98 return pb + pz + px;
99 }
100
101 tailee9 = function(px, py, pz, pa, pb, pc) {
102 "use strict";
103 return %_TailCall(tailee8, this, pb, py, px, pa, pz);
104 };
105
106 %OptimizeFunctionOnNextCall(tailee8);
107 %OptimizeFunctionOnNextCall(tailee9);
108 assertEquals(32, tailee9.call(null, 15, 16, 17, 18, 0, 110));
OLDNEW
« no previous file with comments | « test/mjsunit/strong/function-arity.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698