OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 <functional> | 5 #include <functional> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
| 8 #include "test/cctest/cctest.h" |
8 | 9 |
9 #include "graph-tester.h" | 10 #include "src/compiler/graph.h" |
10 #include "src/compiler/node.h" | 11 #include "src/compiler/node.h" |
11 #include "src/compiler/operator.h" | 12 #include "src/compiler/operator.h" |
12 | 13 |
13 using namespace v8::internal; | 14 using namespace v8::internal; |
14 using namespace v8::internal::compiler; | 15 using namespace v8::internal::compiler; |
15 | 16 |
16 #define NONE reinterpret_cast<Node*>(1) | 17 #define NONE reinterpret_cast<Node*>(1) |
17 | 18 |
18 static Operator dummy_operator(IrOpcode::kParameter, Operator::kNoWrite, | 19 static Operator dummy_operator(IrOpcode::kParameter, Operator::kNoWrite, |
19 "dummy", 0, 0, 0, 1, 0, 0); | 20 "dummy", 0, 0, 0, 1, 0, 0); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 if (edge.from() == node && edge.to() == input && edge.index() == i) { | 124 if (edge.from() == node && edge.to() == input && edge.index() == i) { |
124 count++; | 125 count++; |
125 } | 126 } |
126 } | 127 } |
127 CHECK_EQ(1, count); | 128 CHECK_EQ(1, count); |
128 } | 129 } |
129 } | 130 } |
130 | 131 |
131 | 132 |
132 TEST(NodeUseIteratorReplaceUses) { | 133 TEST(NodeUseIteratorReplaceUses) { |
133 GraphTester graph; | 134 Zone zone; |
| 135 Graph graph(&zone); |
134 Node* n0 = graph.NewNode(&dummy_operator); | 136 Node* n0 = graph.NewNode(&dummy_operator); |
135 Node* n1 = graph.NewNode(&dummy_operator, n0); | 137 Node* n1 = graph.NewNode(&dummy_operator, n0); |
136 Node* n2 = graph.NewNode(&dummy_operator, n0); | 138 Node* n2 = graph.NewNode(&dummy_operator, n0); |
137 Node* n3 = graph.NewNode(&dummy_operator); | 139 Node* n3 = graph.NewNode(&dummy_operator); |
138 | 140 |
139 CHECK_USES(n0, n1, n2); | 141 CHECK_USES(n0, n1, n2); |
140 | 142 |
141 CHECK_INPUTS(n1, n0); | 143 CHECK_INPUTS(n1, n0); |
142 CHECK_INPUTS(n2, n0); | 144 CHECK_INPUTS(n2, n0); |
143 | 145 |
144 n0->ReplaceUses(n3); | 146 n0->ReplaceUses(n3); |
145 | 147 |
146 CHECK_USES(n0, NONE); | 148 CHECK_USES(n0, NONE); |
147 CHECK_USES(n1, NONE); | 149 CHECK_USES(n1, NONE); |
148 CHECK_USES(n2, NONE); | 150 CHECK_USES(n2, NONE); |
149 CHECK_USES(n3, n1, n2); | 151 CHECK_USES(n3, n1, n2); |
150 | 152 |
151 CHECK_INPUTS(n1, n3); | 153 CHECK_INPUTS(n1, n3); |
152 CHECK_INPUTS(n2, n3); | 154 CHECK_INPUTS(n2, n3); |
153 } | 155 } |
154 | 156 |
155 | 157 |
156 TEST(NodeUseIteratorReplaceUsesSelf) { | 158 TEST(NodeUseIteratorReplaceUsesSelf) { |
157 GraphTester graph; | 159 Zone zone; |
| 160 Graph graph(&zone); |
158 Node* n0 = graph.NewNode(&dummy_operator); | 161 Node* n0 = graph.NewNode(&dummy_operator); |
159 Node* n1 = graph.NewNode(&dummy_operator, n0); | 162 Node* n1 = graph.NewNode(&dummy_operator, n0); |
160 | 163 |
161 CHECK_USES(n0, n1); | 164 CHECK_USES(n0, n1); |
162 CHECK_USES(n1, NONE); | 165 CHECK_USES(n1, NONE); |
163 | 166 |
164 n1->ReplaceInput(0, n1); // Create self-reference. | 167 n1->ReplaceInput(0, n1); // Create self-reference. |
165 | 168 |
166 CHECK_USES(n0, NONE); | 169 CHECK_USES(n0, NONE); |
167 CHECK_USES(n1, n1); | 170 CHECK_USES(n1, n1); |
168 | 171 |
169 Node* n2 = graph.NewNode(&dummy_operator); | 172 Node* n2 = graph.NewNode(&dummy_operator); |
170 | 173 |
171 n1->ReplaceUses(n2); | 174 n1->ReplaceUses(n2); |
172 | 175 |
173 CHECK_USES(n0, NONE); | 176 CHECK_USES(n0, NONE); |
174 CHECK_USES(n1, NONE); | 177 CHECK_USES(n1, NONE); |
175 CHECK_USES(n2, n1); | 178 CHECK_USES(n2, n1); |
176 } | 179 } |
177 | 180 |
178 | 181 |
179 TEST(ReplaceInput) { | 182 TEST(ReplaceInput) { |
180 GraphTester graph; | 183 Zone zone; |
| 184 Graph graph(&zone); |
181 Node* n0 = graph.NewNode(&dummy_operator); | 185 Node* n0 = graph.NewNode(&dummy_operator); |
182 Node* n1 = graph.NewNode(&dummy_operator); | 186 Node* n1 = graph.NewNode(&dummy_operator); |
183 Node* n2 = graph.NewNode(&dummy_operator); | 187 Node* n2 = graph.NewNode(&dummy_operator); |
184 Node* n3 = graph.NewNode(&dummy_operator, n0, n1, n2); | 188 Node* n3 = graph.NewNode(&dummy_operator, n0, n1, n2); |
185 Node* n4 = graph.NewNode(&dummy_operator); | 189 Node* n4 = graph.NewNode(&dummy_operator); |
186 | 190 |
187 CHECK_USES(n0, n3); | 191 CHECK_USES(n0, n3); |
188 CHECK_USES(n1, n3); | 192 CHECK_USES(n1, n3); |
189 CHECK_USES(n2, n3); | 193 CHECK_USES(n2, n3); |
190 CHECK_USES(n3, NONE); | 194 CHECK_USES(n3, NONE); |
191 CHECK_USES(n4, NONE); | 195 CHECK_USES(n4, NONE); |
192 | 196 |
193 CHECK_INPUTS(n3, n0, n1, n2); | 197 CHECK_INPUTS(n3, n0, n1, n2); |
194 | 198 |
195 n3->ReplaceInput(1, n4); | 199 n3->ReplaceInput(1, n4); |
196 | 200 |
197 CHECK_USES(n1, NONE); | 201 CHECK_USES(n1, NONE); |
198 CHECK_USES(n4, n3); | 202 CHECK_USES(n4, n3); |
199 | 203 |
200 CHECK_INPUTS(n3, n0, n4, n2); | 204 CHECK_INPUTS(n3, n0, n4, n2); |
201 } | 205 } |
202 | 206 |
203 | 207 |
204 TEST(OwnedBy) { | 208 TEST(OwnedBy) { |
205 GraphTester graph; | 209 Zone zone; |
| 210 Graph graph(&zone); |
206 | 211 |
207 { | 212 { |
208 Node* n0 = graph.NewNode(&dummy_operator); | 213 Node* n0 = graph.NewNode(&dummy_operator); |
209 Node* n1 = graph.NewNode(&dummy_operator); | 214 Node* n1 = graph.NewNode(&dummy_operator); |
210 | 215 |
211 CHECK(!n0->OwnedBy(n1)); | 216 CHECK(!n0->OwnedBy(n1)); |
212 CHECK(!n1->OwnedBy(n0)); | 217 CHECK(!n1->OwnedBy(n0)); |
213 | 218 |
214 Node* n2 = graph.NewNode(&dummy_operator, n0); | 219 Node* n2 = graph.NewNode(&dummy_operator, n0); |
215 CHECK(n0->OwnedBy(n2)); | 220 CHECK(n0->OwnedBy(n2)); |
(...skipping 28 matching lines...) Expand all Loading... |
244 CHECK(!n1->OwnedBy(n2)); | 249 CHECK(!n1->OwnedBy(n2)); |
245 CHECK(!n2->OwnedBy(n0)); | 250 CHECK(!n2->OwnedBy(n0)); |
246 CHECK(!n2->OwnedBy(n1)); | 251 CHECK(!n2->OwnedBy(n1)); |
247 CHECK(n3->OwnedBy(n2)); | 252 CHECK(n3->OwnedBy(n2)); |
248 CHECK(!n2->OwnedBy(n3)); | 253 CHECK(!n2->OwnedBy(n3)); |
249 } | 254 } |
250 } | 255 } |
251 | 256 |
252 | 257 |
253 TEST(Uses) { | 258 TEST(Uses) { |
254 GraphTester graph; | 259 Zone zone; |
| 260 Graph graph(&zone); |
255 | 261 |
256 Node* n0 = graph.NewNode(&dummy_operator); | 262 Node* n0 = graph.NewNode(&dummy_operator); |
257 Node* n1 = graph.NewNode(&dummy_operator, n0); | 263 Node* n1 = graph.NewNode(&dummy_operator, n0); |
258 | 264 |
259 CHECK_USES(n0, n1); | 265 CHECK_USES(n0, n1); |
260 CHECK_USES(n1, NONE); | 266 CHECK_USES(n1, NONE); |
261 | 267 |
262 Node* n2 = graph.NewNode(&dummy_operator, n0); | 268 Node* n2 = graph.NewNode(&dummy_operator, n0); |
263 | 269 |
264 CHECK_USES(n0, n1, n2); | 270 CHECK_USES(n0, n1, n2); |
265 CHECK_USES(n2, NONE); | 271 CHECK_USES(n2, NONE); |
266 | 272 |
267 Node* n3 = graph.NewNode(&dummy_operator, n0); | 273 Node* n3 = graph.NewNode(&dummy_operator, n0); |
268 | 274 |
269 CHECK_USES(n0, n1, n2, n3); | 275 CHECK_USES(n0, n1, n2, n3); |
270 CHECK_USES(n3, NONE); | 276 CHECK_USES(n3, NONE); |
271 } | 277 } |
272 | 278 |
273 | 279 |
274 TEST(Inputs) { | 280 TEST(Inputs) { |
275 GraphTester graph; | 281 Zone zone; |
| 282 Graph graph(&zone); |
276 | 283 |
277 Node* n0 = graph.NewNode(&dummy_operator); | 284 Node* n0 = graph.NewNode(&dummy_operator); |
278 Node* n1 = graph.NewNode(&dummy_operator, n0); | 285 Node* n1 = graph.NewNode(&dummy_operator, n0); |
279 Node* n2 = graph.NewNode(&dummy_operator, n0); | 286 Node* n2 = graph.NewNode(&dummy_operator, n0); |
280 Node* n3 = graph.NewNode(&dummy_operator, n0, n1, n2); | 287 Node* n3 = graph.NewNode(&dummy_operator, n0, n1, n2); |
281 | 288 |
282 CHECK_INPUTS(n3, n0, n1, n2); | 289 CHECK_INPUTS(n3, n0, n1, n2); |
283 | 290 |
284 Node* n4 = graph.NewNode(&dummy_operator, n0, n1, n2); | 291 Node* n4 = graph.NewNode(&dummy_operator, n0, n1, n2); |
285 n3->AppendInput(graph.zone(), n4); | 292 n3->AppendInput(graph.zone(), n4); |
286 | 293 |
287 CHECK_INPUTS(n3, n0, n1, n2, n4); | 294 CHECK_INPUTS(n3, n0, n1, n2, n4); |
288 CHECK_USES(n4, n3); | 295 CHECK_USES(n4, n3); |
289 | 296 |
290 n3->AppendInput(graph.zone(), n4); | 297 n3->AppendInput(graph.zone(), n4); |
291 | 298 |
292 CHECK_INPUTS(n3, n0, n1, n2, n4, n4); | 299 CHECK_INPUTS(n3, n0, n1, n2, n4, n4); |
293 CHECK_USES(n4, n3, n3); | 300 CHECK_USES(n4, n3, n3); |
294 | 301 |
295 Node* n5 = graph.NewNode(&dummy_operator, n4); | 302 Node* n5 = graph.NewNode(&dummy_operator, n4); |
296 | 303 |
297 CHECK_USES(n4, n3, n3, n5); | 304 CHECK_USES(n4, n3, n3, n5); |
298 } | 305 } |
299 | 306 |
300 | 307 |
301 TEST(RemoveInput) { | 308 TEST(RemoveInput) { |
302 GraphTester graph; | 309 Zone zone; |
| 310 Graph graph(&zone); |
303 | 311 |
304 Node* n0 = graph.NewNode(&dummy_operator); | 312 Node* n0 = graph.NewNode(&dummy_operator); |
305 Node* n1 = graph.NewNode(&dummy_operator, n0); | 313 Node* n1 = graph.NewNode(&dummy_operator, n0); |
306 Node* n2 = graph.NewNode(&dummy_operator, n0, n1); | 314 Node* n2 = graph.NewNode(&dummy_operator, n0, n1); |
307 | 315 |
308 CHECK_INPUTS(n0, NONE); | 316 CHECK_INPUTS(n0, NONE); |
309 CHECK_INPUTS(n1, n0); | 317 CHECK_INPUTS(n1, n0); |
310 CHECK_INPUTS(n2, n0, n1); | 318 CHECK_INPUTS(n2, n0, n1); |
311 CHECK_USES(n0, n1, n2); | 319 CHECK_USES(n0, n1, n2); |
312 | 320 |
313 n1->RemoveInput(0); | 321 n1->RemoveInput(0); |
314 CHECK_INPUTS(n1, NONE); | 322 CHECK_INPUTS(n1, NONE); |
315 CHECK_USES(n0, n2); | 323 CHECK_USES(n0, n2); |
316 | 324 |
317 n2->RemoveInput(0); | 325 n2->RemoveInput(0); |
318 CHECK_INPUTS(n2, n1); | 326 CHECK_INPUTS(n2, n1); |
319 CHECK_USES(n0, NONE); | 327 CHECK_USES(n0, NONE); |
320 CHECK_USES(n1, n2); | 328 CHECK_USES(n1, n2); |
321 | 329 |
322 n2->RemoveInput(0); | 330 n2->RemoveInput(0); |
323 CHECK_INPUTS(n2, NONE); | 331 CHECK_INPUTS(n2, NONE); |
324 CHECK_USES(n0, NONE); | 332 CHECK_USES(n0, NONE); |
325 CHECK_USES(n1, NONE); | 333 CHECK_USES(n1, NONE); |
326 CHECK_USES(n2, NONE); | 334 CHECK_USES(n2, NONE); |
327 } | 335 } |
328 | 336 |
329 | 337 |
330 TEST(AppendInputsAndIterator) { | 338 TEST(AppendInputsAndIterator) { |
331 GraphTester graph; | 339 Zone zone; |
| 340 Graph graph(&zone); |
332 | 341 |
333 Node* n0 = graph.NewNode(&dummy_operator); | 342 Node* n0 = graph.NewNode(&dummy_operator); |
334 Node* n1 = graph.NewNode(&dummy_operator, n0); | 343 Node* n1 = graph.NewNode(&dummy_operator, n0); |
335 Node* n2 = graph.NewNode(&dummy_operator, n0, n1); | 344 Node* n2 = graph.NewNode(&dummy_operator, n0, n1); |
336 | 345 |
337 CHECK_INPUTS(n0, NONE); | 346 CHECK_INPUTS(n0, NONE); |
338 CHECK_INPUTS(n1, n0); | 347 CHECK_INPUTS(n1, n0); |
339 CHECK_INPUTS(n2, n0, n1); | 348 CHECK_INPUTS(n2, n0, n1); |
340 CHECK_USES(n0, n1, n2); | 349 CHECK_USES(n0, n1, n2); |
341 | 350 |
342 Node* n3 = graph.NewNode(&dummy_operator); | 351 Node* n3 = graph.NewNode(&dummy_operator); |
343 | 352 |
344 n2->AppendInput(graph.zone(), n3); | 353 n2->AppendInput(graph.zone(), n3); |
345 | 354 |
346 CHECK_INPUTS(n2, n0, n1, n3); | 355 CHECK_INPUTS(n2, n0, n1, n3); |
347 CHECK_USES(n3, n2); | 356 CHECK_USES(n3, n2); |
348 } | 357 } |
349 | 358 |
350 | 359 |
351 TEST(NullInputsSimple) { | 360 TEST(NullInputsSimple) { |
352 GraphTester graph; | 361 Zone zone; |
| 362 Graph graph(&zone); |
353 | 363 |
354 Node* n0 = graph.NewNode(&dummy_operator); | 364 Node* n0 = graph.NewNode(&dummy_operator); |
355 Node* n1 = graph.NewNode(&dummy_operator, n0); | 365 Node* n1 = graph.NewNode(&dummy_operator, n0); |
356 Node* n2 = graph.NewNode(&dummy_operator, n0, n1); | 366 Node* n2 = graph.NewNode(&dummy_operator, n0, n1); |
357 | 367 |
358 CHECK_INPUTS(n0, NONE); | 368 CHECK_INPUTS(n0, NONE); |
359 CHECK_INPUTS(n1, n0); | 369 CHECK_INPUTS(n1, n0); |
360 CHECK_INPUTS(n2, n0, n1); | 370 CHECK_INPUTS(n2, n0, n1); |
361 CHECK_USES(n0, n1, n2); | 371 CHECK_USES(n0, n1, n2); |
362 | 372 |
363 n2->ReplaceInput(0, nullptr); | 373 n2->ReplaceInput(0, nullptr); |
364 | 374 |
365 CHECK_INPUTS(n2, NULL, n1); | 375 CHECK_INPUTS(n2, NULL, n1); |
366 | 376 |
367 CHECK_USES(n0, n1); | 377 CHECK_USES(n0, n1); |
368 | 378 |
369 n2->ReplaceInput(1, nullptr); | 379 n2->ReplaceInput(1, nullptr); |
370 | 380 |
371 CHECK_INPUTS(n2, NULL, NULL); | 381 CHECK_INPUTS(n2, NULL, NULL); |
372 | 382 |
373 CHECK_USES(n1, NONE); | 383 CHECK_USES(n1, NONE); |
374 } | 384 } |
375 | 385 |
376 | 386 |
377 TEST(NullInputsAppended) { | 387 TEST(NullInputsAppended) { |
378 GraphTester graph; | 388 Zone zone; |
| 389 Graph graph(&zone); |
379 | 390 |
380 Node* n0 = graph.NewNode(&dummy_operator); | 391 Node* n0 = graph.NewNode(&dummy_operator); |
381 Node* n1 = graph.NewNode(&dummy_operator, n0); | 392 Node* n1 = graph.NewNode(&dummy_operator, n0); |
382 Node* n2 = graph.NewNode(&dummy_operator, n0); | 393 Node* n2 = graph.NewNode(&dummy_operator, n0); |
383 Node* n3 = graph.NewNode(&dummy_operator, n0); | 394 Node* n3 = graph.NewNode(&dummy_operator, n0); |
384 n3->AppendInput(graph.zone(), n1); | 395 n3->AppendInput(graph.zone(), n1); |
385 n3->AppendInput(graph.zone(), n2); | 396 n3->AppendInput(graph.zone(), n2); |
386 | 397 |
387 CHECK_INPUTS(n3, n0, n1, n2); | 398 CHECK_INPUTS(n3, n0, n1, n2); |
388 CHECK_USES(n0, n1, n2, n3); | 399 CHECK_USES(n0, n1, n2, n3); |
389 CHECK_USES(n1, n3); | 400 CHECK_USES(n1, n3); |
390 CHECK_USES(n2, n3); | 401 CHECK_USES(n2, n3); |
391 | 402 |
392 n3->ReplaceInput(1, NULL); | 403 n3->ReplaceInput(1, NULL); |
393 CHECK_USES(n1, NONE); | 404 CHECK_USES(n1, NONE); |
394 | 405 |
395 CHECK_INPUTS(n3, n0, NULL, n2); | 406 CHECK_INPUTS(n3, n0, NULL, n2); |
396 } | 407 } |
397 | 408 |
398 | 409 |
399 TEST(ReplaceUsesFromAppendedInputs) { | 410 TEST(ReplaceUsesFromAppendedInputs) { |
400 GraphTester graph; | 411 Zone zone; |
| 412 Graph graph(&zone); |
401 | 413 |
402 Node* n0 = graph.NewNode(&dummy_operator); | 414 Node* n0 = graph.NewNode(&dummy_operator); |
403 Node* n1 = graph.NewNode(&dummy_operator, n0); | 415 Node* n1 = graph.NewNode(&dummy_operator, n0); |
404 Node* n2 = graph.NewNode(&dummy_operator, n0); | 416 Node* n2 = graph.NewNode(&dummy_operator, n0); |
405 Node* n3 = graph.NewNode(&dummy_operator); | 417 Node* n3 = graph.NewNode(&dummy_operator); |
406 | 418 |
407 CHECK_INPUTS(n2, n0); | 419 CHECK_INPUTS(n2, n0); |
408 | 420 |
409 n2->AppendInput(graph.zone(), n1); | 421 n2->AppendInput(graph.zone(), n1); |
410 CHECK_INPUTS(n2, n0, n1); | 422 CHECK_INPUTS(n2, n0, n1); |
411 CHECK_USES(n1, n2); | 423 CHECK_USES(n1, n2); |
412 | 424 |
413 n2->AppendInput(graph.zone(), n0); | 425 n2->AppendInput(graph.zone(), n0); |
414 CHECK_INPUTS(n2, n0, n1, n0); | 426 CHECK_INPUTS(n2, n0, n1, n0); |
415 CHECK_USES(n1, n2); | 427 CHECK_USES(n1, n2); |
416 CHECK_USES(n0, n2, n1, n2); | 428 CHECK_USES(n0, n2, n1, n2); |
417 | 429 |
418 n0->ReplaceUses(n3); | 430 n0->ReplaceUses(n3); |
419 | 431 |
420 CHECK_USES(n0, NONE); | 432 CHECK_USES(n0, NONE); |
421 CHECK_INPUTS(n2, n3, n1, n3); | 433 CHECK_INPUTS(n2, n3, n1, n3); |
422 CHECK_USES(n3, n2, n1, n2); | 434 CHECK_USES(n3, n2, n1, n2); |
423 } | 435 } |
424 | 436 |
425 | 437 |
426 TEST(ReplaceInputMultipleUses) { | 438 TEST(ReplaceInputMultipleUses) { |
427 GraphTester graph; | 439 Zone zone; |
| 440 Graph graph(&zone); |
428 | 441 |
429 Node* n0 = graph.NewNode(&dummy_operator); | 442 Node* n0 = graph.NewNode(&dummy_operator); |
430 Node* n1 = graph.NewNode(&dummy_operator); | 443 Node* n1 = graph.NewNode(&dummy_operator); |
431 Node* n2 = graph.NewNode(&dummy_operator, n0); | 444 Node* n2 = graph.NewNode(&dummy_operator, n0); |
432 n2->ReplaceInput(0, n1); | 445 n2->ReplaceInput(0, n1); |
433 CHECK_EQ(0, n0->UseCount()); | 446 CHECK_EQ(0, n0->UseCount()); |
434 CHECK_EQ(1, n1->UseCount()); | 447 CHECK_EQ(1, n1->UseCount()); |
435 | 448 |
436 Node* n3 = graph.NewNode(&dummy_operator, n0); | 449 Node* n3 = graph.NewNode(&dummy_operator, n0); |
437 n3->ReplaceInput(0, n1); | 450 n3->ReplaceInput(0, n1); |
438 CHECK_EQ(0, n0->UseCount()); | 451 CHECK_EQ(0, n0->UseCount()); |
439 CHECK_EQ(2, n1->UseCount()); | 452 CHECK_EQ(2, n1->UseCount()); |
440 } | 453 } |
441 | 454 |
442 | 455 |
443 TEST(TrimInputCountInline) { | 456 TEST(TrimInputCountInline) { |
444 GraphTester graph; | 457 Zone zone; |
| 458 Graph graph(&zone); |
445 | 459 |
446 { | 460 { |
447 Node* n0 = graph.NewNode(&dummy_operator); | 461 Node* n0 = graph.NewNode(&dummy_operator); |
448 Node* n1 = graph.NewNode(&dummy_operator, n0); | 462 Node* n1 = graph.NewNode(&dummy_operator, n0); |
449 n1->TrimInputCount(1); | 463 n1->TrimInputCount(1); |
450 CHECK_INPUTS(n1, n0); | 464 CHECK_INPUTS(n1, n0); |
451 CHECK_USES(n0, n1); | 465 CHECK_USES(n0, n1); |
452 } | 466 } |
453 | 467 |
454 { | 468 { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 Node* n0 = graph.NewNode(&dummy_operator); | 515 Node* n0 = graph.NewNode(&dummy_operator); |
502 Node* n2 = graph.NewNode(&dummy_operator, n0, n0); | 516 Node* n2 = graph.NewNode(&dummy_operator, n0, n0); |
503 n2->TrimInputCount(0); | 517 n2->TrimInputCount(0); |
504 CHECK_INPUTS(n2, NONE); | 518 CHECK_INPUTS(n2, NONE); |
505 CHECK_USES(n0, NONE); | 519 CHECK_USES(n0, NONE); |
506 } | 520 } |
507 } | 521 } |
508 | 522 |
509 | 523 |
510 TEST(TrimInputCountOutOfLine1) { | 524 TEST(TrimInputCountOutOfLine1) { |
511 GraphTester graph; | 525 Zone zone; |
| 526 Graph graph(&zone); |
512 | 527 |
513 { | 528 { |
514 Node* n0 = graph.NewNode(&dummy_operator); | 529 Node* n0 = graph.NewNode(&dummy_operator); |
515 Node* n1 = graph.NewNode(&dummy_operator); | 530 Node* n1 = graph.NewNode(&dummy_operator); |
516 n1->AppendInput(graph.zone(), n0); | 531 n1->AppendInput(graph.zone(), n0); |
517 CHECK_INPUTS(n1, n0); | 532 CHECK_INPUTS(n1, n0); |
518 CHECK_USES(n0, n1); | 533 CHECK_USES(n0, n1); |
519 | 534 |
520 n1->TrimInputCount(1); | 535 n1->TrimInputCount(1); |
521 CHECK_INPUTS(n1, n0); | 536 CHECK_INPUTS(n1, n0); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 CHECK_INPUTS(n2, n0, n0); | 609 CHECK_INPUTS(n2, n0, n0); |
595 CHECK_USES(n0, n2, n2); | 610 CHECK_USES(n0, n2, n2); |
596 n2->TrimInputCount(0); | 611 n2->TrimInputCount(0); |
597 CHECK_INPUTS(n2, NONE); | 612 CHECK_INPUTS(n2, NONE); |
598 CHECK_USES(n0, NONE); | 613 CHECK_USES(n0, NONE); |
599 } | 614 } |
600 } | 615 } |
601 | 616 |
602 | 617 |
603 TEST(TrimInputCountOutOfLine2) { | 618 TEST(TrimInputCountOutOfLine2) { |
604 GraphTester graph; | 619 Zone zone; |
| 620 Graph graph(&zone); |
605 | 621 |
606 { | 622 { |
607 Node* n0 = graph.NewNode(&dummy_operator); | 623 Node* n0 = graph.NewNode(&dummy_operator); |
608 Node* n1 = graph.NewNode(&dummy_operator); | 624 Node* n1 = graph.NewNode(&dummy_operator); |
609 Node* n2 = graph.NewNode(&dummy_operator, n0); | 625 Node* n2 = graph.NewNode(&dummy_operator, n0); |
610 n2->AppendInput(graph.zone(), n1); | 626 n2->AppendInput(graph.zone(), n1); |
611 CHECK_INPUTS(n2, n0, n1); | 627 CHECK_INPUTS(n2, n0, n1); |
612 n2->TrimInputCount(2); | 628 n2->TrimInputCount(2); |
613 CHECK_INPUTS(n2, n0, n1); | 629 CHECK_INPUTS(n2, n0, n1); |
614 CHECK_USES(n0, n2); | 630 CHECK_USES(n0, n2); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 CHECK_EQ(2, n0->UseCount()); | 678 CHECK_EQ(2, n0->UseCount()); |
663 n2->TrimInputCount(0); | 679 n2->TrimInputCount(0); |
664 CHECK_EQ(0, n2->InputCount()); | 680 CHECK_EQ(0, n2->InputCount()); |
665 CHECK_EQ(0, n0->UseCount()); | 681 CHECK_EQ(0, n0->UseCount()); |
666 CHECK_EQ(0, n2->UseCount()); | 682 CHECK_EQ(0, n2->UseCount()); |
667 } | 683 } |
668 } | 684 } |
669 | 685 |
670 | 686 |
671 TEST(NullAllInputs) { | 687 TEST(NullAllInputs) { |
672 GraphTester graph; | 688 Zone zone; |
| 689 Graph graph(&zone); |
673 | 690 |
674 for (int i = 0; i < 2; i++) { | 691 for (int i = 0; i < 2; i++) { |
675 Node* n0 = graph.NewNode(&dummy_operator); | 692 Node* n0 = graph.NewNode(&dummy_operator); |
676 Node* n1 = graph.NewNode(&dummy_operator, n0); | 693 Node* n1 = graph.NewNode(&dummy_operator, n0); |
677 Node* n2; | 694 Node* n2; |
678 if (i == 0) { | 695 if (i == 0) { |
679 n2 = graph.NewNode(&dummy_operator, n0, n1); | 696 n2 = graph.NewNode(&dummy_operator, n0, n1); |
680 CHECK_INPUTS(n2, n0, n1); | 697 CHECK_INPUTS(n2, n0, n1); |
681 } else { | 698 } else { |
682 n2 = graph.NewNode(&dummy_operator, n0); | 699 n2 = graph.NewNode(&dummy_operator, n0); |
(...skipping 30 matching lines...) Expand all Loading... |
713 | 730 |
714 CHECK_INPUTS(n0, NONE); | 731 CHECK_INPUTS(n0, NONE); |
715 CHECK_INPUTS(n1, NULL); | 732 CHECK_INPUTS(n1, NULL); |
716 CHECK_USES(n0, NONE); | 733 CHECK_USES(n0, NONE); |
717 CHECK_USES(n1, NONE); | 734 CHECK_USES(n1, NONE); |
718 } | 735 } |
719 } | 736 } |
720 | 737 |
721 | 738 |
722 TEST(AppendAndTrim) { | 739 TEST(AppendAndTrim) { |
723 GraphTester graph; | 740 Zone zone; |
| 741 Graph graph(&zone); |
724 | 742 |
725 Node* nodes[] = { | 743 Node* nodes[] = { |
726 graph.NewNode(&dummy_operator), graph.NewNode(&dummy_operator), | 744 graph.NewNode(&dummy_operator), graph.NewNode(&dummy_operator), |
727 graph.NewNode(&dummy_operator), graph.NewNode(&dummy_operator), | 745 graph.NewNode(&dummy_operator), graph.NewNode(&dummy_operator), |
728 graph.NewNode(&dummy_operator)}; | 746 graph.NewNode(&dummy_operator)}; |
729 | 747 |
730 int max = static_cast<int>(arraysize(nodes)); | 748 int max = static_cast<int>(arraysize(nodes)); |
731 | 749 |
732 Node* last = graph.NewNode(&dummy_operator); | 750 Node* last = graph.NewNode(&dummy_operator); |
733 | 751 |
(...skipping 14 matching lines...) Expand all Loading... |
748 CheckInputs(last, nodes, i); | 766 CheckInputs(last, nodes, i); |
749 | 767 |
750 for (int j = 0; j < i; j++) { | 768 for (int j = 0; j < i; j++) { |
751 if (j < i) CHECK_USES(nodes[j], last); | 769 if (j < i) CHECK_USES(nodes[j], last); |
752 if (j >= i) CHECK_USES(nodes[j], NONE); | 770 if (j >= i) CHECK_USES(nodes[j], NONE); |
753 } | 771 } |
754 | 772 |
755 CHECK_USES(last, NONE); | 773 CHECK_USES(last, NONE); |
756 } | 774 } |
757 } | 775 } |
OLD | NEW |