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

Side by Side Diff: test/unittests/compiler/linkage-tail-call-unittest.cc

Issue 1439613003: [turbofan] Better and more sane support for tail calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rename tests 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
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 #include "src/compiler/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 #include "src/compiler/graph.h" 6 #include "src/compiler/graph.h"
7 #include "src/compiler/linkage.h" 7 #include "src/compiler/linkage.h"
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "test/unittests/test-utils.h" 9 #include "test/unittests/test-utils.h"
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 }; 49 };
50 50
51 51
52 TEST_F(LinkageTailCall, EmptyToEmpty) { 52 TEST_F(LinkageTailCall, EmptyToEmpty) {
53 LocationSignature locations(0, 0, nullptr); 53 LocationSignature locations(0, 0, nullptr);
54 CallDescriptor* desc = NewStandardCallDescriptor(&locations); 54 CallDescriptor* desc = NewStandardCallDescriptor(&locations);
55 CommonOperatorBuilder common(zone()); 55 CommonOperatorBuilder common(zone());
56 const Operator* op = common.Call(desc); 56 const Operator* op = common.Call(desc);
57 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); 57 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false);
58 EXPECT_TRUE(desc->CanTailCall(node)); 58 int stack_param_delta = 0;
59 EXPECT_TRUE(desc->CanTailCall(node, &stack_param_delta));
59 } 60 }
60 61
61 62
62 TEST_F(LinkageTailCall, SameReturn) { 63 TEST_F(LinkageTailCall, SameReturn) {
63 // Caller 64 // Caller
64 LinkageLocation location_array[] = {RegisterLocation(0)}; 65 LinkageLocation location_array[] = {RegisterLocation(0)};
65 LocationSignature locations1(1, 0, location_array); 66 LocationSignature locations1(1, 0, location_array);
66 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 67 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
67 68
68 // Callee 69 // Callee
69 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); 70 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1);
70 71
71 CommonOperatorBuilder common(zone()); 72 CommonOperatorBuilder common(zone());
72 const Operator* op = common.Call(desc2); 73 const Operator* op = common.Call(desc2);
73 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); 74 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false);
74 EXPECT_TRUE(desc1->CanTailCall(node)); 75 int stack_param_delta = 0;
76 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
75 } 77 }
76 78
77 79
78 TEST_F(LinkageTailCall, DifferingReturn) { 80 TEST_F(LinkageTailCall, DifferingReturn) {
79 // Caller 81 // Caller
80 LinkageLocation location_array1[] = {RegisterLocation(0)}; 82 LinkageLocation location_array1[] = {RegisterLocation(0)};
81 LocationSignature locations1(1, 0, location_array1); 83 LocationSignature locations1(1, 0, location_array1);
82 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 84 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
83 85
84 // Callee 86 // Callee
85 LinkageLocation location_array2[] = {RegisterLocation(1)}; 87 LinkageLocation location_array2[] = {RegisterLocation(1)};
86 LocationSignature locations2(1, 0, location_array2); 88 LocationSignature locations2(1, 0, location_array2);
87 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); 89 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2);
88 90
89 CommonOperatorBuilder common(zone()); 91 CommonOperatorBuilder common(zone());
90 const Operator* op = common.Call(desc2); 92 const Operator* op = common.Call(desc2);
91 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); 93 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false);
92 EXPECT_FALSE(desc1->CanTailCall(node)); 94 int stack_param_delta = 0;
95 EXPECT_FALSE(desc1->CanTailCall(node, &stack_param_delta));
93 } 96 }
94 97
95 98
96 TEST_F(LinkageTailCall, MoreRegisterParametersCallee) { 99 TEST_F(LinkageTailCall, MoreRegisterParametersCallee) {
97 // Caller 100 // Caller
98 LinkageLocation location_array1[] = {RegisterLocation(0)}; 101 LinkageLocation location_array1[] = {RegisterLocation(0)};
99 LocationSignature locations1(1, 0, location_array1); 102 LocationSignature locations1(1, 0, location_array1);
100 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 103 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
101 104
102 // Callee 105 // Callee
103 LinkageLocation location_array2[] = {RegisterLocation(0), 106 LinkageLocation location_array2[] = {RegisterLocation(0),
104 RegisterLocation(0)}; 107 RegisterLocation(0)};
105 LocationSignature locations2(1, 1, location_array2); 108 LocationSignature locations2(1, 1, location_array2);
106 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); 109 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2);
107 110
108 CommonOperatorBuilder common(zone()); 111 CommonOperatorBuilder common(zone());
109 const Operator* op = common.Call(desc2); 112 const Operator* op = common.Call(desc2);
110 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); 113 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false);
111 EXPECT_TRUE(desc1->CanTailCall(node)); 114 int stack_param_delta = 0;
115 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
112 } 116 }
113 117
114 118
115 TEST_F(LinkageTailCall, MoreRegisterParametersCaller) { 119 TEST_F(LinkageTailCall, MoreRegisterParametersCaller) {
116 // Caller 120 // Caller
117 LinkageLocation location_array1[] = {RegisterLocation(0), 121 LinkageLocation location_array1[] = {RegisterLocation(0),
118 RegisterLocation(0)}; 122 RegisterLocation(0)};
119 LocationSignature locations1(1, 1, location_array1); 123 LocationSignature locations1(1, 1, location_array1);
120 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 124 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
121 125
122 // Callee 126 // Callee
123 LinkageLocation location_array2[] = {RegisterLocation(0)}; 127 LinkageLocation location_array2[] = {RegisterLocation(0)};
124 LocationSignature locations2(1, 0, location_array2); 128 LocationSignature locations2(1, 0, location_array2);
125 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); 129 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2);
126 130
127 CommonOperatorBuilder common(zone()); 131 CommonOperatorBuilder common(zone());
128 const Operator* op = common.Call(desc2); 132 const Operator* op = common.Call(desc2);
129 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); 133 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false);
130 EXPECT_TRUE(desc1->CanTailCall(node)); 134 int stack_param_delta = 0;
135 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
131 } 136 }
132 137
133 138
134 TEST_F(LinkageTailCall, MoreRegisterAndStackParametersCallee) { 139 TEST_F(LinkageTailCall, MoreRegisterAndStackParametersCallee) {
135 // Caller 140 // Caller
136 LinkageLocation location_array1[] = {RegisterLocation(0)}; 141 LinkageLocation location_array1[] = {RegisterLocation(0)};
137 LocationSignature locations1(1, 0, location_array1); 142 LocationSignature locations1(1, 0, location_array1);
138 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 143 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
139 144
140 // Callee 145 // Callee
141 LinkageLocation location_array2[] = {RegisterLocation(0), RegisterLocation(0), 146 LinkageLocation location_array2[] = {RegisterLocation(0), RegisterLocation(0),
142 RegisterLocation(1), StackLocation(1)}; 147 RegisterLocation(1), StackLocation(1)};
143 LocationSignature locations2(1, 3, location_array2); 148 LocationSignature locations2(1, 3, location_array2);
144 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); 149 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2);
145 150
146 CommonOperatorBuilder common(zone()); 151 CommonOperatorBuilder common(zone());
147 const Operator* op = common.Call(desc2); 152 const Operator* op = common.Call(desc2);
148 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); 153 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false);
149 EXPECT_FALSE(desc1->CanTailCall(node)); 154 int stack_param_delta = 0;
155 EXPECT_FALSE(desc1->CanTailCall(node, &stack_param_delta));
150 } 156 }
151 157
152 158
153 TEST_F(LinkageTailCall, MoreRegisterAndStackParametersCaller) { 159 TEST_F(LinkageTailCall, MoreRegisterAndStackParametersCaller) {
154 // Caller 160 // Caller
155 LinkageLocation location_array[] = {RegisterLocation(0), RegisterLocation(0), 161 LinkageLocation location_array[] = {RegisterLocation(0), RegisterLocation(0),
156 RegisterLocation(1), StackLocation(1)}; 162 RegisterLocation(1), StackLocation(1)};
157 LocationSignature locations1(1, 3, location_array); 163 LocationSignature locations1(1, 3, location_array);
158 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 164 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
159 165
160 // Callee 166 // Callee
161 LinkageLocation location_array2[] = {RegisterLocation(0)}; 167 LinkageLocation location_array2[] = {RegisterLocation(0)};
162 LocationSignature locations2(1, 0, location_array2); 168 LocationSignature locations2(1, 0, location_array2);
163 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); 169 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2);
164 170
165 CommonOperatorBuilder common(zone()); 171 CommonOperatorBuilder common(zone());
166 const Operator* op = common.Call(desc2); 172 const Operator* op = common.Call(desc2);
167 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); 173 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false);
168 EXPECT_FALSE(desc1->CanTailCall(node)); 174 int stack_param_delta = 0;
175 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
Jarin 2015/11/12 13:45:12 How about checking the delta here and below?
danno 2015/11/13 10:04:17 Done.
169 } 176 }
170 177
171 178
172 TEST_F(LinkageTailCall, MatchingStackParameters) { 179 TEST_F(LinkageTailCall, MatchingStackParameters) {
173 // Caller 180 // Caller
174 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), 181 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3),
175 StackLocation(2), StackLocation(1)}; 182 StackLocation(2), StackLocation(1)};
176 LocationSignature locations1(1, 3, location_array); 183 LocationSignature locations1(1, 3, location_array);
177 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 184 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
178 185
179 // Caller 186 // Caller
180 LocationSignature locations2(1, 3, location_array); 187 LocationSignature locations2(1, 3, location_array);
181 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); 188 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1);
182 189
183 CommonOperatorBuilder common(zone()); 190 CommonOperatorBuilder common(zone());
184 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); 191 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false);
185 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); 192 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false);
186 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); 193 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false);
187 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); 194 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false);
188 Node* parameters[] = {p0, p1, p2, p3}; 195 Node* parameters[] = {p0, p1, p2, p3};
189 const Operator* op = common.Call(desc2); 196 const Operator* op = common.Call(desc2);
190 Node* const node = 197 Node* const node =
191 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); 198 Node::New(zone(), 1, op, arraysize(parameters), parameters, false);
192 EXPECT_TRUE(desc1->CanTailCall(node)); 199 int stack_param_delta = 0;
200 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
193 } 201 }
194 202
195 203
196 TEST_F(LinkageTailCall, NonMatchingStackParameters) { 204 TEST_F(LinkageTailCall, NonMatchingStackParameters) {
197 // Caller 205 // Caller
198 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), 206 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3),
199 StackLocation(2), StackLocation(1)}; 207 StackLocation(2), StackLocation(1)};
200 LocationSignature locations1(1, 3, location_array); 208 LocationSignature locations1(1, 3, location_array);
201 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 209 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
202 210
203 // Caller 211 // Caller
204 LocationSignature locations2(1, 3, location_array); 212 LocationSignature locations2(1, 3, location_array);
205 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); 213 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1);
206 214
207 CommonOperatorBuilder common(zone()); 215 CommonOperatorBuilder common(zone());
208 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); 216 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false);
209 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); 217 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false);
210 Node* p2 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); 218 Node* p2 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false);
211 Node* p3 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); 219 Node* p3 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false);
212 Node* parameters[] = {p0, p1, p2, p3}; 220 Node* parameters[] = {p0, p1, p2, p3};
213 const Operator* op = common.Call(desc2); 221 const Operator* op = common.Call(desc2);
214 Node* const node = 222 Node* const node =
215 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); 223 Node::New(zone(), 1, op, arraysize(parameters), parameters, false);
216 EXPECT_FALSE(desc1->CanTailCall(node)); 224 int stack_param_delta = 0;
225 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
217 } 226 }
218 227
219 228
220 TEST_F(LinkageTailCall, MatchingStackParametersExtraCallerRegisters) { 229 TEST_F(LinkageTailCall, MatchingStackParametersExtraCallerRegisters) {
221 // Caller 230 // Caller
222 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), 231 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3),
223 StackLocation(2), StackLocation(1), 232 StackLocation(2), StackLocation(1),
224 RegisterLocation(0), RegisterLocation(1)}; 233 RegisterLocation(0), RegisterLocation(1)};
225 LocationSignature locations1(1, 5, location_array); 234 LocationSignature locations1(1, 5, location_array);
226 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 235 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
227 236
228 // Caller 237 // Caller
229 LocationSignature locations2(1, 3, location_array); 238 LocationSignature locations2(1, 3, location_array);
230 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); 239 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1);
231 240
232 CommonOperatorBuilder common(zone()); 241 CommonOperatorBuilder common(zone());
233 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); 242 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false);
234 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); 243 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false);
235 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); 244 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false);
236 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); 245 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false);
237 Node* parameters[] = {p0, p1, p2, p3}; 246 Node* parameters[] = {p0, p1, p2, p3};
238 const Operator* op = common.Call(desc2); 247 const Operator* op = common.Call(desc2);
239 Node* const node = 248 Node* const node =
240 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); 249 Node::New(zone(), 1, op, arraysize(parameters), parameters, false);
241 EXPECT_TRUE(desc1->CanTailCall(node)); 250 int stack_param_delta = 0;
251 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
242 } 252 }
243 253
244 254
245 TEST_F(LinkageTailCall, MatchingStackParametersExtraCalleeRegisters) { 255 TEST_F(LinkageTailCall, MatchingStackParametersExtraCalleeRegisters) {
246 // Caller 256 // Caller
247 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), 257 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3),
248 StackLocation(2), StackLocation(1), 258 StackLocation(2), StackLocation(1),
249 RegisterLocation(0), RegisterLocation(1)}; 259 RegisterLocation(0), RegisterLocation(1)};
250 LocationSignature locations1(1, 3, location_array); 260 LocationSignature locations1(1, 3, location_array);
251 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 261 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
252 262
253 // Caller 263 // Caller
254 LocationSignature locations2(1, 5, location_array); 264 LocationSignature locations2(1, 5, location_array);
255 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1); 265 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations1);
256 266
257 CommonOperatorBuilder common(zone()); 267 CommonOperatorBuilder common(zone());
258 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); 268 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false);
259 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); 269 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false);
260 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); 270 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false);
261 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); 271 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false);
262 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false); 272 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false);
263 Node* parameters[] = {p0, p1, p2, p3, p4}; 273 Node* parameters[] = {p0, p1, p2, p3, p4};
264 const Operator* op = common.Call(desc2); 274 const Operator* op = common.Call(desc2);
265 Node* const node = 275 Node* const node =
266 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); 276 Node::New(zone(), 1, op, arraysize(parameters), parameters, false);
267 EXPECT_TRUE(desc1->CanTailCall(node)); 277 int stack_param_delta = 0;
278 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
268 } 279 }
269 280
270 281
271 TEST_F(LinkageTailCall, MatchingStackParametersExtraCallerRegistersAndStack) { 282 TEST_F(LinkageTailCall, MatchingStackParametersExtraCallerRegistersAndStack) {
272 // Caller 283 // Caller
273 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), 284 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3),
274 StackLocation(2), StackLocation(1), 285 StackLocation(2), StackLocation(1),
275 RegisterLocation(0), StackLocation(4)}; 286 RegisterLocation(0), StackLocation(4)};
276 LocationSignature locations1(1, 5, location_array); 287 LocationSignature locations1(1, 5, location_array);
277 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 288 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
278 289
279 // Caller 290 // Caller
280 LocationSignature locations2(1, 3, location_array); 291 LocationSignature locations2(1, 3, location_array);
281 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); 292 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2);
282 293
283 CommonOperatorBuilder common(zone()); 294 CommonOperatorBuilder common(zone());
284 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); 295 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false);
285 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); 296 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false);
286 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); 297 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false);
287 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); 298 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false);
288 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false); 299 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false);
289 Node* parameters[] = {p0, p1, p2, p3, p4}; 300 Node* parameters[] = {p0, p1, p2, p3, p4};
290 const Operator* op = common.Call(desc2); 301 const Operator* op = common.Call(desc2);
291 Node* const node = 302 Node* const node =
292 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); 303 Node::New(zone(), 1, op, arraysize(parameters), parameters, false);
293 EXPECT_FALSE(desc1->CanTailCall(node)); 304 int stack_param_delta = 0;
305 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
294 } 306 }
295 307
296 308
297 TEST_F(LinkageTailCall, MatchingStackParametersExtraCalleeRegistersAndStack) { 309 TEST_F(LinkageTailCall, MatchingStackParametersExtraCalleeRegistersAndStack) {
298 // Caller 310 // Caller
299 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), 311 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3),
300 StackLocation(2), RegisterLocation(0), 312 StackLocation(2), RegisterLocation(0),
301 RegisterLocation(1), StackLocation(4)}; 313 RegisterLocation(1), StackLocation(4)};
302 LocationSignature locations1(1, 3, location_array); 314 LocationSignature locations1(1, 3, location_array);
303 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 315 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
304 316
305 // Caller 317 // Caller
306 LocationSignature locations2(1, 5, location_array); 318 LocationSignature locations2(1, 5, location_array);
307 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); 319 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2);
308 320
309 CommonOperatorBuilder common(zone()); 321 CommonOperatorBuilder common(zone());
310 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); 322 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false);
311 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); 323 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false);
312 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); 324 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false);
313 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); 325 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false);
314 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false); 326 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false);
315 Node* parameters[] = {p0, p1, p2, p3, p4}; 327 Node* parameters[] = {p0, p1, p2, p3, p4};
316 const Operator* op = common.Call(desc2); 328 const Operator* op = common.Call(desc2);
317 Node* const node = 329 Node* const node =
318 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); 330 Node::New(zone(), 1, op, arraysize(parameters), parameters, false);
319 EXPECT_FALSE(desc1->CanTailCall(node)); 331 int stack_param_delta = 0;
332 EXPECT_FALSE(desc1->CanTailCall(node, &stack_param_delta));
320 } 333 }
321 334
322 } // namespace compiler 335 } // namespace compiler
323 } // namespace internal 336 } // namespace internal
324 } // namespace v8 337 } // namespace v8
OLDNEW
« src/runtime/runtime-function.cc ('K') | « test/mjsunit/tail-call-intrinsic.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698