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

Side by Side Diff: runtime/vm/scavenger.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, 4 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.cc ('k') | runtime/vm/thread_test.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/scavenger.h" 5 #include "vm/scavenger.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
11 #include "vm/dart.h" 11 #include "vm/dart.h"
12 #include "vm/dart_api_state.h" 12 #include "vm/dart_api_state.h"
13 #include "vm/isolate.h" 13 #include "vm/isolate.h"
14 #include "vm/lockers.h" 14 #include "vm/lockers.h"
15 #include "vm/object.h" 15 #include "vm/object.h"
16 #include "vm/object_id_ring.h" 16 #include "vm/object_id_ring.h"
17 #include "vm/stack_frame.h" 17 #include "vm/stack_frame.h"
18 #include "vm/store_buffer.h" 18 #include "vm/store_buffer.h"
19 #include "vm/thread_registry.h"
19 #include "vm/verified_memory.h" 20 #include "vm/verified_memory.h"
20 #include "vm/verifier.h" 21 #include "vm/verifier.h"
21 #include "vm/visitor.h" 22 #include "vm/visitor.h"
22 #include "vm/weak_table.h" 23 #include "vm/weak_table.h"
23 24
24 namespace dart { 25 namespace dart {
25 26
26 DEFINE_FLAG(int, early_tenuring_threshold, 66, 27 DEFINE_FLAG(int, early_tenuring_threshold, 66,
27 "When more than this percentage of promotion candidates survive, " 28 "When more than this percentage of promotion candidates survive, "
28 "promote all survivors of next scavenge."); 29 "promote all survivors of next scavenge.");
(...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 793
793 794
794 void Scavenger::Scavenge() { 795 void Scavenger::Scavenge() {
795 // TODO(cshapiro): Add a decision procedure for determining when the 796 // TODO(cshapiro): Add a decision procedure for determining when the
796 // the API callbacks should be invoked. 797 // the API callbacks should be invoked.
797 Scavenge(false); 798 Scavenge(false);
798 } 799 }
799 800
800 801
801 void Scavenger::Scavenge(bool invoke_api_callbacks) { 802 void Scavenger::Scavenge(bool invoke_api_callbacks) {
803 Isolate* isolate = heap_->isolate();
804 // Ensure that all threads for this isolate are at a safepoint (either stopped
805 // or in native code). If two threads are racing at this point, the loser
806 // will continue with its scavenge after waiting for the winner to complete.
807 // TODO(koda): Consider moving SafepointThreads into allocation failure/retry
808 // logic to avoid needless collections.
809 isolate->thread_registry()->SafepointThreads();
810
802 // Scavenging is not reentrant. Make sure that is the case. 811 // Scavenging is not reentrant. Make sure that is the case.
803 ASSERT(!scavenging_); 812 ASSERT(!scavenging_);
804 scavenging_ = true; 813 scavenging_ = true;
805 Isolate* isolate = heap_->isolate(); 814
806 PageSpace* page_space = heap_->old_space(); 815 PageSpace* page_space = heap_->old_space();
807 NoSafepointScope no_safepoints; 816 NoSafepointScope no_safepoints;
808 817
809 // TODO(koda): Make verification more compatible with concurrent sweep. 818 // TODO(koda): Make verification more compatible with concurrent sweep.
810 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { 819 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) {
811 OS::PrintErr("Verifying before Scavenge..."); 820 OS::PrintErr("Verifying before Scavenge...");
812 heap_->Verify(kForbidMarked); 821 heap_->Verify(kForbidMarked);
813 OS::PrintErr(" done.\n"); 822 OS::PrintErr(" done.\n");
814 } 823 }
815 824
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 // TODO(koda): Make verification more compatible with concurrent sweep. 863 // TODO(koda): Make verification more compatible with concurrent sweep.
855 if (FLAG_verify_after_gc && !FLAG_concurrent_sweep) { 864 if (FLAG_verify_after_gc && !FLAG_concurrent_sweep) {
856 OS::PrintErr("Verifying after Scavenge..."); 865 OS::PrintErr("Verifying after Scavenge...");
857 heap_->Verify(kForbidMarked); 866 heap_->Verify(kForbidMarked);
858 OS::PrintErr(" done.\n"); 867 OS::PrintErr(" done.\n");
859 } 868 }
860 869
861 // Done scavenging. Reset the marker. 870 // Done scavenging. Reset the marker.
862 ASSERT(scavenging_); 871 ASSERT(scavenging_);
863 scavenging_ = false; 872 scavenging_ = false;
873
874 isolate->thread_registry()->ResumeAllThreads();
864 } 875 }
865 876
866 877
867 void Scavenger::WriteProtect(bool read_only) { 878 void Scavenger::WriteProtect(bool read_only) {
868 ASSERT(!scavenging_); 879 ASSERT(!scavenging_);
869 to_->WriteProtect(read_only); 880 to_->WriteProtect(read_only);
870 } 881 }
871 882
872 883
873 void Scavenger::PrintToJSONObject(JSONObject* object) const { 884 void Scavenger::PrintToJSONObject(JSONObject* object) const {
(...skipping 28 matching lines...) Expand all
902 } 913 }
903 914
904 915
905 void Scavenger::FreeExternal(intptr_t size) { 916 void Scavenger::FreeExternal(intptr_t size) {
906 ASSERT(size >= 0); 917 ASSERT(size >= 0);
907 external_size_ -= size; 918 external_size_ -= size;
908 ASSERT(external_size_ >= 0); 919 ASSERT(external_size_ >= 0);
909 } 920 }
910 921
911 } // namespace dart 922 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/pages.cc ('k') | runtime/vm/thread_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698