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" |
11 #include "vm/lockers.h" | 11 #include "vm/lockers.h" |
12 #include "vm/object.h" | 12 #include "vm/object.h" |
13 #include "vm/os_thread.h" | 13 #include "vm/os_thread.h" |
| 14 #include "vm/thread_registry.h" |
14 #include "vm/verified_memory.h" | 15 #include "vm/verified_memory.h" |
15 #include "vm/virtual_memory.h" | 16 #include "vm/virtual_memory.h" |
16 | 17 |
17 namespace dart { | 18 namespace dart { |
18 | 19 |
19 DEFINE_FLAG(int, heap_growth_rate, 0, | 20 DEFINE_FLAG(int, heap_growth_rate, 0, |
20 "The max number of pages the heap can grow at a time"); | 21 "The max number of pages the heap can grow at a time"); |
21 DEFINE_FLAG(int, old_gen_growth_space_ratio, 20, | 22 DEFINE_FLAG(int, old_gen_growth_space_ratio, 20, |
22 "The desired maximum percentage of free space after old gen GC"); | 23 "The desired maximum percentage of free space after old gen GC"); |
23 DEFINE_FLAG(int, old_gen_growth_time_ratio, 3, | 24 DEFINE_FLAG(int, old_gen_growth_time_ratio, 3, |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 | 762 |
762 // Wait for pending tasks to complete and then account for the driver task. | 763 // Wait for pending tasks to complete and then account for the driver task. |
763 { | 764 { |
764 MonitorLocker locker(tasks_lock()); | 765 MonitorLocker locker(tasks_lock()); |
765 while (tasks() > 0) { | 766 while (tasks() > 0) { |
766 locker.Wait(); | 767 locker.Wait(); |
767 } | 768 } |
768 set_tasks(1); | 769 set_tasks(1); |
769 } | 770 } |
770 | 771 |
| 772 int safepoint_id = isolate->thread_registry()->SafepointThreads(); |
| 773 |
771 // Perform various cleanup that relies on no tasks interfering. | 774 // Perform various cleanup that relies on no tasks interfering. |
772 isolate->class_table()->FreeOldTables(); | 775 isolate->class_table()->FreeOldTables(); |
773 | 776 |
774 NoSafepointScope no_safepoints; | 777 NoSafepointScope no_safepoints; |
775 | 778 |
776 if (FLAG_print_free_list_before_gc) { | 779 if (FLAG_print_free_list_before_gc) { |
777 OS::Print("Data Freelist (before GC):\n"); | 780 OS::Print("Data Freelist (before GC):\n"); |
778 freelist_[HeapPage::kData].Print(); | 781 freelist_[HeapPage::kData].Print(); |
779 OS::Print("Executable Freelist (before GC):\n"); | 782 OS::Print("Executable Freelist (before GC):\n"); |
780 freelist_[HeapPage::kExecutable].Print(); | 783 freelist_[HeapPage::kExecutable].Print(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 // Advance to the next page. | 876 // Advance to the next page. |
874 page = next_page; | 877 page = next_page; |
875 } | 878 } |
876 if (FLAG_verify_after_gc) { | 879 if (FLAG_verify_after_gc) { |
877 OS::PrintErr("Verifying after sweeping..."); | 880 OS::PrintErr("Verifying after sweeping..."); |
878 heap_->VerifyGC(kForbidMarked); | 881 heap_->VerifyGC(kForbidMarked); |
879 OS::PrintErr(" done.\n"); | 882 OS::PrintErr(" done.\n"); |
880 } | 883 } |
881 } else { | 884 } else { |
882 // Start the concurrent sweeper task now. | 885 // Start the concurrent sweeper task now. |
883 GCSweeper::SweepConcurrent( | 886 GCSweeper::SweepConcurrent(isolate, pages_, pages_tail_, |
884 isolate, pages_, pages_tail_, &freelist_[HeapPage::kData]); | 887 &freelist_[HeapPage::kData], safepoint_id); |
885 } | 888 } |
886 } | 889 } |
887 | 890 |
888 // Make code pages read-only. | 891 // Make code pages read-only. |
889 WriteProtectCode(true); | 892 WriteProtectCode(true); |
890 | 893 |
891 int64_t end = OS::GetCurrentTimeMicros(); | 894 int64_t end = OS::GetCurrentTimeMicros(); |
892 | 895 |
893 // Record signals for growth control. Include size of external allocations. | 896 // Record signals for growth control. Include size of external allocations. |
894 page_space_controller_.EvaluateGarbageCollection(usage_before, | 897 page_space_controller_.EvaluateGarbageCollection(usage_before, |
895 GetCurrentUsage(), | 898 GetCurrentUsage(), |
896 start, end); | 899 start, end); |
897 | 900 |
898 heap_->RecordTime(kMarkObjects, mid1 - start); | 901 heap_->RecordTime(kMarkObjects, mid1 - start); |
899 heap_->RecordTime(kResetFreeLists, mid2 - mid1); | 902 heap_->RecordTime(kResetFreeLists, mid2 - mid1); |
900 heap_->RecordTime(kSweepPages, mid3 - mid2); | 903 heap_->RecordTime(kSweepPages, mid3 - mid2); |
901 heap_->RecordTime(kSweepLargePages, end - mid3); | 904 heap_->RecordTime(kSweepLargePages, end - mid3); |
902 | 905 |
903 if (FLAG_print_free_list_after_gc) { | 906 if (FLAG_print_free_list_after_gc) { |
904 OS::Print("Data Freelist (after GC):\n"); | 907 OS::Print("Data Freelist (after GC):\n"); |
905 freelist_[HeapPage::kData].Print(); | 908 freelist_[HeapPage::kData].Print(); |
906 OS::Print("Executable Freelist (after GC):\n"); | 909 OS::Print("Executable Freelist (after GC):\n"); |
907 freelist_[HeapPage::kExecutable].Print(); | 910 freelist_[HeapPage::kExecutable].Print(); |
908 } | 911 } |
909 | 912 |
| 913 isolate->thread_registry()->ResumeAllThreads(); // Rename |
| 914 |
910 // Done, reset the task count. | 915 // Done, reset the task count. |
911 { | 916 { |
912 MonitorLocker ml(tasks_lock()); | 917 MonitorLocker ml(tasks_lock()); |
913 set_tasks(tasks() - 1); | 918 set_tasks(tasks() - 1); |
914 ml.Notify(); | 919 ml.Notify(); |
915 } | 920 } |
916 } | 921 } |
917 | 922 |
918 | 923 |
919 uword PageSpace::TryAllocateDataBumpInternal(intptr_t size, | 924 uword PageSpace::TryAllocateDataBumpInternal(intptr_t size, |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1138 return 0; | 1143 return 0; |
1139 } else { | 1144 } else { |
1140 ASSERT(total_time >= gc_time); | 1145 ASSERT(total_time >= gc_time); |
1141 int result = static_cast<int>((static_cast<double>(gc_time) / | 1146 int result = static_cast<int>((static_cast<double>(gc_time) / |
1142 static_cast<double>(total_time)) * 100); | 1147 static_cast<double>(total_time)) * 100); |
1143 return result; | 1148 return result; |
1144 } | 1149 } |
1145 } | 1150 } |
1146 | 1151 |
1147 } // namespace dart | 1152 } // namespace dart |
OLD | NEW |