| 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; | |
| 539 | 538 |
| 540 // Mark all reachable old-gen objects. | 539 // Mark all reachable old-gen objects. |
| 541 bool collect_code = FLAG_collect_code && ShouldCollectCode(); | 540 bool collect_code = FLAG_collect_code && ShouldCollectCode(); |
| 542 GCMarker marker(heap_); | 541 GCMarker marker(heap_); |
| 543 marker.MarkObjects(isolate, this, invoke_api_callbacks, collect_code); | 542 marker.MarkObjects(isolate, this, invoke_api_callbacks, collect_code); |
| 543 usage_.used_in_words = marker.marked_words(); |
| 544 | 544 |
| 545 int64_t mid1 = OS::GetCurrentTimeMicros(); | 545 int64_t mid1 = OS::GetCurrentTimeMicros(); |
| 546 | 546 |
| 547 // Reset the bump allocation page to unused. | 547 // Reset the bump allocation page to unused. |
| 548 // Reset the freelists and setup sweeping. | 548 // Reset the freelists and setup sweeping. |
| 549 freelist_[HeapPage::kData].Reset(); | 549 freelist_[HeapPage::kData].Reset(); |
| 550 freelist_[HeapPage::kExecutable].Reset(); | 550 freelist_[HeapPage::kExecutable].Reset(); |
| 551 | 551 |
| 552 int64_t mid2 = OS::GetCurrentTimeMicros(); | 552 int64_t mid2 = OS::GetCurrentTimeMicros(); |
| 553 | 553 |
| 554 GCSweeper sweeper(heap_); | 554 GCSweeper sweeper(heap_); |
| 555 | 555 |
| 556 HeapPage* prev_page = NULL; | 556 HeapPage* prev_page = NULL; |
| 557 HeapPage* page = pages_; | 557 HeapPage* page = pages_; |
| 558 while (page != NULL) { | 558 while (page != NULL) { |
| 559 HeapPage* next_page = page->next(); | 559 HeapPage* next_page = page->next(); |
| 560 intptr_t page_in_use = sweeper.SweepPage(page, &freelist_[page->type()]); | 560 bool page_in_use = sweeper.SweepPage(page, &freelist_[page->type()]); |
| 561 if (page_in_use == 0) { | 561 if (page_in_use) { |
| 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 bool page_in_use = sweeper.SweepLargePage(page); |
| 577 if (page_in_use) { |
| 578 prev_page = page; |
| 579 } else { |
| 579 FreeLargePage(page, prev_page); | 580 FreeLargePage(page, prev_page); |
| 580 } else { | |
| 581 usage_.used_in_words += (page_in_use >> kWordSizeLog2); | |
| 582 prev_page = page; | |
| 583 } | 581 } |
| 584 // Advance to the next page. | 582 // Advance to the next page. |
| 585 page = next_page; | 583 page = next_page; |
| 586 } | 584 } |
| 587 | 585 |
| 588 if (FLAG_write_protect_code) { | 586 if (FLAG_write_protect_code) { |
| 589 // Make code pages read-only. | 587 // Make code pages read-only. |
| 590 HeapPage* current_page = pages_; | 588 HeapPage* current_page = pages_; |
| 591 while (current_page != NULL) { | 589 while (current_page != NULL) { |
| 592 if (current_page->type() == HeapPage::kExecutable) { | 590 if (current_page->type() == HeapPage::kExecutable) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 return 0; | 736 return 0; |
| 739 } else { | 737 } else { |
| 740 ASSERT(total_time >= gc_time); | 738 ASSERT(total_time >= gc_time); |
| 741 int result= static_cast<int>((static_cast<double>(gc_time) / | 739 int result= static_cast<int>((static_cast<double>(gc_time) / |
| 742 static_cast<double>(total_time)) * 100); | 740 static_cast<double>(total_time)) * 100); |
| 743 return result; | 741 return result; |
| 744 } | 742 } |
| 745 } | 743 } |
| 746 | 744 |
| 747 } // namespace dart | 745 } // namespace dart |
| OLD | NEW |