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

Side by Side Diff: test/unittests/compiler/scheduler-unittest.cc

Issue 2446543002: [turbofan] Support variable size argument popping in TF-generated functions (Closed)
Patch Set: Fix tests and arm64 Created 4 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 2015 the V8 project authors. All rights reserved. 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 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/schedule.h" 5 #include "src/compiler/schedule.h"
6 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/graph-visualizer.h" 8 #include "src/compiler/graph-visualizer.h"
9 #include "src/compiler/graph.h" 9 #include "src/compiler/graph.h"
10 #include "src/compiler/js-operator.h" 10 #include "src/compiler/js-operator.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 graph()->SetStart(graph()->NewNode(common()->Start(0))); 89 graph()->SetStart(graph()->NewNode(common()->Start(0)));
90 graph()->SetEnd(graph()->NewNode(common()->End(1), graph()->start())); 90 graph()->SetEnd(graph()->NewNode(common()->End(1), graph()->start()));
91 USE(Scheduler::ComputeSchedule(zone(), graph(), Scheduler::kNoFlags)); 91 USE(Scheduler::ComputeSchedule(zone(), graph(), Scheduler::kNoFlags));
92 } 92 }
93 93
94 94
95 TEST_F(SchedulerTest, BuildScheduleOneParameter) { 95 TEST_F(SchedulerTest, BuildScheduleOneParameter) {
96 graph()->SetStart(graph()->NewNode(common()->Start(0))); 96 graph()->SetStart(graph()->NewNode(common()->Start(0)));
97 97
98 Node* p1 = graph()->NewNode(common()->Parameter(0), graph()->start()); 98 Node* p1 = graph()->NewNode(common()->Parameter(0), graph()->start());
99 Node* ret = graph()->NewNode(common()->Return(), p1, graph()->start(), 99 Node* zero = graph()->NewNode(common()->Int32Constant(0));
100 Node* ret = graph()->NewNode(common()->Return(), zero, p1, graph()->start(),
100 graph()->start()); 101 graph()->start());
101 102
102 graph()->SetEnd(graph()->NewNode(common()->End(1), ret)); 103 graph()->SetEnd(graph()->NewNode(common()->End(1), ret));
103 104
104 USE(Scheduler::ComputeSchedule(zone(), graph(), Scheduler::kNoFlags)); 105 USE(Scheduler::ComputeSchedule(zone(), graph(), Scheduler::kNoFlags));
105 } 106 }
106 107
107 108
108 namespace { 109 namespace {
109 110
(...skipping 11 matching lines...) Expand all
121 122
122 } // namespace 123 } // namespace
123 124
124 125
125 TARGET_TEST_F(SchedulerTest, FloatingDiamond1) { 126 TARGET_TEST_F(SchedulerTest, FloatingDiamond1) {
126 Node* start = graph()->NewNode(common()->Start(1)); 127 Node* start = graph()->NewNode(common()->Start(1));
127 graph()->SetStart(start); 128 graph()->SetStart(start);
128 129
129 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 130 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
130 Node* d1 = CreateDiamond(graph(), common(), p0); 131 Node* d1 = CreateDiamond(graph(), common(), p0);
131 Node* ret = graph()->NewNode(common()->Return(), d1, start, start); 132 Node* zero = graph()->NewNode(common()->Int32Constant(0));
133 Node* ret = graph()->NewNode(common()->Return(), zero, d1, start, start);
132 Node* end = graph()->NewNode(common()->End(1), ret); 134 Node* end = graph()->NewNode(common()->End(1), ret);
133 135
134 graph()->SetEnd(end); 136 graph()->SetEnd(end);
135 137
136 ComputeAndVerifySchedule(13); 138 ComputeAndVerifySchedule(14);
137 } 139 }
138 140
139 TARGET_TEST_F(SchedulerTest, FloatingDeadDiamond1) { 141 TARGET_TEST_F(SchedulerTest, FloatingDeadDiamond1) {
140 Node* start = graph()->NewNode(common()->Start(1)); 142 Node* start = graph()->NewNode(common()->Start(1));
141 graph()->SetStart(start); 143 graph()->SetStart(start);
142 144
143 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 145 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
144 Node* d1 = CreateDiamond(graph(), common(), p0); 146 Node* d1 = CreateDiamond(graph(), common(), p0);
145 USE(d1); 147 USE(d1);
146 Node* ret = graph()->NewNode(common()->Return(), p0, start, start); 148 Node* zero = graph()->NewNode(common()->Int32Constant(0));
149 Node* ret = graph()->NewNode(common()->Return(), zero, p0, start, start);
147 Node* end = graph()->NewNode(common()->End(1), ret); 150 Node* end = graph()->NewNode(common()->End(1), ret);
148 151
149 graph()->SetEnd(end); 152 graph()->SetEnd(end);
150 153
151 ComputeAndVerifySchedule(4); 154 ComputeAndVerifySchedule(5);
152 } 155 }
153 156
154 TARGET_TEST_F(SchedulerTest, FloatingDeadDiamond2) { 157 TARGET_TEST_F(SchedulerTest, FloatingDeadDiamond2) {
155 Graph* g = graph(); 158 Graph* g = graph();
156 Node* start = g->NewNode(common()->Start(1)); 159 Node* start = g->NewNode(common()->Start(1));
157 g->SetStart(start); 160 g->SetStart(start);
158 161
159 Node* n1 = g->NewNode(common()->Parameter(1), start); 162 Node* n1 = g->NewNode(common()->Parameter(1), start);
160 163
161 Node* n2 = g->NewNode(common()->Branch(), n1, start); 164 Node* n2 = g->NewNode(common()->Branch(), n1, start);
162 Node* n3 = g->NewNode(common()->IfTrue(), n2); 165 Node* n3 = g->NewNode(common()->IfTrue(), n2);
163 Node* n4 = g->NewNode(common()->IfFalse(), n2); 166 Node* n4 = g->NewNode(common()->IfFalse(), n2);
164 Node* n5 = g->NewNode(common()->Int32Constant(-100)); 167 Node* n5 = g->NewNode(common()->Int32Constant(-100));
165 Node* n6 = g->NewNode(common()->Return(), n5, start, n4); 168 Node* zero = graph()->NewNode(common()->Int32Constant(0));
169 Node* n6 = g->NewNode(common()->Return(), zero, n5, start, n4);
166 Node* n7 = g->NewNode(common()->Int32Constant(0)); 170 Node* n7 = g->NewNode(common()->Int32Constant(0));
167 Node* n8 = g->NewNode(common()->Return(), n7, start, n3); 171 Node* n8 = g->NewNode(common()->Return(), zero, n7, start, n3);
168 Node* n9 = g->NewNode(common()->End(2), n6, n8); 172 Node* n9 = g->NewNode(common()->End(2), n6, n8);
169 173
170 // Dead nodes 174 // Dead nodes
171 Node* n10 = g->NewNode(common()->Branch(), n1, n3); 175 Node* n10 = g->NewNode(common()->Branch(), n1, n3);
172 Node* n11 = g->NewNode(common()->IfTrue(), n10); 176 Node* n11 = g->NewNode(common()->IfTrue(), n10);
173 Node* n12 = g->NewNode(common()->IfFalse(), n10); 177 Node* n12 = g->NewNode(common()->IfFalse(), n10);
174 Node* n13 = g->NewNode(common()->Merge(2), n11, n12); 178 Node* n13 = g->NewNode(common()->Merge(2), n11, n12);
175 Node* n14 = 179 Node* n14 =
176 g->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), n1, n7, n13); 180 g->NewNode(common()->Phi(MachineRepresentation::kWord32, 2), n1, n7, n13);
177 181
178 USE(n14); 182 USE(n14);
179 183
180 g->SetEnd(n9); 184 g->SetEnd(n9);
181 185
182 ComputeAndVerifySchedule(10); 186 ComputeAndVerifySchedule(11);
183 } 187 }
184 188
185 TARGET_TEST_F(SchedulerTest, FloatingDiamond2) { 189 TARGET_TEST_F(SchedulerTest, FloatingDiamond2) {
186 Node* start = graph()->NewNode(common()->Start(2)); 190 Node* start = graph()->NewNode(common()->Start(2));
187 graph()->SetStart(start); 191 graph()->SetStart(start);
188 192
189 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 193 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
190 Node* p1 = graph()->NewNode(common()->Parameter(1), start); 194 Node* p1 = graph()->NewNode(common()->Parameter(1), start);
191 Node* d1 = CreateDiamond(graph(), common(), p0); 195 Node* d1 = CreateDiamond(graph(), common(), p0);
192 Node* d2 = CreateDiamond(graph(), common(), p1); 196 Node* d2 = CreateDiamond(graph(), common(), p1);
193 Node* add = graph()->NewNode(&kIntAdd, d1, d2); 197 Node* add = graph()->NewNode(&kIntAdd, d1, d2);
194 Node* ret = graph()->NewNode(common()->Return(), add, start, start); 198 Node* zero = graph()->NewNode(common()->Int32Constant(0));
199 Node* ret = graph()->NewNode(common()->Return(), zero, add, start, start);
195 Node* end = graph()->NewNode(common()->End(1), ret); 200 Node* end = graph()->NewNode(common()->End(1), ret);
196 201
197 graph()->SetEnd(end); 202 graph()->SetEnd(end);
198 203
199 ComputeAndVerifySchedule(24); 204 ComputeAndVerifySchedule(25);
200 } 205 }
201 206
202 207
203 TARGET_TEST_F(SchedulerTest, FloatingDiamond3) { 208 TARGET_TEST_F(SchedulerTest, FloatingDiamond3) {
204 Node* start = graph()->NewNode(common()->Start(2)); 209 Node* start = graph()->NewNode(common()->Start(2));
205 graph()->SetStart(start); 210 graph()->SetStart(start);
206 211
207 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 212 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
208 Node* p1 = graph()->NewNode(common()->Parameter(1), start); 213 Node* p1 = graph()->NewNode(common()->Parameter(1), start);
209 Node* d1 = CreateDiamond(graph(), common(), p0); 214 Node* d1 = CreateDiamond(graph(), common(), p0);
210 Node* d2 = CreateDiamond(graph(), common(), p1); 215 Node* d2 = CreateDiamond(graph(), common(), p1);
211 Node* add = graph()->NewNode(&kIntAdd, d1, d2); 216 Node* add = graph()->NewNode(&kIntAdd, d1, d2);
212 Node* d3 = CreateDiamond(graph(), common(), add); 217 Node* d3 = CreateDiamond(graph(), common(), add);
213 Node* ret = graph()->NewNode(common()->Return(), d3, start, start); 218 Node* zero = graph()->NewNode(common()->Int32Constant(0));
219 Node* ret = graph()->NewNode(common()->Return(), zero, d3, start, start);
214 Node* end = graph()->NewNode(common()->End(1), ret); 220 Node* end = graph()->NewNode(common()->End(1), ret);
215 221
216 graph()->SetEnd(end); 222 graph()->SetEnd(end);
217 223
218 ComputeAndVerifySchedule(33); 224 ComputeAndVerifySchedule(34);
219 } 225 }
220 226
221 227
222 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamonds) { 228 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamonds) {
223 Node* start = graph()->NewNode(common()->Start(2)); 229 Node* start = graph()->NewNode(common()->Start(2));
224 graph()->SetStart(start); 230 graph()->SetStart(start);
225 231
226 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 232 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
227 233
228 Node* fv = graph()->NewNode(common()->Int32Constant(7)); 234 Node* fv = graph()->NewNode(common()->Int32Constant(7));
(...skipping 12 matching lines...) Expand all
241 Node* ffalse = graph()->NewNode(common()->Int32Constant(0)); 247 Node* ffalse = graph()->NewNode(common()->Int32Constant(0));
242 Node* phi1 = graph()->NewNode( 248 Node* phi1 = graph()->NewNode(
243 common()->Phi(MachineRepresentation::kTagged, 2), ttrue, ffalse, m1); 249 common()->Phi(MachineRepresentation::kTagged, 2), ttrue, ffalse, m1);
244 250
245 251
246 Node* m = graph()->NewNode(common()->Merge(2), t, f); 252 Node* m = graph()->NewNode(common()->Merge(2), t, f);
247 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), 253 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
248 fv, phi1, m); 254 fv, phi1, m);
249 Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), start, map, m); 255 Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), start, map, m);
250 256
251 Node* ret = graph()->NewNode(common()->Return(), phi, ephi1, start); 257 Node* zero = graph()->NewNode(common()->Int32Constant(0));
258 Node* ret = graph()->NewNode(common()->Return(), zero, phi, ephi1, start);
252 Node* end = graph()->NewNode(common()->End(1), ret); 259 Node* end = graph()->NewNode(common()->End(1), ret);
253 260
254 graph()->SetEnd(end); 261 graph()->SetEnd(end);
255 262
256 ComputeAndVerifySchedule(23); 263 ComputeAndVerifySchedule(24);
257 } 264 }
258 265
259 266
260 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithChain) { 267 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithChain) {
261 Node* start = graph()->NewNode(common()->Start(2)); 268 Node* start = graph()->NewNode(common()->Start(2));
262 graph()->SetStart(start); 269 graph()->SetStart(start);
263 270
264 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 271 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
265 Node* p1 = graph()->NewNode(common()->Parameter(1), start); 272 Node* p1 = graph()->NewNode(common()->Parameter(1), start);
266 Node* c = graph()->NewNode(common()->Int32Constant(7)); 273 Node* c = graph()->NewNode(common()->Int32Constant(7));
(...skipping 20 matching lines...) Expand all
287 common()->Phi(MachineRepresentation::kTagged, 2), phiB1, c, mA2); 294 common()->Phi(MachineRepresentation::kTagged, 2), phiB1, c, mA2);
288 295
289 Node* brB2 = graph()->NewNode(common()->Branch(), phiA1, mB1); 296 Node* brB2 = graph()->NewNode(common()->Branch(), phiA1, mB1);
290 Node* tB2 = graph()->NewNode(common()->IfTrue(), brB2); 297 Node* tB2 = graph()->NewNode(common()->IfTrue(), brB2);
291 Node* fB2 = graph()->NewNode(common()->IfFalse(), brB2); 298 Node* fB2 = graph()->NewNode(common()->IfFalse(), brB2);
292 Node* mB2 = graph()->NewNode(common()->Merge(2), tB2, fB2); 299 Node* mB2 = graph()->NewNode(common()->Merge(2), tB2, fB2);
293 Node* phiB2 = graph()->NewNode( 300 Node* phiB2 = graph()->NewNode(
294 common()->Phi(MachineRepresentation::kTagged, 2), phiA1, c, mB2); 301 common()->Phi(MachineRepresentation::kTagged, 2), phiA1, c, mB2);
295 302
296 Node* add = graph()->NewNode(&kIntAdd, phiA2, phiB2); 303 Node* add = graph()->NewNode(&kIntAdd, phiA2, phiB2);
297 Node* ret = graph()->NewNode(common()->Return(), add, start, start); 304 Node* zero = graph()->NewNode(common()->Int32Constant(0));
305 Node* ret = graph()->NewNode(common()->Return(), zero, add, start, start);
298 Node* end = graph()->NewNode(common()->End(1), ret); 306 Node* end = graph()->NewNode(common()->End(1), ret);
299 307
300 graph()->SetEnd(end); 308 graph()->SetEnd(end);
301 309
302 ComputeAndVerifySchedule(36); 310 ComputeAndVerifySchedule(37);
303 } 311 }
304 312
305 313
306 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithLoop) { 314 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithLoop) {
307 Node* start = graph()->NewNode(common()->Start(2)); 315 Node* start = graph()->NewNode(common()->Start(2));
308 graph()->SetStart(start); 316 graph()->SetStart(start);
309 317
310 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 318 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
311 319
312 Node* fv = graph()->NewNode(common()->Int32Constant(7)); 320 Node* fv = graph()->NewNode(common()->Int32Constant(7));
(...skipping 10 matching lines...) Expand all
323 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); 331 Node* t1 = graph()->NewNode(common()->IfTrue(), br1);
324 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); 332 Node* f1 = graph()->NewNode(common()->IfFalse(), br1);
325 333
326 loop->ReplaceInput(1, t1); // close loop. 334 loop->ReplaceInput(1, t1); // close loop.
327 ind->ReplaceInput(1, ind); // close induction variable. 335 ind->ReplaceInput(1, ind); // close induction variable.
328 336
329 Node* m = graph()->NewNode(common()->Merge(2), t, f1); 337 Node* m = graph()->NewNode(common()->Merge(2), t, f1);
330 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), 338 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
331 fv, ind, m); 339 fv, ind, m);
332 340
333 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); 341 Node* zero = graph()->NewNode(common()->Int32Constant(0));
342 Node* ret = graph()->NewNode(common()->Return(), zero, phi, start, start);
334 Node* end = graph()->NewNode(common()->End(1), ret); 343 Node* end = graph()->NewNode(common()->End(1), ret);
335 344
336 graph()->SetEnd(end); 345 graph()->SetEnd(end);
337 346
338 ComputeAndVerifySchedule(20); 347 ComputeAndVerifySchedule(21);
339 } 348 }
340 349
341 350
342 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond1) { 351 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond1) {
343 Node* start = graph()->NewNode(common()->Start(2)); 352 Node* start = graph()->NewNode(common()->Start(2));
344 graph()->SetStart(start); 353 graph()->SetStart(start);
345 354
346 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 355 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
347 356
348 Node* c = graph()->NewNode(common()->Int32Constant(7)); 357 Node* c = graph()->NewNode(common()->Int32Constant(7));
349 Node* loop = graph()->NewNode(common()->Loop(2), start, start); 358 Node* loop = graph()->NewNode(common()->Loop(2), start, start);
350 Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), 359 Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
351 p0, p0, loop); 360 p0, p0, loop);
352 Node* add = graph()->NewNode(&kIntAdd, ind, c); 361 Node* add = graph()->NewNode(&kIntAdd, ind, c);
353 362
354 Node* br = graph()->NewNode(common()->Branch(), add, loop); 363 Node* br = graph()->NewNode(common()->Branch(), add, loop);
355 Node* t = graph()->NewNode(common()->IfTrue(), br); 364 Node* t = graph()->NewNode(common()->IfTrue(), br);
356 Node* f = graph()->NewNode(common()->IfFalse(), br); 365 Node* f = graph()->NewNode(common()->IfFalse(), br);
357 366
358 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); 367 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start());
359 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); 368 Node* t1 = graph()->NewNode(common()->IfTrue(), br1);
360 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); 369 Node* f1 = graph()->NewNode(common()->IfFalse(), br1);
361 Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1); 370 Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1);
362 Node* phi1 = graph()->NewNode( 371 Node* phi1 = graph()->NewNode(
363 common()->Phi(MachineRepresentation::kTagged, 2), add, p0, m1); 372 common()->Phi(MachineRepresentation::kTagged, 2), add, p0, m1);
364 373
365 loop->ReplaceInput(1, t); // close loop. 374 loop->ReplaceInput(1, t); // close loop.
366 ind->ReplaceInput(1, phi1); // close induction variable. 375 ind->ReplaceInput(1, phi1); // close induction variable.
367 376
368 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); 377 Node* zero = graph()->NewNode(common()->Int32Constant(0));
378 Node* ret = graph()->NewNode(common()->Return(), zero, ind, start, f);
369 Node* end = graph()->NewNode(common()->End(2), ret, f); 379 Node* end = graph()->NewNode(common()->End(2), ret, f);
370 380
371 graph()->SetEnd(end); 381 graph()->SetEnd(end);
372 382
373 ComputeAndVerifySchedule(20); 383 ComputeAndVerifySchedule(21);
374 } 384 }
375 385
376 386
377 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond2) { 387 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond2) {
378 Node* start = graph()->NewNode(common()->Start(2)); 388 Node* start = graph()->NewNode(common()->Start(2));
379 graph()->SetStart(start); 389 graph()->SetStart(start);
380 390
381 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 391 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
382 392
383 Node* c = graph()->NewNode(common()->Int32Constant(7)); 393 Node* c = graph()->NewNode(common()->Int32Constant(7));
(...skipping 10 matching lines...) Expand all
394 404
395 Node* add = graph()->NewNode(&kIntAdd, ind, phi1); 405 Node* add = graph()->NewNode(&kIntAdd, ind, phi1);
396 406
397 Node* br = graph()->NewNode(common()->Branch(), add, loop); 407 Node* br = graph()->NewNode(common()->Branch(), add, loop);
398 Node* t = graph()->NewNode(common()->IfTrue(), br); 408 Node* t = graph()->NewNode(common()->IfTrue(), br);
399 Node* f = graph()->NewNode(common()->IfFalse(), br); 409 Node* f = graph()->NewNode(common()->IfFalse(), br);
400 410
401 loop->ReplaceInput(1, t); // close loop. 411 loop->ReplaceInput(1, t); // close loop.
402 ind->ReplaceInput(1, add); // close induction variable. 412 ind->ReplaceInput(1, add); // close induction variable.
403 413
404 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); 414 Node* zero = graph()->NewNode(common()->Int32Constant(0));
415 Node* ret = graph()->NewNode(common()->Return(), zero, ind, start, f);
405 Node* end = graph()->NewNode(common()->End(2), ret, f); 416 Node* end = graph()->NewNode(common()->End(2), ret, f);
406 417
407 graph()->SetEnd(end); 418 graph()->SetEnd(end);
408 419
409 ComputeAndVerifySchedule(20); 420 ComputeAndVerifySchedule(21);
410 } 421 }
411 422
412 423
413 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond3) { 424 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond3) {
414 Node* start = graph()->NewNode(common()->Start(2)); 425 Node* start = graph()->NewNode(common()->Start(2));
415 graph()->SetStart(start); 426 graph()->SetStart(start);
416 427
417 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 428 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
418 429
419 Node* c = graph()->NewNode(common()->Int32Constant(7)); 430 Node* c = graph()->NewNode(common()->Int32Constant(7));
(...skipping 23 matching lines...) Expand all
443 454
444 Node* add = graph()->NewNode(&kIntAdd, ind, phi1); 455 Node* add = graph()->NewNode(&kIntAdd, ind, phi1);
445 456
446 Node* br = graph()->NewNode(common()->Branch(), add, loop); 457 Node* br = graph()->NewNode(common()->Branch(), add, loop);
447 Node* t = graph()->NewNode(common()->IfTrue(), br); 458 Node* t = graph()->NewNode(common()->IfTrue(), br);
448 Node* f = graph()->NewNode(common()->IfFalse(), br); 459 Node* f = graph()->NewNode(common()->IfFalse(), br);
449 460
450 loop->ReplaceInput(1, t); // close loop. 461 loop->ReplaceInput(1, t); // close loop.
451 ind->ReplaceInput(1, add); // close induction variable. 462 ind->ReplaceInput(1, add); // close induction variable.
452 463
453 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); 464 Node* zero = graph()->NewNode(common()->Int32Constant(0));
465 Node* ret = graph()->NewNode(common()->Return(), zero, ind, start, f);
454 Node* end = graph()->NewNode(common()->End(2), ret, f); 466 Node* end = graph()->NewNode(common()->End(2), ret, f);
455 467
456 graph()->SetEnd(end); 468 graph()->SetEnd(end);
457 469
458 ComputeAndVerifySchedule(28); 470 ComputeAndVerifySchedule(29);
459 } 471 }
460 472
461 473
462 TARGET_TEST_F(SchedulerTest, PhisPushedDownToDifferentBranches) { 474 TARGET_TEST_F(SchedulerTest, PhisPushedDownToDifferentBranches) {
463 Node* start = graph()->NewNode(common()->Start(2)); 475 Node* start = graph()->NewNode(common()->Start(2));
464 graph()->SetStart(start); 476 graph()->SetStart(start);
465 477
466 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 478 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
467 Node* p1 = graph()->NewNode(common()->Parameter(1), start); 479 Node* p1 = graph()->NewNode(common()->Parameter(1), start);
468 480
(...skipping 10 matching lines...) Expand all
479 Node* phi2 = graph()->NewNode( 491 Node* phi2 = graph()->NewNode(
480 common()->Phi(MachineRepresentation::kTagged, 2), v3, v4, m); 492 common()->Phi(MachineRepresentation::kTagged, 2), v3, v4, m);
481 493
482 Node* br2 = graph()->NewNode(common()->Branch(), p1, graph()->start()); 494 Node* br2 = graph()->NewNode(common()->Branch(), p1, graph()->start());
483 Node* t2 = graph()->NewNode(common()->IfTrue(), br2); 495 Node* t2 = graph()->NewNode(common()->IfTrue(), br2);
484 Node* f2 = graph()->NewNode(common()->IfFalse(), br2); 496 Node* f2 = graph()->NewNode(common()->IfFalse(), br2);
485 Node* m2 = graph()->NewNode(common()->Merge(2), t2, f2); 497 Node* m2 = graph()->NewNode(common()->Merge(2), t2, f2);
486 Node* phi3 = graph()->NewNode( 498 Node* phi3 = graph()->NewNode(
487 common()->Phi(MachineRepresentation::kTagged, 2), phi, phi2, m2); 499 common()->Phi(MachineRepresentation::kTagged, 2), phi, phi2, m2);
488 500
489 Node* ret = graph()->NewNode(common()->Return(), phi3, start, start); 501 Node* zero = graph()->NewNode(common()->Int32Constant(0));
502 Node* ret = graph()->NewNode(common()->Return(), zero, phi3, start, start);
490 Node* end = graph()->NewNode(common()->End(1), ret); 503 Node* end = graph()->NewNode(common()->End(1), ret);
491 504
492 graph()->SetEnd(end); 505 graph()->SetEnd(end);
493 506
494 ComputeAndVerifySchedule(24); 507 ComputeAndVerifySchedule(25);
495 } 508 }
496 509
497 510
498 TARGET_TEST_F(SchedulerTest, BranchHintTrue) { 511 TARGET_TEST_F(SchedulerTest, BranchHintTrue) {
499 Node* start = graph()->NewNode(common()->Start(1)); 512 Node* start = graph()->NewNode(common()->Start(1));
500 graph()->SetStart(start); 513 graph()->SetStart(start);
501 514
502 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 515 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
503 Node* tv = graph()->NewNode(common()->Int32Constant(6)); 516 Node* tv = graph()->NewNode(common()->Int32Constant(6));
504 Node* fv = graph()->NewNode(common()->Int32Constant(7)); 517 Node* fv = graph()->NewNode(common()->Int32Constant(7));
505 Node* br = graph()->NewNode(common()->Branch(BranchHint::kTrue), p0, start); 518 Node* br = graph()->NewNode(common()->Branch(BranchHint::kTrue), p0, start);
506 Node* t = graph()->NewNode(common()->IfTrue(), br); 519 Node* t = graph()->NewNode(common()->IfTrue(), br);
507 Node* f = graph()->NewNode(common()->IfFalse(), br); 520 Node* f = graph()->NewNode(common()->IfFalse(), br);
508 Node* m = graph()->NewNode(common()->Merge(2), t, f); 521 Node* m = graph()->NewNode(common()->Merge(2), t, f);
509 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), 522 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
510 tv, fv, m); 523 tv, fv, m);
511 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); 524 Node* zero = graph()->NewNode(common()->Int32Constant(0));
525 Node* ret = graph()->NewNode(common()->Return(), zero, phi, start, start);
512 Node* end = graph()->NewNode(common()->End(1), ret); 526 Node* end = graph()->NewNode(common()->End(1), ret);
513 527
514 graph()->SetEnd(end); 528 graph()->SetEnd(end);
515 529
516 Schedule* schedule = ComputeAndVerifySchedule(13); 530 Schedule* schedule = ComputeAndVerifySchedule(14);
517 // Make sure the false block is marked as deferred. 531 // Make sure the false block is marked as deferred.
518 EXPECT_FALSE(schedule->block(t)->deferred()); 532 EXPECT_FALSE(schedule->block(t)->deferred());
519 EXPECT_TRUE(schedule->block(f)->deferred()); 533 EXPECT_TRUE(schedule->block(f)->deferred());
520 } 534 }
521 535
522 536
523 TARGET_TEST_F(SchedulerTest, BranchHintFalse) { 537 TARGET_TEST_F(SchedulerTest, BranchHintFalse) {
524 Node* start = graph()->NewNode(common()->Start(1)); 538 Node* start = graph()->NewNode(common()->Start(1));
525 graph()->SetStart(start); 539 graph()->SetStart(start);
526 540
527 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 541 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
528 Node* tv = graph()->NewNode(common()->Int32Constant(6)); 542 Node* tv = graph()->NewNode(common()->Int32Constant(6));
529 Node* fv = graph()->NewNode(common()->Int32Constant(7)); 543 Node* fv = graph()->NewNode(common()->Int32Constant(7));
530 Node* br = graph()->NewNode(common()->Branch(BranchHint::kFalse), p0, start); 544 Node* br = graph()->NewNode(common()->Branch(BranchHint::kFalse), p0, start);
531 Node* t = graph()->NewNode(common()->IfTrue(), br); 545 Node* t = graph()->NewNode(common()->IfTrue(), br);
532 Node* f = graph()->NewNode(common()->IfFalse(), br); 546 Node* f = graph()->NewNode(common()->IfFalse(), br);
533 Node* m = graph()->NewNode(common()->Merge(2), t, f); 547 Node* m = graph()->NewNode(common()->Merge(2), t, f);
534 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), 548 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
535 tv, fv, m); 549 tv, fv, m);
536 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); 550 Node* zero = graph()->NewNode(common()->Int32Constant(0));
551 Node* ret = graph()->NewNode(common()->Return(), zero, phi, start, start);
537 Node* end = graph()->NewNode(common()->End(1), ret); 552 Node* end = graph()->NewNode(common()->End(1), ret);
538 553
539 graph()->SetEnd(end); 554 graph()->SetEnd(end);
540 555
541 Schedule* schedule = ComputeAndVerifySchedule(13); 556 Schedule* schedule = ComputeAndVerifySchedule(14);
542 // Make sure the true block is marked as deferred. 557 // Make sure the true block is marked as deferred.
543 EXPECT_TRUE(schedule->block(t)->deferred()); 558 EXPECT_TRUE(schedule->block(t)->deferred());
544 EXPECT_FALSE(schedule->block(f)->deferred()); 559 EXPECT_FALSE(schedule->block(f)->deferred());
545 } 560 }
546 561
547 562
548 TARGET_TEST_F(SchedulerTest, CallException) { 563 TARGET_TEST_F(SchedulerTest, CallException) {
549 Node* start = graph()->NewNode(common()->Start(1)); 564 Node* start = graph()->NewNode(common()->Start(1));
550 graph()->SetStart(start); 565 graph()->SetStart(start);
551 566
552 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 567 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
553 Node* c1 = graph()->NewNode(&kMockCall, start); 568 Node* c1 = graph()->NewNode(&kMockCall, start);
554 Node* ok1 = graph()->NewNode(common()->IfSuccess(), c1); 569 Node* ok1 = graph()->NewNode(common()->IfSuccess(), c1);
555 Node* ex1 = graph()->NewNode(common()->IfException(), c1, c1); 570 Node* ex1 = graph()->NewNode(common()->IfException(), c1, c1);
556 Node* c2 = graph()->NewNode(&kMockCall, ok1); 571 Node* c2 = graph()->NewNode(&kMockCall, ok1);
557 Node* ok2 = graph()->NewNode(common()->IfSuccess(), c2); 572 Node* ok2 = graph()->NewNode(common()->IfSuccess(), c2);
558 Node* ex2 = graph()->NewNode(common()->IfException(), c2, c2); 573 Node* ex2 = graph()->NewNode(common()->IfException(), c2, c2);
559 Node* hdl = graph()->NewNode(common()->Merge(2), ex1, ex2); 574 Node* hdl = graph()->NewNode(common()->Merge(2), ex1, ex2);
560 Node* m = graph()->NewNode(common()->Merge(2), ok2, hdl); 575 Node* m = graph()->NewNode(common()->Merge(2), ok2, hdl);
561 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), 576 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
562 c2, p0, m); 577 c2, p0, m);
563 Node* ret = graph()->NewNode(common()->Return(), phi, start, m); 578 Node* zero = graph()->NewNode(common()->Int32Constant(0));
579 Node* ret = graph()->NewNode(common()->Return(), zero, phi, start, m);
564 Node* end = graph()->NewNode(common()->End(1), ret); 580 Node* end = graph()->NewNode(common()->End(1), ret);
565 581
566 graph()->SetEnd(end); 582 graph()->SetEnd(end);
567 583
568 Schedule* schedule = ComputeAndVerifySchedule(17); 584 Schedule* schedule = ComputeAndVerifySchedule(18);
569 // Make sure the exception blocks as well as the handler are deferred. 585 // Make sure the exception blocks as well as the handler are deferred.
570 EXPECT_TRUE(schedule->block(ex1)->deferred()); 586 EXPECT_TRUE(schedule->block(ex1)->deferred());
571 EXPECT_TRUE(schedule->block(ex2)->deferred()); 587 EXPECT_TRUE(schedule->block(ex2)->deferred());
572 EXPECT_TRUE(schedule->block(hdl)->deferred()); 588 EXPECT_TRUE(schedule->block(hdl)->deferred());
573 EXPECT_FALSE(schedule->block(m)->deferred()); 589 EXPECT_FALSE(schedule->block(m)->deferred());
574 } 590 }
575 591
576 592
577 TARGET_TEST_F(SchedulerTest, TailCall) { 593 TARGET_TEST_F(SchedulerTest, TailCall) {
578 Node* start = graph()->NewNode(common()->Start(1)); 594 Node* start = graph()->NewNode(common()->Start(1));
(...skipping 17 matching lines...) Expand all
596 Node* sw = graph()->NewNode(common()->Switch(3), p0, start); 612 Node* sw = graph()->NewNode(common()->Switch(3), p0, start);
597 Node* c0 = graph()->NewNode(common()->IfValue(0), sw); 613 Node* c0 = graph()->NewNode(common()->IfValue(0), sw);
598 Node* v0 = graph()->NewNode(common()->Int32Constant(11)); 614 Node* v0 = graph()->NewNode(common()->Int32Constant(11));
599 Node* c1 = graph()->NewNode(common()->IfValue(1), sw); 615 Node* c1 = graph()->NewNode(common()->IfValue(1), sw);
600 Node* v1 = graph()->NewNode(common()->Int32Constant(22)); 616 Node* v1 = graph()->NewNode(common()->Int32Constant(22));
601 Node* d = graph()->NewNode(common()->IfDefault(), sw); 617 Node* d = graph()->NewNode(common()->IfDefault(), sw);
602 Node* vd = graph()->NewNode(common()->Int32Constant(33)); 618 Node* vd = graph()->NewNode(common()->Int32Constant(33));
603 Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d); 619 Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d);
604 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 3), 620 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 3),
605 v0, v1, vd, m); 621 v0, v1, vd, m);
606 Node* ret = graph()->NewNode(common()->Return(), phi, start, m); 622 Node* zero = graph()->NewNode(common()->Int32Constant(0));
623 Node* ret = graph()->NewNode(common()->Return(), zero, phi, start, m);
607 Node* end = graph()->NewNode(common()->End(1), ret); 624 Node* end = graph()->NewNode(common()->End(1), ret);
608 625
609 graph()->SetEnd(end); 626 graph()->SetEnd(end);
610 627
611 ComputeAndVerifySchedule(16); 628 ComputeAndVerifySchedule(17);
612 } 629 }
613 630
614 631
615 TARGET_TEST_F(SchedulerTest, FloatingSwitch) { 632 TARGET_TEST_F(SchedulerTest, FloatingSwitch) {
616 Node* start = graph()->NewNode(common()->Start(1)); 633 Node* start = graph()->NewNode(common()->Start(1));
617 graph()->SetStart(start); 634 graph()->SetStart(start);
618 635
619 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 636 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
620 Node* sw = graph()->NewNode(common()->Switch(3), p0, start); 637 Node* sw = graph()->NewNode(common()->Switch(3), p0, start);
621 Node* c0 = graph()->NewNode(common()->IfValue(0), sw); 638 Node* c0 = graph()->NewNode(common()->IfValue(0), sw);
622 Node* v0 = graph()->NewNode(common()->Int32Constant(11)); 639 Node* v0 = graph()->NewNode(common()->Int32Constant(11));
623 Node* c1 = graph()->NewNode(common()->IfValue(1), sw); 640 Node* c1 = graph()->NewNode(common()->IfValue(1), sw);
624 Node* v1 = graph()->NewNode(common()->Int32Constant(22)); 641 Node* v1 = graph()->NewNode(common()->Int32Constant(22));
625 Node* d = graph()->NewNode(common()->IfDefault(), sw); 642 Node* d = graph()->NewNode(common()->IfDefault(), sw);
626 Node* vd = graph()->NewNode(common()->Int32Constant(33)); 643 Node* vd = graph()->NewNode(common()->Int32Constant(33));
627 Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d); 644 Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d);
628 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 3), 645 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 3),
629 v0, v1, vd, m); 646 v0, v1, vd, m);
630 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); 647 Node* zero = graph()->NewNode(common()->Int32Constant(0));
648 Node* ret = graph()->NewNode(common()->Return(), zero, phi, start, start);
631 Node* end = graph()->NewNode(common()->End(1), ret); 649 Node* end = graph()->NewNode(common()->End(1), ret);
632 650
633 graph()->SetEnd(end); 651 graph()->SetEnd(end);
634 652
635 ComputeAndVerifySchedule(16); 653 ComputeAndVerifySchedule(17);
636 } 654 }
637 655
638 656
639 TARGET_TEST_F(SchedulerTest, Terminate) { 657 TARGET_TEST_F(SchedulerTest, Terminate) {
640 Node* start = graph()->NewNode(common()->Start(1)); 658 Node* start = graph()->NewNode(common()->Start(1));
641 graph()->SetStart(start); 659 graph()->SetStart(start);
642 660
643 Node* loop = graph()->NewNode(common()->Loop(2), start, start); 661 Node* loop = graph()->NewNode(common()->Loop(2), start, start);
644 loop->ReplaceInput(1, loop); // self loop, NTL. 662 loop->ReplaceInput(1, loop); // self loop, NTL.
645 663
646 Node* effect = graph()->NewNode(common()->EffectPhi(2), start, start, loop); 664 Node* effect = graph()->NewNode(common()->EffectPhi(2), start, start, loop);
647 effect->ReplaceInput(1, effect); // self loop. 665 effect->ReplaceInput(1, effect); // self loop.
648 666
649 Node* terminate = graph()->NewNode(common()->Terminate(), effect, loop); 667 Node* terminate = graph()->NewNode(common()->Terminate(), effect, loop);
650 Node* end = graph()->NewNode(common()->End(1), terminate); 668 Node* end = graph()->NewNode(common()->End(1), terminate);
651 graph()->SetEnd(end); 669 graph()->SetEnd(end);
652 670
653 Schedule* schedule = ComputeAndVerifySchedule(6); 671 Schedule* schedule = ComputeAndVerifySchedule(6);
654 BasicBlock* block = schedule->block(loop); 672 BasicBlock* block = schedule->block(loop);
655 EXPECT_EQ(block, schedule->block(effect)); 673 EXPECT_EQ(block, schedule->block(effect));
656 EXPECT_GE(block->rpo_number(), 0); 674 EXPECT_GE(block->rpo_number(), 0);
657 } 675 }
658 676
659 } // namespace compiler 677 } // namespace compiler
660 } // namespace internal 678 } // namespace internal
661 } // namespace v8 679 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/node-test-utils.cc ('k') | test/unittests/compiler/tail-call-optimization-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698