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

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

Issue 1455833004: [turbofan]: Implement tail calls with more callee than caller parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Improve comment 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/compiler/x64/code-generator-x64.cc ('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
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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // Callee 150 // Callee
151 LinkageLocation location_array2[] = {RegisterLocation(0), RegisterLocation(0), 151 LinkageLocation location_array2[] = {RegisterLocation(0), RegisterLocation(0),
152 RegisterLocation(1), StackLocation(1)}; 152 RegisterLocation(1), StackLocation(1)};
153 LocationSignature locations2(1, 3, location_array2); 153 LocationSignature locations2(1, 3, location_array2);
154 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); 154 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2);
155 155
156 CommonOperatorBuilder common(zone()); 156 CommonOperatorBuilder common(zone());
157 const Operator* op = common.Call(desc2); 157 const Operator* op = common.Call(desc2);
158 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); 158 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false);
159 int stack_param_delta = 0; 159 int stack_param_delta = 0;
160 EXPECT_FALSE(desc1->CanTailCall(node, &stack_param_delta)); 160 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
161 EXPECT_EQ(1, stack_param_delta); 161 EXPECT_EQ(-1, stack_param_delta);
162 } 162 }
163 163
164 164
165 TEST_F(LinkageTailCall, MoreRegisterAndStackParametersCaller) { 165 TEST_F(LinkageTailCall, MoreRegisterAndStackParametersCaller) {
166 // Caller 166 // Caller
167 LinkageLocation location_array[] = {RegisterLocation(0), RegisterLocation(0), 167 LinkageLocation location_array[] = {RegisterLocation(0), RegisterLocation(0),
168 RegisterLocation(1), StackLocation(1)}; 168 RegisterLocation(1), StackLocation(1)};
169 LocationSignature locations1(1, 3, location_array); 169 LocationSignature locations1(1, 3, location_array);
170 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 170 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
171 171
172 // Callee 172 // Callee
173 LinkageLocation location_array2[] = {RegisterLocation(0)}; 173 LinkageLocation location_array2[] = {RegisterLocation(0)};
174 LocationSignature locations2(1, 0, location_array2); 174 LocationSignature locations2(1, 0, location_array2);
175 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); 175 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2);
176 176
177 CommonOperatorBuilder common(zone()); 177 CommonOperatorBuilder common(zone());
178 const Operator* op = common.Call(desc2); 178 const Operator* op = common.Call(desc2);
179 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); 179 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false);
180 int stack_param_delta = 0; 180 int stack_param_delta = 0;
181 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta)); 181 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
182 EXPECT_EQ(-1, stack_param_delta); 182 EXPECT_EQ(1, stack_param_delta);
183 } 183 }
184 184
185 185
186 TEST_F(LinkageTailCall, MatchingStackParameters) { 186 TEST_F(LinkageTailCall, MatchingStackParameters) {
187 // Caller 187 // Caller
188 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), 188 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3),
189 StackLocation(2), StackLocation(1)}; 189 StackLocation(2), StackLocation(1)};
190 LocationSignature locations1(1, 3, location_array); 190 LocationSignature locations1(1, 3, location_array);
191 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 191 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
192 192
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); 307 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false);
308 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); 308 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false);
309 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); 309 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false);
310 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false); 310 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false);
311 Node* parameters[] = {p0, p1, p2, p3, p4}; 311 Node* parameters[] = {p0, p1, p2, p3, p4};
312 const Operator* op = common.Call(desc2); 312 const Operator* op = common.Call(desc2);
313 Node* const node = 313 Node* const node =
314 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); 314 Node::New(zone(), 1, op, arraysize(parameters), parameters, false);
315 int stack_param_delta = 0; 315 int stack_param_delta = 0;
316 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta)); 316 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
317 EXPECT_EQ(-1, stack_param_delta); 317 EXPECT_EQ(1, stack_param_delta);
318 } 318 }
319 319
320 320
321 TEST_F(LinkageTailCall, MatchingStackParametersExtraCalleeRegistersAndStack) { 321 TEST_F(LinkageTailCall, MatchingStackParametersExtraCalleeRegistersAndStack) {
322 // Caller 322 // Caller
323 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), 323 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3),
324 StackLocation(2), RegisterLocation(0), 324 StackLocation(2), RegisterLocation(0),
325 RegisterLocation(1), StackLocation(4)}; 325 RegisterLocation(1), StackLocation(4)};
326 LocationSignature locations1(1, 3, location_array); 326 LocationSignature locations1(1, 3, location_array);
327 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 327 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
328 328
329 // Caller 329 // Caller
330 LocationSignature locations2(1, 5, location_array); 330 LocationSignature locations2(1, 5, location_array);
331 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); 331 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2);
332 332
333 CommonOperatorBuilder common(zone()); 333 CommonOperatorBuilder common(zone());
334 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); 334 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false);
335 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); 335 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false);
336 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); 336 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false);
337 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); 337 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false);
338 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false); 338 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false);
339 Node* parameters[] = {p0, p1, p2, p3, p4}; 339 Node* parameters[] = {p0, p1, p2, p3, p4};
340 const Operator* op = common.Call(desc2); 340 const Operator* op = common.Call(desc2);
341 Node* const node = 341 Node* const node =
342 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); 342 Node::New(zone(), 1, op, arraysize(parameters), parameters, false);
343 int stack_param_delta = 0; 343 int stack_param_delta = 0;
344 EXPECT_FALSE(desc1->CanTailCall(node, &stack_param_delta)); 344 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
345 EXPECT_EQ(1, stack_param_delta); 345 EXPECT_EQ(-1, stack_param_delta);
346 } 346 }
347 347
348 } // namespace compiler 348 } // namespace compiler
349 } // namespace internal 349 } // namespace internal
350 } // namespace v8 350 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/x64/code-generator-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698