Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(976)

Side by Side Diff: runtime/vm/pages.cc

Issue 1292353004: Safepointing in GC (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: More git cleanup. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/gc_sweeper.cc ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 ASSERT(isolate == Isolate::Current()); 761 ASSERT(isolate == Isolate::Current());
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 }
771 // Ensure that all threads for this isolate are at a safepoint (either stopped
772 // or in native code). If two threads are racing at this point, the loser
773 // will continue with its collection after waiting for the winner to complete.
774 // TODO(koda): Consider moving SafepointThreads into allocation failure/retry
775 // logic to avoid needless collections.
776 isolate->thread_registry()->SafepointThreads();
770 777
771 // Perform various cleanup that relies on no tasks interfering. 778 // Perform various cleanup that relies on no tasks interfering.
772 isolate->class_table()->FreeOldTables(); 779 isolate->class_table()->FreeOldTables();
773 780
774 NoSafepointScope no_safepoints; 781 NoSafepointScope no_safepoints;
775 782
776 if (FLAG_print_free_list_before_gc) { 783 if (FLAG_print_free_list_before_gc) {
777 OS::Print("Data Freelist (before GC):\n"); 784 OS::Print("Data Freelist (before GC):\n");
778 freelist_[HeapPage::kData].Print(); 785 freelist_[HeapPage::kData].Print();
779 OS::Print("Executable Freelist (before GC):\n"); 786 OS::Print("Executable Freelist (before GC):\n");
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 heap_->RecordTime(kSweepPages, mid3 - mid2); 907 heap_->RecordTime(kSweepPages, mid3 - mid2);
901 heap_->RecordTime(kSweepLargePages, end - mid3); 908 heap_->RecordTime(kSweepLargePages, end - mid3);
902 909
903 if (FLAG_print_free_list_after_gc) { 910 if (FLAG_print_free_list_after_gc) {
904 OS::Print("Data Freelist (after GC):\n"); 911 OS::Print("Data Freelist (after GC):\n");
905 freelist_[HeapPage::kData].Print(); 912 freelist_[HeapPage::kData].Print();
906 OS::Print("Executable Freelist (after GC):\n"); 913 OS::Print("Executable Freelist (after GC):\n");
907 freelist_[HeapPage::kExecutable].Print(); 914 freelist_[HeapPage::kExecutable].Print();
908 } 915 }
909 916
917 isolate->thread_registry()->ResumeAllThreads();
918
910 // Done, reset the task count. 919 // Done, reset the task count.
911 { 920 {
912 MonitorLocker ml(tasks_lock()); 921 MonitorLocker ml(tasks_lock());
913 set_tasks(tasks() - 1); 922 set_tasks(tasks() - 1);
914 ml.Notify(); 923 ml.Notify();
915 } 924 }
916 } 925 }
917 926
918 927
919 uword PageSpace::TryAllocateDataBumpInternal(intptr_t size, 928 uword PageSpace::TryAllocateDataBumpInternal(intptr_t size,
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 return 0; 1147 return 0;
1139 } else { 1148 } else {
1140 ASSERT(total_time >= gc_time); 1149 ASSERT(total_time >= gc_time);
1141 int result = static_cast<int>((static_cast<double>(gc_time) / 1150 int result = static_cast<int>((static_cast<double>(gc_time) /
1142 static_cast<double>(total_time)) * 100); 1151 static_cast<double>(total_time)) * 100);
1143 return result; 1152 return result;
1144 } 1153 }
1145 } 1154 }
1146 1155
1147 } // namespace dart 1156 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/gc_sweeper.cc ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698