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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 usage_.used_in_words = marker.marked_words(); | 558 usage_.used_in_words = marker.marked_words(); |
| 559 | 559 |
| 560 int64_t mid1 = OS::GetCurrentTimeMicros(); | 560 int64_t mid1 = OS::GetCurrentTimeMicros(); |
| 561 | 561 |
| 562 // Reset the bump allocation page to unused. | 562 // Reset the bump allocation page to unused. |
| 563 // Reset the freelists and setup sweeping. | 563 // Reset the freelists and setup sweeping. |
| 564 freelist_[HeapPage::kData].Reset(); | 564 freelist_[HeapPage::kData].Reset(); |
| 565 freelist_[HeapPage::kExecutable].Reset(); | 565 freelist_[HeapPage::kExecutable].Reset(); |
| 566 | 566 |
| 567 int64_t mid2 = OS::GetCurrentTimeMicros(); | 567 int64_t mid2 = OS::GetCurrentTimeMicros(); |
| 568 int64_t mid3 = 0; | |
| 568 | 569 |
| 569 GCSweeper sweeper(heap_); | 570 GCSweeper sweeper(heap_); |
| 570 | 571 |
| 571 HeapPage* prev_page = NULL; | 572 // During stop-the-world phases we should use bulk lock when adding elements |
| 572 HeapPage* page = pages_; | 573 // to the free list. |
| 573 while (page != NULL) { | 574 { |
| 574 HeapPage* next_page = page->next(); | 575 MutexLocker mld(freelist_[HeapPage::kData].mutex()); |
| 575 bool page_in_use = sweeper.SweepPage(page, &freelist_[page->type()]); | 576 MutexLocker mle(freelist_[HeapPage::kExecutable].mutex()); |
| 576 if (page_in_use) { | 577 |
| 577 prev_page = page; | 578 HeapPage* prev_page = NULL; |
| 578 } else { | 579 HeapPage* page = pages_; |
| 579 FreePage(page, prev_page); | 580 while (page != NULL) { |
| 581 HeapPage* next_page = page->next(); | |
| 582 bool page_in_use = sweeper.SweepPage(page, &freelist_[page->type()]); | |
| 583 if (page_in_use) { | |
| 584 prev_page = page; | |
| 585 } else { | |
| 586 FreePage(page, prev_page); | |
| 587 } | |
| 588 // Advance to the next page. | |
| 589 page = next_page; | |
| 580 } | 590 } |
| 581 // Advance to the next page. | |
| 582 page = next_page; | |
| 583 } | |
| 584 | 591 |
| 585 int64_t mid3 = OS::GetCurrentTimeMicros(); | 592 mid3 = OS::GetCurrentTimeMicros(); |
| 586 | 593 |
| 587 prev_page = NULL; | 594 prev_page = NULL; |
| 588 page = large_pages_; | 595 page = large_pages_; |
| 589 while (page != NULL) { | 596 while (page != NULL) { |
| 590 HeapPage* next_page = page->next(); | 597 HeapPage* next_page = page->next(); |
| 591 const intptr_t words_to_end = sweeper.SweepLargePage(page); | 598 const intptr_t words_to_end = sweeper.SweepLargePage(page); |
| 592 if (words_to_end == 0) { | 599 if (words_to_end == 0) { |
| 593 FreeLargePage(page, prev_page); | 600 FreeLargePage(page, prev_page); |
| 594 } else { | 601 } else { |
| 595 TruncateLargePage(page, words_to_end << kWordSizeLog2); | 602 TruncateLargePage(page, words_to_end << kWordSizeLog2); |
| 596 prev_page = page; | 603 prev_page = page; |
| 604 } | |
| 605 // Advance to the next page. | |
| 606 page = next_page; | |
| 597 } | 607 } |
| 598 // Advance to the next page. | |
| 599 page = next_page; | |
| 600 } | 608 } |
|
koda
2014/08/20 13:52:22
For a large scope like this, it might help readabi
Ivan Posva
2014/08/20 14:10:20
In my experience commenting here is counter-produc
koda
2014/08/20 16:11:19
In any case, keeping method bodies within a reason
| |
| 601 | 609 |
| 602 // Make code pages read-only. | 610 // Make code pages read-only. |
| 603 WriteProtectCode(true); | 611 WriteProtectCode(true); |
| 604 | 612 |
| 605 int64_t end = OS::GetCurrentTimeMicros(); | 613 int64_t end = OS::GetCurrentTimeMicros(); |
| 606 | 614 |
| 607 // Record signals for growth control. Include size of external allocations. | 615 // Record signals for growth control. Include size of external allocations. |
| 608 page_space_controller_.EvaluateGarbageCollection(usage_before, usage_, | 616 page_space_controller_.EvaluateGarbageCollection(usage_before, usage_, |
| 609 start, end); | 617 start, end); |
| 610 | 618 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 return 0; | 757 return 0; |
| 750 } else { | 758 } else { |
| 751 ASSERT(total_time >= gc_time); | 759 ASSERT(total_time >= gc_time); |
| 752 int result= static_cast<int>((static_cast<double>(gc_time) / | 760 int result= static_cast<int>((static_cast<double>(gc_time) / |
| 753 static_cast<double>(total_time)) * 100); | 761 static_cast<double>(total_time)) * 100); |
| 754 return result; | 762 return result; |
| 755 } | 763 } |
| 756 } | 764 } |
| 757 | 765 |
| 758 } // namespace dart | 766 } // namespace dart |
| OLD | NEW |