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

Side by Side Diff: test/cctest/compiler/test-node.cc

Issue 1847543002: Expose a lower bound of malloc'd memory via heap statistics (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 8 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
OLDNEW
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/compiler/graph.h" 7 #include "src/compiler/graph.h"
8 #include "src/compiler/node.h" 8 #include "src/compiler/node.h"
9 #include "src/compiler/operator.h" 9 #include "src/compiler/operator.h"
10 #include "test/cctest/cctest.h" 10 #include "test/cctest/cctest.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 #define CHECK_INPUTS(node, ...) \ 134 #define CHECK_INPUTS(node, ...) \
135 do { \ 135 do { \
136 Node* __array[] = {__VA_ARGS__}; \ 136 Node* __array[] = {__VA_ARGS__}; \
137 int __size = \ 137 int __size = \
138 __array[0] != NONE ? static_cast<int>(arraysize(__array)) : 0; \ 138 __array[0] != NONE ? static_cast<int>(arraysize(__array)) : 0; \
139 CheckInputs(node, __array, __size); \ 139 CheckInputs(node, __array, __size); \
140 } while (false) 140 } while (false)
141 141
142 142
143 TEST(NodeUseIteratorReplaceUses) { 143 TEST(NodeUseIteratorReplaceUses) {
144 Zone zone; 144 base::AccountingAllocator allocator;
145 Zone zone(&allocator);
145 Graph graph(&zone); 146 Graph graph(&zone);
146 Node* n0 = graph.NewNode(&dummy_operator0); 147 Node* n0 = graph.NewNode(&dummy_operator0);
147 Node* n1 = graph.NewNode(&dummy_operator1, n0); 148 Node* n1 = graph.NewNode(&dummy_operator1, n0);
148 Node* n2 = graph.NewNode(&dummy_operator1, n0); 149 Node* n2 = graph.NewNode(&dummy_operator1, n0);
149 Node* n3 = graph.NewNode(&dummy_operator0); 150 Node* n3 = graph.NewNode(&dummy_operator0);
150 151
151 CHECK_USES(n0, n1, n2); 152 CHECK_USES(n0, n1, n2);
152 153
153 CHECK_INPUTS(n1, n0); 154 CHECK_INPUTS(n1, n0);
154 CHECK_INPUTS(n2, n0); 155 CHECK_INPUTS(n2, n0);
155 156
156 n0->ReplaceUses(n3); 157 n0->ReplaceUses(n3);
157 158
158 CHECK_USES(n0, NONE); 159 CHECK_USES(n0, NONE);
159 CHECK_USES(n1, NONE); 160 CHECK_USES(n1, NONE);
160 CHECK_USES(n2, NONE); 161 CHECK_USES(n2, NONE);
161 CHECK_USES(n3, n1, n2); 162 CHECK_USES(n3, n1, n2);
162 163
163 CHECK_INPUTS(n1, n3); 164 CHECK_INPUTS(n1, n3);
164 CHECK_INPUTS(n2, n3); 165 CHECK_INPUTS(n2, n3);
165 } 166 }
166 167
167 168
168 TEST(NodeUseIteratorReplaceUsesSelf) { 169 TEST(NodeUseIteratorReplaceUsesSelf) {
169 Zone zone; 170 base::AccountingAllocator allocator;
171 Zone zone(&allocator);
170 Graph graph(&zone); 172 Graph graph(&zone);
171 Node* n0 = graph.NewNode(&dummy_operator0); 173 Node* n0 = graph.NewNode(&dummy_operator0);
172 Node* n1 = graph.NewNode(&dummy_operator1, n0); 174 Node* n1 = graph.NewNode(&dummy_operator1, n0);
173 175
174 CHECK_USES(n0, n1); 176 CHECK_USES(n0, n1);
175 CHECK_USES(n1, NONE); 177 CHECK_USES(n1, NONE);
176 178
177 n1->ReplaceInput(0, n1); // Create self-reference. 179 n1->ReplaceInput(0, n1); // Create self-reference.
178 180
179 CHECK_USES(n0, NONE); 181 CHECK_USES(n0, NONE);
180 CHECK_USES(n1, n1); 182 CHECK_USES(n1, n1);
181 183
182 Node* n2 = graph.NewNode(&dummy_operator0); 184 Node* n2 = graph.NewNode(&dummy_operator0);
183 185
184 n1->ReplaceUses(n2); 186 n1->ReplaceUses(n2);
185 187
186 CHECK_USES(n0, NONE); 188 CHECK_USES(n0, NONE);
187 CHECK_USES(n1, NONE); 189 CHECK_USES(n1, NONE);
188 CHECK_USES(n2, n1); 190 CHECK_USES(n2, n1);
189 } 191 }
190 192
191 193
192 TEST(ReplaceInput) { 194 TEST(ReplaceInput) {
193 Zone zone; 195 base::AccountingAllocator allocator;
196 Zone zone(&allocator);
194 Graph graph(&zone); 197 Graph graph(&zone);
195 Node* n0 = graph.NewNode(&dummy_operator0); 198 Node* n0 = graph.NewNode(&dummy_operator0);
196 Node* n1 = graph.NewNode(&dummy_operator0); 199 Node* n1 = graph.NewNode(&dummy_operator0);
197 Node* n2 = graph.NewNode(&dummy_operator0); 200 Node* n2 = graph.NewNode(&dummy_operator0);
198 Node* n3 = graph.NewNode(&dummy_operator3, n0, n1, n2); 201 Node* n3 = graph.NewNode(&dummy_operator3, n0, n1, n2);
199 Node* n4 = graph.NewNode(&dummy_operator0); 202 Node* n4 = graph.NewNode(&dummy_operator0);
200 203
201 CHECK_USES(n0, n3); 204 CHECK_USES(n0, n3);
202 CHECK_USES(n1, n3); 205 CHECK_USES(n1, n3);
203 CHECK_USES(n2, n3); 206 CHECK_USES(n2, n3);
204 CHECK_USES(n3, NONE); 207 CHECK_USES(n3, NONE);
205 CHECK_USES(n4, NONE); 208 CHECK_USES(n4, NONE);
206 209
207 CHECK_INPUTS(n3, n0, n1, n2); 210 CHECK_INPUTS(n3, n0, n1, n2);
208 211
209 n3->ReplaceInput(1, n4); 212 n3->ReplaceInput(1, n4);
210 213
211 CHECK_USES(n1, NONE); 214 CHECK_USES(n1, NONE);
212 CHECK_USES(n4, n3); 215 CHECK_USES(n4, n3);
213 216
214 CHECK_INPUTS(n3, n0, n4, n2); 217 CHECK_INPUTS(n3, n0, n4, n2);
215 } 218 }
216 219
217 220
218 TEST(OwnedBy) { 221 TEST(OwnedBy) {
219 Zone zone; 222 base::AccountingAllocator allocator;
223 Zone zone(&allocator);
220 Graph graph(&zone); 224 Graph graph(&zone);
221 225
222 { 226 {
223 Node* n0 = graph.NewNode(&dummy_operator0); 227 Node* n0 = graph.NewNode(&dummy_operator0);
224 Node* n1 = graph.NewNode(&dummy_operator0); 228 Node* n1 = graph.NewNode(&dummy_operator0);
225 229
226 CHECK(!n0->OwnedBy(n1)); 230 CHECK(!n0->OwnedBy(n1));
227 CHECK(!n1->OwnedBy(n0)); 231 CHECK(!n1->OwnedBy(n0));
228 232
229 Node* n2 = graph.NewNode(&dummy_operator1, n0); 233 Node* n2 = graph.NewNode(&dummy_operator1, n0);
(...skipping 29 matching lines...) Expand all
259 CHECK(!n1->OwnedBy(n2)); 263 CHECK(!n1->OwnedBy(n2));
260 CHECK(!n2->OwnedBy(n0)); 264 CHECK(!n2->OwnedBy(n0));
261 CHECK(!n2->OwnedBy(n1)); 265 CHECK(!n2->OwnedBy(n1));
262 CHECK(n3->OwnedBy(n2)); 266 CHECK(n3->OwnedBy(n2));
263 CHECK(!n2->OwnedBy(n3)); 267 CHECK(!n2->OwnedBy(n3));
264 } 268 }
265 } 269 }
266 270
267 271
268 TEST(Uses) { 272 TEST(Uses) {
269 Zone zone; 273 base::AccountingAllocator allocator;
274 Zone zone(&allocator);
270 Graph graph(&zone); 275 Graph graph(&zone);
271 276
272 Node* n0 = graph.NewNode(&dummy_operator0); 277 Node* n0 = graph.NewNode(&dummy_operator0);
273 Node* n1 = graph.NewNode(&dummy_operator1, n0); 278 Node* n1 = graph.NewNode(&dummy_operator1, n0);
274 279
275 CHECK_USES(n0, n1); 280 CHECK_USES(n0, n1);
276 CHECK_USES(n1, NONE); 281 CHECK_USES(n1, NONE);
277 282
278 Node* n2 = graph.NewNode(&dummy_operator1, n0); 283 Node* n2 = graph.NewNode(&dummy_operator1, n0);
279 284
280 CHECK_USES(n0, n1, n2); 285 CHECK_USES(n0, n1, n2);
281 CHECK_USES(n2, NONE); 286 CHECK_USES(n2, NONE);
282 287
283 Node* n3 = graph.NewNode(&dummy_operator1, n0); 288 Node* n3 = graph.NewNode(&dummy_operator1, n0);
284 289
285 CHECK_USES(n0, n1, n2, n3); 290 CHECK_USES(n0, n1, n2, n3);
286 CHECK_USES(n3, NONE); 291 CHECK_USES(n3, NONE);
287 } 292 }
288 293
289 294
290 TEST(Inputs) { 295 TEST(Inputs) {
291 Zone zone; 296 base::AccountingAllocator allocator;
297 Zone zone(&allocator);
292 Graph graph(&zone); 298 Graph graph(&zone);
293 299
294 Node* n0 = graph.NewNode(&dummy_operator0); 300 Node* n0 = graph.NewNode(&dummy_operator0);
295 Node* n1 = graph.NewNode(&dummy_operator1, n0); 301 Node* n1 = graph.NewNode(&dummy_operator1, n0);
296 Node* n2 = graph.NewNode(&dummy_operator1, n0); 302 Node* n2 = graph.NewNode(&dummy_operator1, n0);
297 Node* n3 = graph.NewNode(&dummy_operator3, n0, n1, n2); 303 Node* n3 = graph.NewNode(&dummy_operator3, n0, n1, n2);
298 304
299 CHECK_INPUTS(n3, n0, n1, n2); 305 CHECK_INPUTS(n3, n0, n1, n2);
300 306
301 Node* n4 = graph.NewNode(&dummy_operator3, n0, n1, n2); 307 Node* n4 = graph.NewNode(&dummy_operator3, n0, n1, n2);
302 n3->AppendInput(graph.zone(), n4); 308 n3->AppendInput(graph.zone(), n4);
303 309
304 CHECK_INPUTS(n3, n0, n1, n2, n4); 310 CHECK_INPUTS(n3, n0, n1, n2, n4);
305 CHECK_USES(n4, n3); 311 CHECK_USES(n4, n3);
306 312
307 n3->AppendInput(graph.zone(), n4); 313 n3->AppendInput(graph.zone(), n4);
308 314
309 CHECK_INPUTS(n3, n0, n1, n2, n4, n4); 315 CHECK_INPUTS(n3, n0, n1, n2, n4, n4);
310 CHECK_USES(n4, n3, n3); 316 CHECK_USES(n4, n3, n3);
311 317
312 Node* n5 = graph.NewNode(&dummy_operator1, n4); 318 Node* n5 = graph.NewNode(&dummy_operator1, n4);
313 319
314 CHECK_USES(n4, n3, n3, n5); 320 CHECK_USES(n4, n3, n3, n5);
315 } 321 }
316 322
317 323
318 TEST(RemoveInput) { 324 TEST(RemoveInput) {
319 Zone zone; 325 base::AccountingAllocator allocator;
326 Zone zone(&allocator);
320 Graph graph(&zone); 327 Graph graph(&zone);
321 328
322 Node* n0 = graph.NewNode(&dummy_operator0); 329 Node* n0 = graph.NewNode(&dummy_operator0);
323 Node* n1 = graph.NewNode(&dummy_operator1, n0); 330 Node* n1 = graph.NewNode(&dummy_operator1, n0);
324 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1); 331 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1);
325 332
326 CHECK_INPUTS(n0, NONE); 333 CHECK_INPUTS(n0, NONE);
327 CHECK_INPUTS(n1, n0); 334 CHECK_INPUTS(n1, n0);
328 CHECK_INPUTS(n2, n0, n1); 335 CHECK_INPUTS(n2, n0, n1);
329 CHECK_USES(n0, n1, n2); 336 CHECK_USES(n0, n1, n2);
330 337
331 n1->RemoveInput(0); 338 n1->RemoveInput(0);
332 CHECK_INPUTS(n1, NONE); 339 CHECK_INPUTS(n1, NONE);
333 CHECK_USES(n0, n2); 340 CHECK_USES(n0, n2);
334 341
335 n2->RemoveInput(0); 342 n2->RemoveInput(0);
336 CHECK_INPUTS(n2, n1); 343 CHECK_INPUTS(n2, n1);
337 CHECK_USES(n0, NONE); 344 CHECK_USES(n0, NONE);
338 CHECK_USES(n1, n2); 345 CHECK_USES(n1, n2);
339 346
340 n2->RemoveInput(0); 347 n2->RemoveInput(0);
341 CHECK_INPUTS(n2, NONE); 348 CHECK_INPUTS(n2, NONE);
342 CHECK_USES(n0, NONE); 349 CHECK_USES(n0, NONE);
343 CHECK_USES(n1, NONE); 350 CHECK_USES(n1, NONE);
344 CHECK_USES(n2, NONE); 351 CHECK_USES(n2, NONE);
345 } 352 }
346 353
347 354
348 TEST(AppendInputsAndIterator) { 355 TEST(AppendInputsAndIterator) {
349 Zone zone; 356 base::AccountingAllocator allocator;
357 Zone zone(&allocator);
350 Graph graph(&zone); 358 Graph graph(&zone);
351 359
352 Node* n0 = graph.NewNode(&dummy_operator0); 360 Node* n0 = graph.NewNode(&dummy_operator0);
353 Node* n1 = graph.NewNode(&dummy_operator1, n0); 361 Node* n1 = graph.NewNode(&dummy_operator1, n0);
354 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1); 362 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1);
355 363
356 CHECK_INPUTS(n0, NONE); 364 CHECK_INPUTS(n0, NONE);
357 CHECK_INPUTS(n1, n0); 365 CHECK_INPUTS(n1, n0);
358 CHECK_INPUTS(n2, n0, n1); 366 CHECK_INPUTS(n2, n0, n1);
359 CHECK_USES(n0, n1, n2); 367 CHECK_USES(n0, n1, n2);
360 368
361 Node* n3 = graph.NewNode(&dummy_operator0); 369 Node* n3 = graph.NewNode(&dummy_operator0);
362 370
363 n2->AppendInput(graph.zone(), n3); 371 n2->AppendInput(graph.zone(), n3);
364 372
365 CHECK_INPUTS(n2, n0, n1, n3); 373 CHECK_INPUTS(n2, n0, n1, n3);
366 CHECK_USES(n3, n2); 374 CHECK_USES(n3, n2);
367 } 375 }
368 376
369 377
370 TEST(NullInputsSimple) { 378 TEST(NullInputsSimple) {
371 Zone zone; 379 base::AccountingAllocator allocator;
380 Zone zone(&allocator);
372 Graph graph(&zone); 381 Graph graph(&zone);
373 382
374 Node* n0 = graph.NewNode(&dummy_operator0); 383 Node* n0 = graph.NewNode(&dummy_operator0);
375 Node* n1 = graph.NewNode(&dummy_operator1, n0); 384 Node* n1 = graph.NewNode(&dummy_operator1, n0);
376 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1); 385 Node* n2 = graph.NewNode(&dummy_operator2, n0, n1);
377 386
378 CHECK_INPUTS(n0, NONE); 387 CHECK_INPUTS(n0, NONE);
379 CHECK_INPUTS(n1, n0); 388 CHECK_INPUTS(n1, n0);
380 CHECK_INPUTS(n2, n0, n1); 389 CHECK_INPUTS(n2, n0, n1);
381 CHECK_USES(n0, n1, n2); 390 CHECK_USES(n0, n1, n2);
382 391
383 n2->ReplaceInput(0, nullptr); 392 n2->ReplaceInput(0, nullptr);
384 393
385 CHECK_INPUTS(n2, NULL, n1); 394 CHECK_INPUTS(n2, NULL, n1);
386 395
387 CHECK_USES(n0, n1); 396 CHECK_USES(n0, n1);
388 397
389 n2->ReplaceInput(1, nullptr); 398 n2->ReplaceInput(1, nullptr);
390 399
391 CHECK_INPUTS(n2, NULL, NULL); 400 CHECK_INPUTS(n2, NULL, NULL);
392 401
393 CHECK_USES(n1, NONE); 402 CHECK_USES(n1, NONE);
394 } 403 }
395 404
396 405
397 TEST(NullInputsAppended) { 406 TEST(NullInputsAppended) {
398 Zone zone; 407 base::AccountingAllocator allocator;
408 Zone zone(&allocator);
399 Graph graph(&zone); 409 Graph graph(&zone);
400 410
401 Node* n0 = graph.NewNode(&dummy_operator0); 411 Node* n0 = graph.NewNode(&dummy_operator0);
402 Node* n1 = graph.NewNode(&dummy_operator1, n0); 412 Node* n1 = graph.NewNode(&dummy_operator1, n0);
403 Node* n2 = graph.NewNode(&dummy_operator1, n0); 413 Node* n2 = graph.NewNode(&dummy_operator1, n0);
404 Node* n3 = graph.NewNode(&dummy_operator1, n0); 414 Node* n3 = graph.NewNode(&dummy_operator1, n0);
405 n3->AppendInput(graph.zone(), n1); 415 n3->AppendInput(graph.zone(), n1);
406 n3->AppendInput(graph.zone(), n2); 416 n3->AppendInput(graph.zone(), n2);
407 417
408 CHECK_INPUTS(n3, n0, n1, n2); 418 CHECK_INPUTS(n3, n0, n1, n2);
409 CHECK_USES(n0, n1, n2, n3); 419 CHECK_USES(n0, n1, n2, n3);
410 CHECK_USES(n1, n3); 420 CHECK_USES(n1, n3);
411 CHECK_USES(n2, n3); 421 CHECK_USES(n2, n3);
412 422
413 n3->ReplaceInput(1, NULL); 423 n3->ReplaceInput(1, NULL);
414 CHECK_USES(n1, NONE); 424 CHECK_USES(n1, NONE);
415 425
416 CHECK_INPUTS(n3, n0, NULL, n2); 426 CHECK_INPUTS(n3, n0, NULL, n2);
417 } 427 }
418 428
419 429
420 TEST(ReplaceUsesFromAppendedInputs) { 430 TEST(ReplaceUsesFromAppendedInputs) {
421 Zone zone; 431 base::AccountingAllocator allocator;
432 Zone zone(&allocator);
422 Graph graph(&zone); 433 Graph graph(&zone);
423 434
424 Node* n0 = graph.NewNode(&dummy_operator0); 435 Node* n0 = graph.NewNode(&dummy_operator0);
425 Node* n1 = graph.NewNode(&dummy_operator1, n0); 436 Node* n1 = graph.NewNode(&dummy_operator1, n0);
426 Node* n2 = graph.NewNode(&dummy_operator1, n0); 437 Node* n2 = graph.NewNode(&dummy_operator1, n0);
427 Node* n3 = graph.NewNode(&dummy_operator0); 438 Node* n3 = graph.NewNode(&dummy_operator0);
428 439
429 CHECK_INPUTS(n2, n0); 440 CHECK_INPUTS(n2, n0);
430 441
431 n2->AppendInput(graph.zone(), n1); 442 n2->AppendInput(graph.zone(), n1);
432 CHECK_INPUTS(n2, n0, n1); 443 CHECK_INPUTS(n2, n0, n1);
433 CHECK_USES(n1, n2); 444 CHECK_USES(n1, n2);
434 445
435 n2->AppendInput(graph.zone(), n0); 446 n2->AppendInput(graph.zone(), n0);
436 CHECK_INPUTS(n2, n0, n1, n0); 447 CHECK_INPUTS(n2, n0, n1, n0);
437 CHECK_USES(n1, n2); 448 CHECK_USES(n1, n2);
438 CHECK_USES(n0, n2, n1, n2); 449 CHECK_USES(n0, n2, n1, n2);
439 450
440 n0->ReplaceUses(n3); 451 n0->ReplaceUses(n3);
441 452
442 CHECK_USES(n0, NONE); 453 CHECK_USES(n0, NONE);
443 CHECK_INPUTS(n2, n3, n1, n3); 454 CHECK_INPUTS(n2, n3, n1, n3);
444 CHECK_USES(n3, n2, n1, n2); 455 CHECK_USES(n3, n2, n1, n2);
445 } 456 }
446 457
447 458
448 TEST(ReplaceInputMultipleUses) { 459 TEST(ReplaceInputMultipleUses) {
449 Zone zone; 460 base::AccountingAllocator allocator;
461 Zone zone(&allocator);
450 Graph graph(&zone); 462 Graph graph(&zone);
451 463
452 Node* n0 = graph.NewNode(&dummy_operator0); 464 Node* n0 = graph.NewNode(&dummy_operator0);
453 Node* n1 = graph.NewNode(&dummy_operator0); 465 Node* n1 = graph.NewNode(&dummy_operator0);
454 Node* n2 = graph.NewNode(&dummy_operator1, n0); 466 Node* n2 = graph.NewNode(&dummy_operator1, n0);
455 n2->ReplaceInput(0, n1); 467 n2->ReplaceInput(0, n1);
456 CHECK_EQ(0, n0->UseCount()); 468 CHECK_EQ(0, n0->UseCount());
457 CHECK_EQ(1, n1->UseCount()); 469 CHECK_EQ(1, n1->UseCount());
458 470
459 Node* n3 = graph.NewNode(&dummy_operator1, n0); 471 Node* n3 = graph.NewNode(&dummy_operator1, n0);
460 n3->ReplaceInput(0, n1); 472 n3->ReplaceInput(0, n1);
461 CHECK_EQ(0, n0->UseCount()); 473 CHECK_EQ(0, n0->UseCount());
462 CHECK_EQ(2, n1->UseCount()); 474 CHECK_EQ(2, n1->UseCount());
463 } 475 }
464 476
465 477
466 TEST(TrimInputCountInline) { 478 TEST(TrimInputCountInline) {
467 Zone zone; 479 base::AccountingAllocator allocator;
480 Zone zone(&allocator);
468 Graph graph(&zone); 481 Graph graph(&zone);
469 482
470 { 483 {
471 Node* n0 = graph.NewNode(&dummy_operator0); 484 Node* n0 = graph.NewNode(&dummy_operator0);
472 Node* n1 = graph.NewNode(&dummy_operator1, n0); 485 Node* n1 = graph.NewNode(&dummy_operator1, n0);
473 n1->TrimInputCount(1); 486 n1->TrimInputCount(1);
474 CHECK_INPUTS(n1, n0); 487 CHECK_INPUTS(n1, n0);
475 CHECK_USES(n0, n1); 488 CHECK_USES(n0, n1);
476 } 489 }
477 490
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 Node* n0 = graph.NewNode(&dummy_operator0); 538 Node* n0 = graph.NewNode(&dummy_operator0);
526 Node* n2 = graph.NewNode(&dummy_operator2, n0, n0); 539 Node* n2 = graph.NewNode(&dummy_operator2, n0, n0);
527 n2->TrimInputCount(0); 540 n2->TrimInputCount(0);
528 CHECK_INPUTS(n2, NONE); 541 CHECK_INPUTS(n2, NONE);
529 CHECK_USES(n0, NONE); 542 CHECK_USES(n0, NONE);
530 } 543 }
531 } 544 }
532 545
533 546
534 TEST(TrimInputCountOutOfLine1) { 547 TEST(TrimInputCountOutOfLine1) {
535 Zone zone; 548 base::AccountingAllocator allocator;
549 Zone zone(&allocator);
536 Graph graph(&zone); 550 Graph graph(&zone);
537 551
538 { 552 {
539 Node* n0 = graph.NewNode(&dummy_operator0); 553 Node* n0 = graph.NewNode(&dummy_operator0);
540 Node* n1 = graph.NewNode(&dummy_operator0); 554 Node* n1 = graph.NewNode(&dummy_operator0);
541 n1->AppendInput(graph.zone(), n0); 555 n1->AppendInput(graph.zone(), n0);
542 CHECK_INPUTS(n1, n0); 556 CHECK_INPUTS(n1, n0);
543 CHECK_USES(n0, n1); 557 CHECK_USES(n0, n1);
544 558
545 n1->TrimInputCount(1); 559 n1->TrimInputCount(1);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 CHECK_INPUTS(n2, n0, n0); 633 CHECK_INPUTS(n2, n0, n0);
620 CHECK_USES(n0, n2, n2); 634 CHECK_USES(n0, n2, n2);
621 n2->TrimInputCount(0); 635 n2->TrimInputCount(0);
622 CHECK_INPUTS(n2, NONE); 636 CHECK_INPUTS(n2, NONE);
623 CHECK_USES(n0, NONE); 637 CHECK_USES(n0, NONE);
624 } 638 }
625 } 639 }
626 640
627 641
628 TEST(TrimInputCountOutOfLine2) { 642 TEST(TrimInputCountOutOfLine2) {
629 Zone zone; 643 base::AccountingAllocator allocator;
644 Zone zone(&allocator);
630 Graph graph(&zone); 645 Graph graph(&zone);
631 646
632 { 647 {
633 Node* n0 = graph.NewNode(&dummy_operator0); 648 Node* n0 = graph.NewNode(&dummy_operator0);
634 Node* n1 = graph.NewNode(&dummy_operator0); 649 Node* n1 = graph.NewNode(&dummy_operator0);
635 Node* n2 = graph.NewNode(&dummy_operator1, n0); 650 Node* n2 = graph.NewNode(&dummy_operator1, n0);
636 n2->AppendInput(graph.zone(), n1); 651 n2->AppendInput(graph.zone(), n1);
637 CHECK_INPUTS(n2, n0, n1); 652 CHECK_INPUTS(n2, n0, n1);
638 n2->TrimInputCount(2); 653 n2->TrimInputCount(2);
639 CHECK_INPUTS(n2, n0, n1); 654 CHECK_INPUTS(n2, n0, n1);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 CHECK_EQ(2, n0->UseCount()); 703 CHECK_EQ(2, n0->UseCount());
689 n2->TrimInputCount(0); 704 n2->TrimInputCount(0);
690 CHECK_EQ(0, n2->InputCount()); 705 CHECK_EQ(0, n2->InputCount());
691 CHECK_EQ(0, n0->UseCount()); 706 CHECK_EQ(0, n0->UseCount());
692 CHECK_EQ(0, n2->UseCount()); 707 CHECK_EQ(0, n2->UseCount());
693 } 708 }
694 } 709 }
695 710
696 711
697 TEST(NullAllInputs) { 712 TEST(NullAllInputs) {
698 Zone zone; 713 base::AccountingAllocator allocator;
714 Zone zone(&allocator);
699 Graph graph(&zone); 715 Graph graph(&zone);
700 716
701 for (int i = 0; i < 2; i++) { 717 for (int i = 0; i < 2; i++) {
702 Node* n0 = graph.NewNode(&dummy_operator0); 718 Node* n0 = graph.NewNode(&dummy_operator0);
703 Node* n1 = graph.NewNode(&dummy_operator1, n0); 719 Node* n1 = graph.NewNode(&dummy_operator1, n0);
704 Node* n2; 720 Node* n2;
705 if (i == 0) { 721 if (i == 0) {
706 n2 = graph.NewNode(&dummy_operator2, n0, n1); 722 n2 = graph.NewNode(&dummy_operator2, n0, n1);
707 CHECK_INPUTS(n2, n0, n1); 723 CHECK_INPUTS(n2, n0, n1);
708 } else { 724 } else {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 756
741 CHECK_INPUTS(n0, NONE); 757 CHECK_INPUTS(n0, NONE);
742 CHECK_INPUTS(n1, NULL); 758 CHECK_INPUTS(n1, NULL);
743 CHECK_USES(n0, NONE); 759 CHECK_USES(n0, NONE);
744 CHECK_USES(n1, NONE); 760 CHECK_USES(n1, NONE);
745 } 761 }
746 } 762 }
747 763
748 764
749 TEST(AppendAndTrim) { 765 TEST(AppendAndTrim) {
750 Zone zone; 766 base::AccountingAllocator allocator;
767 Zone zone(&allocator);
751 Graph graph(&zone); 768 Graph graph(&zone);
752 769
753 Node* nodes[] = { 770 Node* nodes[] = {
754 graph.NewNode(&dummy_operator0), graph.NewNode(&dummy_operator0), 771 graph.NewNode(&dummy_operator0), graph.NewNode(&dummy_operator0),
755 graph.NewNode(&dummy_operator0), graph.NewNode(&dummy_operator0), 772 graph.NewNode(&dummy_operator0), graph.NewNode(&dummy_operator0),
756 graph.NewNode(&dummy_operator0)}; 773 graph.NewNode(&dummy_operator0)};
757 774
758 int max = static_cast<int>(arraysize(nodes)); 775 int max = static_cast<int>(arraysize(nodes));
759 776
760 Node* last = graph.NewNode(&dummy_operator0); 777 Node* last = graph.NewNode(&dummy_operator0);
(...skipping 19 matching lines...) Expand all
780 if (j >= i) CHECK_USES(nodes[j], NONE); 797 if (j >= i) CHECK_USES(nodes[j], NONE);
781 } 798 }
782 799
783 CHECK_USES(last, NONE); 800 CHECK_USES(last, NONE);
784 } 801 }
785 } 802 }
786 803
787 } // namespace compiler 804 } // namespace compiler
788 } // namespace internal 805 } // namespace internal
789 } // namespace v8 806 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-multiple-return.cc ('k') | test/cctest/compiler/test-run-native-calls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698