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

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

Issue 2771013002: Add more safe points in compiler (Closed)
Patch Set: Fix test that 'parses' verbose GC output Created 3 years, 8 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/pages.h ('k') | runtime/vm/precompiler.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/address_sanitizer.h" 7 #include "platform/address_sanitizer.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/compiler_stats.h" 9 #include "vm/compiler_stats.h"
10 #include "vm/gc_marker.h" 10 #include "vm/gc_marker.h"
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 } 842 }
843 } 843 }
844 } 844 }
845 845
846 846
847 void PageSpace::MarkSweep(bool invoke_api_callbacks) { 847 void PageSpace::MarkSweep(bool invoke_api_callbacks) {
848 Thread* thread = Thread::Current(); 848 Thread* thread = Thread::Current();
849 Isolate* isolate = heap_->isolate(); 849 Isolate* isolate = heap_->isolate();
850 ASSERT(isolate == Isolate::Current()); 850 ASSERT(isolate == Isolate::Current());
851 851
852 const int64_t pre_wait_for_sweepers = OS::GetCurrentMonotonicMicros();
853
852 // Wait for pending tasks to complete and then account for the driver task. 854 // Wait for pending tasks to complete and then account for the driver task.
853 { 855 {
854 MonitorLocker locker(tasks_lock()); 856 MonitorLocker locker(tasks_lock());
855 while (tasks() > 0) { 857 while (tasks() > 0) {
856 locker.WaitWithSafepointCheck(thread); 858 locker.WaitWithSafepointCheck(thread);
857 } 859 }
858 set_tasks(1); 860 set_tasks(1);
859 } 861 }
862
863 const int64_t pre_safe_point = OS::GetCurrentMonotonicMicros();
864
860 // Ensure that all threads for this isolate are at a safepoint (either 865 // Ensure that all threads for this isolate are at a safepoint (either
861 // stopped or in native code). We have guards around Newgen GC and oldgen GC 866 // stopped or in native code). We have guards around Newgen GC and oldgen GC
862 // to ensure that if two threads are racing to collect at the same time the 867 // to ensure that if two threads are racing to collect at the same time the
863 // loser skips collection and goes straight to allocation. 868 // loser skips collection and goes straight to allocation.
864 { 869 {
865 SafepointOperationScope safepoint_scope(thread); 870 SafepointOperationScope safepoint_scope(thread);
866 871
872 const int64_t start = OS::GetCurrentMonotonicMicros();
873
867 // Perform various cleanup that relies on no tasks interfering. 874 // Perform various cleanup that relies on no tasks interfering.
868 isolate->class_table()->FreeOldTables(); 875 isolate->class_table()->FreeOldTables();
869 876
870 NoSafepointScope no_safepoints; 877 NoSafepointScope no_safepoints;
871 878
872 if (FLAG_print_free_list_before_gc) { 879 if (FLAG_print_free_list_before_gc) {
873 OS::Print("Data Freelist (before GC):\n"); 880 OS::Print("Data Freelist (before GC):\n");
874 freelist_[HeapPage::kData].Print(); 881 freelist_[HeapPage::kData].Print();
875 OS::Print("Executable Freelist (before GC):\n"); 882 OS::Print("Executable Freelist (before GC):\n");
876 freelist_[HeapPage::kExecutable].Print(); 883 freelist_[HeapPage::kExecutable].Print();
877 } 884 }
878 885
879 if (FLAG_verify_before_gc) { 886 if (FLAG_verify_before_gc) {
880 OS::PrintErr("Verifying before marking..."); 887 OS::PrintErr("Verifying before marking...");
881 heap_->VerifyGC(); 888 heap_->VerifyGC();
882 OS::PrintErr(" done.\n"); 889 OS::PrintErr(" done.\n");
883 } 890 }
884 891
885 const int64_t start = OS::GetCurrentMonotonicMicros();
886
887 // Make code pages writable. 892 // Make code pages writable.
888 WriteProtectCode(false); 893 WriteProtectCode(false);
889 894
890 // Save old value before GCMarker visits the weak persistent handles. 895 // Save old value before GCMarker visits the weak persistent handles.
891 SpaceUsage usage_before = GetCurrentUsage(); 896 SpaceUsage usage_before = GetCurrentUsage();
892 897
893 // Mark all reachable old-gen objects. 898 // Mark all reachable old-gen objects.
894 bool collect_code = FLAG_collect_code && ShouldCollectCode() && 899 bool collect_code = FLAG_collect_code && ShouldCollectCode() &&
895 !isolate->HasAttemptedReload(); 900 !isolate->HasAttemptedReload();
896 GCMarker marker(heap_); 901 GCMarker marker(heap_);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 989
985 // Make code pages read-only. 990 // Make code pages read-only.
986 WriteProtectCode(true); 991 WriteProtectCode(true);
987 992
988 int64_t end = OS::GetCurrentMonotonicMicros(); 993 int64_t end = OS::GetCurrentMonotonicMicros();
989 994
990 // Record signals for growth control. Include size of external allocations. 995 // Record signals for growth control. Include size of external allocations.
991 page_space_controller_.EvaluateGarbageCollection( 996 page_space_controller_.EvaluateGarbageCollection(
992 usage_before, GetCurrentUsage(), start, end); 997 usage_before, GetCurrentUsage(), start, end);
993 998
999 heap_->RecordTime(kConcurrentSweep, pre_safe_point - pre_wait_for_sweepers);
1000 heap_->RecordTime(kSafePoint, start - pre_safe_point);
994 heap_->RecordTime(kMarkObjects, mid1 - start); 1001 heap_->RecordTime(kMarkObjects, mid1 - start);
995 heap_->RecordTime(kResetFreeLists, mid2 - mid1); 1002 heap_->RecordTime(kResetFreeLists, mid2 - mid1);
996 heap_->RecordTime(kSweepPages, mid3 - mid2); 1003 heap_->RecordTime(kSweepPages, mid3 - mid2);
997 heap_->RecordTime(kSweepLargePages, end - mid3); 1004 heap_->RecordTime(kSweepLargePages, end - mid3);
998 1005
999 if (FLAG_print_free_list_after_gc) { 1006 if (FLAG_print_free_list_after_gc) {
1000 OS::Print("Data Freelist (after GC):\n"); 1007 OS::Print("Data Freelist (after GC):\n");
1001 freelist_[HeapPage::kData].Print(); 1008 freelist_[HeapPage::kData].Print();
1002 OS::Print("Executable Freelist (after GC):\n"); 1009 OS::Print("Executable Freelist (after GC):\n");
1003 freelist_[HeapPage::kExecutable].Print(); 1010 freelist_[HeapPage::kExecutable].Print();
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1295 return 0; 1302 return 0;
1296 } else { 1303 } else {
1297 ASSERT(total_time >= gc_time); 1304 ASSERT(total_time >= gc_time);
1298 int result = static_cast<int>( 1305 int result = static_cast<int>(
1299 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100); 1306 (static_cast<double>(gc_time) / static_cast<double>(total_time)) * 100);
1300 return result; 1307 return result;
1301 } 1308 }
1302 } 1309 }
1303 1310
1304 } // namespace dart 1311 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/pages.h ('k') | runtime/vm/precompiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698