Chromium Code Reviews| 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 "vm/pages.h" | 5 #include "vm/pages.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/compiler_stats.h" | 8 #include "vm/compiler_stats.h" |
| 9 #include "vm/gc_marker.h" | 9 #include "vm/gc_marker.h" |
| 10 #include "vm/gc_sweeper.h" | 10 #include "vm/gc_sweeper.h" |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 528 while (current_page != NULL) { | 528 while (current_page != NULL) { |
| 529 if (current_page->type() == HeapPage::kExecutable) { | 529 if (current_page->type() == HeapPage::kExecutable) { |
| 530 current_page->WriteProtect(false); | 530 current_page->WriteProtect(false); |
| 531 } | 531 } |
| 532 current_page = current_page->next(); | 532 current_page = current_page->next(); |
| 533 } | 533 } |
| 534 } | 534 } |
| 535 | 535 |
| 536 // Save old value before GCMarker visits the weak persistent handles. | 536 // Save old value before GCMarker visits the weak persistent handles. |
| 537 SpaceUsage usage_before = usage_; | 537 SpaceUsage usage_before = usage_; |
| 538 usage_.used_in_words = 0; | 538 usage_.used_in_words = 0; |
|
koda
2014/04/24 23:09:56
This should be redundant now; remove.
Ivan Posva
2014/04/24 23:17:50
Done.
| |
| 539 | 539 |
| 540 // Mark all reachable old-gen objects. | 540 // Mark all reachable old-gen objects. |
| 541 bool collect_code = FLAG_collect_code && ShouldCollectCode(); | 541 bool collect_code = FLAG_collect_code && ShouldCollectCode(); |
| 542 GCMarker marker(heap_); | 542 GCMarker marker(heap_); |
| 543 marker.MarkObjects(isolate, this, invoke_api_callbacks, collect_code); | 543 marker.MarkObjects(isolate, this, invoke_api_callbacks, collect_code); |
| 544 usage_.used_in_words = marker.marked_words(); | |
| 544 | 545 |
| 545 int64_t mid1 = OS::GetCurrentTimeMicros(); | 546 int64_t mid1 = OS::GetCurrentTimeMicros(); |
| 546 | 547 |
| 547 // Reset the bump allocation page to unused. | 548 // Reset the bump allocation page to unused. |
| 548 // Reset the freelists and setup sweeping. | 549 // Reset the freelists and setup sweeping. |
| 549 freelist_[HeapPage::kData].Reset(); | 550 freelist_[HeapPage::kData].Reset(); |
| 550 freelist_[HeapPage::kExecutable].Reset(); | 551 freelist_[HeapPage::kExecutable].Reset(); |
| 551 | 552 |
| 552 int64_t mid2 = OS::GetCurrentTimeMicros(); | 553 int64_t mid2 = OS::GetCurrentTimeMicros(); |
| 553 | 554 |
| 554 GCSweeper sweeper(heap_); | 555 GCSweeper sweeper(heap_); |
| 555 | 556 |
| 556 HeapPage* prev_page = NULL; | 557 HeapPage* prev_page = NULL; |
| 557 HeapPage* page = pages_; | 558 HeapPage* page = pages_; |
| 558 while (page != NULL) { | 559 while (page != NULL) { |
| 559 HeapPage* next_page = page->next(); | 560 HeapPage* next_page = page->next(); |
| 560 intptr_t page_in_use = sweeper.SweepPage(page, &freelist_[page->type()]); | 561 if (sweeper.SweepPage(page, &freelist_[page->type()])) { |
|
koda
2014/04/24 23:09:56
Consider helping the reader remember what the retu
Ivan Posva
2014/04/24 23:17:50
Done.
| |
| 561 if (page_in_use == 0) { | 562 prev_page = page; |
| 563 } else { | |
| 562 FreePage(page, prev_page); | 564 FreePage(page, prev_page); |
| 563 } else { | |
| 564 usage_.used_in_words += (page_in_use >> kWordSizeLog2); | |
| 565 prev_page = page; | |
| 566 } | 565 } |
| 567 // Advance to the next page. | 566 // Advance to the next page. |
| 568 page = next_page; | 567 page = next_page; |
| 569 } | 568 } |
| 570 | 569 |
| 571 int64_t mid3 = OS::GetCurrentTimeMicros(); | 570 int64_t mid3 = OS::GetCurrentTimeMicros(); |
| 572 | 571 |
| 573 prev_page = NULL; | 572 prev_page = NULL; |
| 574 page = large_pages_; | 573 page = large_pages_; |
| 575 while (page != NULL) { | 574 while (page != NULL) { |
| 576 intptr_t page_in_use = sweeper.SweepLargePage(page); | |
| 577 HeapPage* next_page = page->next(); | 575 HeapPage* next_page = page->next(); |
| 578 if (page_in_use == 0) { | 576 if (sweeper.SweepLargePage(page)) { |
| 577 prev_page = page; | |
| 578 } else { | |
| 579 FreeLargePage(page, prev_page); | 579 FreeLargePage(page, prev_page); |
| 580 } else { | |
| 581 usage_.used_in_words += (page_in_use >> kWordSizeLog2); | |
| 582 prev_page = page; | |
| 583 } | 580 } |
| 584 // Advance to the next page. | 581 // Advance to the next page. |
| 585 page = next_page; | 582 page = next_page; |
| 586 } | 583 } |
| 587 | 584 |
| 588 if (FLAG_write_protect_code) { | 585 if (FLAG_write_protect_code) { |
| 589 // Make code pages read-only. | 586 // Make code pages read-only. |
| 590 HeapPage* current_page = pages_; | 587 HeapPage* current_page = pages_; |
| 591 while (current_page != NULL) { | 588 while (current_page != NULL) { |
| 592 if (current_page->type() == HeapPage::kExecutable) { | 589 if (current_page->type() == HeapPage::kExecutable) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 return 0; | 735 return 0; |
| 739 } else { | 736 } else { |
| 740 ASSERT(total_time >= gc_time); | 737 ASSERT(total_time >= gc_time); |
| 741 int result= static_cast<int>((static_cast<double>(gc_time) / | 738 int result= static_cast<int>((static_cast<double>(gc_time) / |
| 742 static_cast<double>(total_time)) * 100); | 739 static_cast<double>(total_time)) * 100); |
| 743 return result; | 740 return result; |
| 744 } | 741 } |
| 745 } | 742 } |
| 746 | 743 |
| 747 } // namespace dart | 744 } // namespace dart |
| OLD | NEW |