OLD | NEW |
---|---|
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 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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) { |
802 // Scavenging is not reentrant. Make sure that is the case. | 803 // Scavenging is not reentrant. Make sure that is the case. |
803 ASSERT(!scavenging_); | 804 ASSERT(!scavenging_); |
804 scavenging_ = true; | 805 scavenging_ = true; |
805 Isolate* isolate = heap_->isolate(); | 806 Isolate* isolate = heap_->isolate(); |
807 | |
808 isolate->thread_registry()->SafepointThreads(); | |
Ivan Posva
2015/08/25 23:27:15
ditto about the comment.
Also please explain what
koda
2015/08/26 01:09:14
Done.
Added TODO about avoiding the possibility o
| |
809 | |
806 PageSpace* page_space = heap_->old_space(); | 810 PageSpace* page_space = heap_->old_space(); |
807 NoSafepointScope no_safepoints; | 811 NoSafepointScope no_safepoints; |
808 | 812 |
809 // TODO(koda): Make verification more compatible with concurrent sweep. | 813 // TODO(koda): Make verification more compatible with concurrent sweep. |
810 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { | 814 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { |
811 OS::PrintErr("Verifying before Scavenge..."); | 815 OS::PrintErr("Verifying before Scavenge..."); |
812 heap_->Verify(kForbidMarked); | 816 heap_->Verify(kForbidMarked); |
813 OS::PrintErr(" done.\n"); | 817 OS::PrintErr(" done.\n"); |
814 } | 818 } |
815 | 819 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
851 } | 855 } |
852 Epilogue(isolate, from, invoke_api_callbacks); | 856 Epilogue(isolate, from, invoke_api_callbacks); |
853 | 857 |
854 // TODO(koda): Make verification more compatible with concurrent sweep. | 858 // TODO(koda): Make verification more compatible with concurrent sweep. |
855 if (FLAG_verify_after_gc && !FLAG_concurrent_sweep) { | 859 if (FLAG_verify_after_gc && !FLAG_concurrent_sweep) { |
856 OS::PrintErr("Verifying after Scavenge..."); | 860 OS::PrintErr("Verifying after Scavenge..."); |
857 heap_->Verify(kForbidMarked); | 861 heap_->Verify(kForbidMarked); |
858 OS::PrintErr(" done.\n"); | 862 OS::PrintErr(" done.\n"); |
859 } | 863 } |
860 | 864 |
865 isolate->thread_registry()->ResumeAllThreads(); | |
866 | |
861 // Done scavenging. Reset the marker. | 867 // Done scavenging. Reset the marker. |
862 ASSERT(scavenging_); | 868 ASSERT(scavenging_); |
863 scavenging_ = false; | 869 scavenging_ = false; |
864 } | 870 } |
865 | 871 |
866 | 872 |
867 void Scavenger::WriteProtect(bool read_only) { | 873 void Scavenger::WriteProtect(bool read_only) { |
868 ASSERT(!scavenging_); | 874 ASSERT(!scavenging_); |
869 to_->WriteProtect(read_only); | 875 to_->WriteProtect(read_only); |
870 } | 876 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
902 } | 908 } |
903 | 909 |
904 | 910 |
905 void Scavenger::FreeExternal(intptr_t size) { | 911 void Scavenger::FreeExternal(intptr_t size) { |
906 ASSERT(size >= 0); | 912 ASSERT(size >= 0); |
907 external_size_ -= size; | 913 external_size_ -= size; |
908 ASSERT(external_size_ >= 0); | 914 ASSERT(external_size_ >= 0); |
909 } | 915 } |
910 | 916 |
911 } // namespace dart | 917 } // namespace dart |
OLD | NEW |