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 // TODO(koda): Allow concurrent sweeper to keep running. |
| 808 isolate->thread_registry()->SafepointThreads(); |
806 PageSpace* page_space = heap_->old_space(); | 809 PageSpace* page_space = heap_->old_space(); |
807 NoSafepointScope no_safepoints; | 810 NoSafepointScope no_safepoints; |
808 | 811 |
809 // TODO(koda): Make verification more compatible with concurrent sweep. | 812 // TODO(koda): Make verification more compatible with concurrent sweep. |
810 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { | 813 if (FLAG_verify_before_gc && !FLAG_concurrent_sweep) { |
811 OS::PrintErr("Verifying before Scavenge..."); | 814 OS::PrintErr("Verifying before Scavenge..."); |
812 heap_->Verify(kForbidMarked); | 815 heap_->Verify(kForbidMarked); |
813 OS::PrintErr(" done.\n"); | 816 OS::PrintErr(" done.\n"); |
814 } | 817 } |
815 | 818 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 } | 854 } |
852 Epilogue(isolate, invoke_api_callbacks); | 855 Epilogue(isolate, invoke_api_callbacks); |
853 | 856 |
854 // TODO(koda): Make verification more compatible with concurrent sweep. | 857 // TODO(koda): Make verification more compatible with concurrent sweep. |
855 if (FLAG_verify_after_gc && !FLAG_concurrent_sweep) { | 858 if (FLAG_verify_after_gc && !FLAG_concurrent_sweep) { |
856 OS::PrintErr("Verifying after Scavenge..."); | 859 OS::PrintErr("Verifying after Scavenge..."); |
857 heap_->Verify(kForbidMarked); | 860 heap_->Verify(kForbidMarked); |
858 OS::PrintErr(" done.\n"); | 861 OS::PrintErr(" done.\n"); |
859 } | 862 } |
860 | 863 |
| 864 isolate->thread_registry()->ResumeAllThreads(); |
| 865 |
861 // Done scavenging. Reset the marker. | 866 // Done scavenging. Reset the marker. |
862 ASSERT(scavenging_); | 867 ASSERT(scavenging_); |
863 scavenging_ = false; | 868 scavenging_ = false; |
864 } | 869 } |
865 | 870 |
866 | 871 |
867 void Scavenger::WriteProtect(bool read_only) { | 872 void Scavenger::WriteProtect(bool read_only) { |
868 ASSERT(!scavenging_); | 873 ASSERT(!scavenging_); |
869 ASSERT(from_ == NULL); | 874 ASSERT(from_ == NULL); |
870 to_->WriteProtect(read_only); | 875 to_->WriteProtect(read_only); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
903 } | 908 } |
904 | 909 |
905 | 910 |
906 void Scavenger::FreeExternal(intptr_t size) { | 911 void Scavenger::FreeExternal(intptr_t size) { |
907 ASSERT(size >= 0); | 912 ASSERT(size >= 0); |
908 external_size_ -= size; | 913 external_size_ -= size; |
909 ASSERT(external_size_ >= 0); | 914 ASSERT(external_size_ >= 0); |
910 } | 915 } |
911 | 916 |
912 } // namespace dart | 917 } // namespace dart |
OLD | NEW |