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

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

Issue 2082263002: [turbofan]: Support using push instructions for setting up tail call parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix comments Created 4 years, 5 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 | « 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 LinkageLocation location_array2[] = {RegisterLocation(0), RegisterLocation(0), 153 LinkageLocation location_array2[] = {RegisterLocation(0), RegisterLocation(0),
154 RegisterLocation(1), StackLocation(1)}; 154 RegisterLocation(1), StackLocation(1)};
155 LocationSignature locations2(1, 3, location_array2); 155 LocationSignature locations2(1, 3, location_array2);
156 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); 156 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2);
157 157
158 CommonOperatorBuilder common(zone()); 158 CommonOperatorBuilder common(zone());
159 const Operator* op = common.Call(desc2); 159 const Operator* op = common.Call(desc2);
160 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); 160 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false);
161 int stack_param_delta = 0; 161 int stack_param_delta = 0;
162 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta)); 162 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
163 EXPECT_EQ(-1, stack_param_delta); 163 EXPECT_EQ(1, stack_param_delta);
164 } 164 }
165 165
166 166
167 TEST_F(LinkageTailCall, MoreRegisterAndStackParametersCaller) { 167 TEST_F(LinkageTailCall, MoreRegisterAndStackParametersCaller) {
168 // Caller 168 // Caller
169 LinkageLocation location_array[] = {RegisterLocation(0), RegisterLocation(0), 169 LinkageLocation location_array[] = {RegisterLocation(0), RegisterLocation(0),
170 RegisterLocation(1), StackLocation(1)}; 170 RegisterLocation(1), StackLocation(1)};
171 LocationSignature locations1(1, 3, location_array); 171 LocationSignature locations1(1, 3, location_array);
172 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 172 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
173 173
174 // Callee 174 // Callee
175 LinkageLocation location_array2[] = {RegisterLocation(0)}; 175 LinkageLocation location_array2[] = {RegisterLocation(0)};
176 LocationSignature locations2(1, 0, location_array2); 176 LocationSignature locations2(1, 0, location_array2);
177 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); 177 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2);
178 178
179 CommonOperatorBuilder common(zone()); 179 CommonOperatorBuilder common(zone());
180 const Operator* op = common.Call(desc2); 180 const Operator* op = common.Call(desc2);
181 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false); 181 Node* const node = Node::New(zone(), 1, op, 0, nullptr, false);
182 int stack_param_delta = 0; 182 int stack_param_delta = 0;
183 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta)); 183 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
184 EXPECT_EQ(1, stack_param_delta); 184 EXPECT_EQ(-1, stack_param_delta);
185 } 185 }
186 186
187 187
188 TEST_F(LinkageTailCall, MatchingStackParameters) { 188 TEST_F(LinkageTailCall, MatchingStackParameters) {
189 // Caller 189 // Caller
190 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), 190 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3),
191 StackLocation(2), StackLocation(1)}; 191 StackLocation(2), StackLocation(1)};
192 LocationSignature locations1(1, 3, location_array); 192 LocationSignature locations1(1, 3, location_array);
193 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 193 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
194 194
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); 309 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false);
310 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); 310 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false);
311 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); 311 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false);
312 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false); 312 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false);
313 Node* parameters[] = {p0, p1, p2, p3, p4}; 313 Node* parameters[] = {p0, p1, p2, p3, p4};
314 const Operator* op = common.Call(desc2); 314 const Operator* op = common.Call(desc2);
315 Node* const node = 315 Node* const node =
316 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); 316 Node::New(zone(), 1, op, arraysize(parameters), parameters, false);
317 int stack_param_delta = 0; 317 int stack_param_delta = 0;
318 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta)); 318 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
319 EXPECT_EQ(1, stack_param_delta); 319 EXPECT_EQ(-1, stack_param_delta);
320 } 320 }
321 321
322 322
323 TEST_F(LinkageTailCall, MatchingStackParametersExtraCalleeRegistersAndStack) { 323 TEST_F(LinkageTailCall, MatchingStackParametersExtraCalleeRegistersAndStack) {
324 // Caller 324 // Caller
325 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3), 325 LinkageLocation location_array[] = {RegisterLocation(0), StackLocation(3),
326 StackLocation(2), RegisterLocation(0), 326 StackLocation(2), RegisterLocation(0),
327 RegisterLocation(1), StackLocation(4)}; 327 RegisterLocation(1), StackLocation(4)};
328 LocationSignature locations1(1, 3, location_array); 328 LocationSignature locations1(1, 3, location_array);
329 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1); 329 CallDescriptor* desc1 = NewStandardCallDescriptor(&locations1);
330 330
331 // Caller 331 // Caller
332 LocationSignature locations2(1, 5, location_array); 332 LocationSignature locations2(1, 5, location_array);
333 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2); 333 CallDescriptor* desc2 = NewStandardCallDescriptor(&locations2);
334 334
335 CommonOperatorBuilder common(zone()); 335 CommonOperatorBuilder common(zone());
336 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false); 336 Node* p0 = Node::New(zone(), 0, nullptr, 0, nullptr, false);
337 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false); 337 Node* p1 = Node::New(zone(), 0, common.Parameter(0), 0, nullptr, false);
338 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false); 338 Node* p2 = Node::New(zone(), 0, common.Parameter(1), 0, nullptr, false);
339 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false); 339 Node* p3 = Node::New(zone(), 0, common.Parameter(2), 0, nullptr, false);
340 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false); 340 Node* p4 = Node::New(zone(), 0, common.Parameter(3), 0, nullptr, false);
341 Node* parameters[] = {p0, p1, p2, p3, p4}; 341 Node* parameters[] = {p0, p1, p2, p3, p4};
342 const Operator* op = common.Call(desc2); 342 const Operator* op = common.Call(desc2);
343 Node* const node = 343 Node* const node =
344 Node::New(zone(), 1, op, arraysize(parameters), parameters, false); 344 Node::New(zone(), 1, op, arraysize(parameters), parameters, false);
345 int stack_param_delta = 0; 345 int stack_param_delta = 0;
346 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta)); 346 EXPECT_TRUE(desc1->CanTailCall(node, &stack_param_delta));
347 EXPECT_EQ(-1, stack_param_delta); 347 EXPECT_EQ(1, stack_param_delta);
348 } 348 }
349 349
350 } // namespace compiler 350 } // namespace compiler
351 } // namespace internal 351 } // namespace internal
352 } // namespace v8 352 } // 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