OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/become.h" | 8 #include "vm/become.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 Become::ElementsForwardIdentity(before, after); | 356 Become::ElementsForwardIdentity(before, after); |
357 | 357 |
358 EXPECT(before_obj.raw() == after_obj.raw()); | 358 EXPECT(before_obj.raw() == after_obj.raw()); |
359 EXPECT(!after_obj.raw()->IsRemembered()); | 359 EXPECT(!after_obj.raw()->IsRemembered()); |
360 | 360 |
361 heap->CollectAllGarbage(); | 361 heap->CollectAllGarbage(); |
362 | 362 |
363 EXPECT(before_obj.raw() == after_obj.raw()); | 363 EXPECT(before_obj.raw() == after_obj.raw()); |
364 } | 364 } |
365 | 365 |
| 366 |
| 367 ISOLATE_UNIT_TEST_CASE(CollectAllGarbage_DeadOldToNew) { |
| 368 Isolate* isolate = Isolate::Current(); |
| 369 Heap* heap = isolate->heap(); |
| 370 |
| 371 heap->CollectAllGarbage(); |
| 372 intptr_t size_before = |
| 373 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 374 |
| 375 Array& old = Array::Handle(Array::New(1, Heap::kOld)); |
| 376 Array& neu = Array::Handle(Array::New(1, Heap::kNew)); |
| 377 old.SetAt(0, neu); |
| 378 old = Array::null(); |
| 379 neu = Array::null(); |
| 380 |
| 381 heap->CollectAllGarbage(); |
| 382 |
| 383 intptr_t size_after = |
| 384 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 385 |
| 386 EXPECT(size_before == size_after); |
| 387 } |
| 388 |
| 389 |
| 390 ISOLATE_UNIT_TEST_CASE(CollectAllGarbage_DeadNewToOld) { |
| 391 Isolate* isolate = Isolate::Current(); |
| 392 Heap* heap = isolate->heap(); |
| 393 |
| 394 heap->CollectAllGarbage(); |
| 395 intptr_t size_before = |
| 396 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 397 |
| 398 Array& old = Array::Handle(Array::New(1, Heap::kOld)); |
| 399 Array& neu = Array::Handle(Array::New(1, Heap::kNew)); |
| 400 neu.SetAt(0, old); |
| 401 old = Array::null(); |
| 402 neu = Array::null(); |
| 403 |
| 404 heap->CollectAllGarbage(); |
| 405 |
| 406 intptr_t size_after = |
| 407 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 408 |
| 409 EXPECT(size_before == size_after); |
| 410 } |
| 411 |
| 412 |
| 413 ISOLATE_UNIT_TEST_CASE(CollectAllGarbage_DeadGenCycle) { |
| 414 Isolate* isolate = Isolate::Current(); |
| 415 Heap* heap = isolate->heap(); |
| 416 |
| 417 heap->CollectAllGarbage(); |
| 418 intptr_t size_before = |
| 419 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 420 |
| 421 Array& old = Array::Handle(Array::New(1, Heap::kOld)); |
| 422 Array& neu = Array::Handle(Array::New(1, Heap::kNew)); |
| 423 neu.SetAt(0, old); |
| 424 old.SetAt(0, neu); |
| 425 old = Array::null(); |
| 426 neu = Array::null(); |
| 427 |
| 428 heap->CollectAllGarbage(); |
| 429 |
| 430 intptr_t size_after = |
| 431 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 432 |
| 433 EXPECT(size_before == size_after); |
| 434 } |
| 435 |
| 436 |
| 437 ISOLATE_UNIT_TEST_CASE(CollectAllGarbage_LiveNewToOld) { |
| 438 Isolate* isolate = Isolate::Current(); |
| 439 Heap* heap = isolate->heap(); |
| 440 |
| 441 heap->CollectAllGarbage(); |
| 442 intptr_t size_before = |
| 443 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 444 |
| 445 Array& old = Array::Handle(Array::New(1, Heap::kOld)); |
| 446 Array& neu = Array::Handle(Array::New(1, Heap::kNew)); |
| 447 neu.SetAt(0, old); |
| 448 old = Array::null(); |
| 449 |
| 450 heap->CollectAllGarbage(); |
| 451 |
| 452 intptr_t size_after = |
| 453 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 454 |
| 455 EXPECT(size_before < size_after); |
| 456 } |
| 457 |
| 458 |
| 459 ISOLATE_UNIT_TEST_CASE(CollectAllGarbage_LiveOldToNew) { |
| 460 Isolate* isolate = Isolate::Current(); |
| 461 Heap* heap = isolate->heap(); |
| 462 |
| 463 heap->CollectAllGarbage(); |
| 464 intptr_t size_before = |
| 465 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 466 |
| 467 Array& old = Array::Handle(Array::New(1, Heap::kOld)); |
| 468 Array& neu = Array::Handle(Array::New(1, Heap::kNew)); |
| 469 old.SetAt(0, neu); |
| 470 neu = Array::null(); |
| 471 |
| 472 heap->CollectAllGarbage(); |
| 473 |
| 474 intptr_t size_after = |
| 475 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 476 |
| 477 EXPECT(size_before < size_after); |
| 478 } |
| 479 |
| 480 |
| 481 ISOLATE_UNIT_TEST_CASE(CollectAllGarbage_LiveOldDeadNew) { |
| 482 Isolate* isolate = Isolate::Current(); |
| 483 Heap* heap = isolate->heap(); |
| 484 |
| 485 heap->CollectAllGarbage(); |
| 486 intptr_t size_before = |
| 487 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 488 |
| 489 Array& old = Array::Handle(Array::New(1, Heap::kOld)); |
| 490 Array& neu = Array::Handle(Array::New(1, Heap::kNew)); |
| 491 neu = Array::null(); |
| 492 old.SetAt(0, old); |
| 493 |
| 494 heap->CollectAllGarbage(); |
| 495 |
| 496 intptr_t size_after = |
| 497 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 498 |
| 499 EXPECT(size_before < size_after); |
| 500 } |
| 501 |
| 502 |
| 503 ISOLATE_UNIT_TEST_CASE(CollectAllGarbage_LiveNewDeadOld) { |
| 504 Isolate* isolate = Isolate::Current(); |
| 505 Heap* heap = isolate->heap(); |
| 506 |
| 507 heap->CollectAllGarbage(); |
| 508 intptr_t size_before = |
| 509 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 510 |
| 511 Array& old = Array::Handle(Array::New(1, Heap::kOld)); |
| 512 Array& neu = Array::Handle(Array::New(1, Heap::kNew)); |
| 513 old = Array::null(); |
| 514 neu.SetAt(0, neu); |
| 515 |
| 516 heap->CollectAllGarbage(); |
| 517 |
| 518 intptr_t size_after = |
| 519 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 520 |
| 521 EXPECT(size_before < size_after); |
| 522 } |
| 523 |
| 524 |
| 525 ISOLATE_UNIT_TEST_CASE(CollectAllGarbage_LiveNewToOldChain) { |
| 526 Isolate* isolate = Isolate::Current(); |
| 527 Heap* heap = isolate->heap(); |
| 528 |
| 529 heap->CollectAllGarbage(); |
| 530 intptr_t size_before = |
| 531 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 532 |
| 533 Array& old = Array::Handle(Array::New(1, Heap::kOld)); |
| 534 Array& old2 = Array::Handle(Array::New(1, Heap::kOld)); |
| 535 Array& neu = Array::Handle(Array::New(1, Heap::kNew)); |
| 536 old.SetAt(0, old2); |
| 537 neu.SetAt(0, old); |
| 538 old = Array::null(); |
| 539 old2 = Array::null(); |
| 540 |
| 541 heap->CollectAllGarbage(); |
| 542 |
| 543 intptr_t size_after = |
| 544 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 545 |
| 546 EXPECT(size_before < size_after); |
| 547 } |
| 548 |
| 549 |
| 550 ISOLATE_UNIT_TEST_CASE(CollectAllGarbage_LiveOldToNewChain) { |
| 551 Isolate* isolate = Isolate::Current(); |
| 552 Heap* heap = isolate->heap(); |
| 553 |
| 554 heap->CollectAllGarbage(); |
| 555 intptr_t size_before = |
| 556 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 557 |
| 558 Array& old = Array::Handle(Array::New(1, Heap::kOld)); |
| 559 Array& neu = Array::Handle(Array::New(1, Heap::kNew)); |
| 560 Array& neu2 = Array::Handle(Array::New(1, Heap::kOld)); |
| 561 neu.SetAt(0, neu2); |
| 562 old.SetAt(0, neu); |
| 563 neu = Array::null(); |
| 564 neu2 = Array::null(); |
| 565 |
| 566 heap->CollectAllGarbage(); |
| 567 |
| 568 intptr_t size_after = |
| 569 heap->new_space()->UsedInWords() + heap->old_space()->UsedInWords(); |
| 570 |
| 571 EXPECT(size_before < size_after); |
| 572 } |
| 573 |
366 } // namespace dart | 574 } // namespace dart |
OLD | NEW |