| 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 "vm/dart.h" | 7 #include "vm/dart.h" |
| 8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/lockers.h" | 10 #include "vm/lockers.h" |
| (...skipping 798 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 StackZone zone(thread); | 809 StackZone zone(thread); |
| 810 // Setup the visitor and run the scavenge. | 810 // Setup the visitor and run the scavenge. |
| 811 ScavengerVisitor visitor(isolate, this, from); | 811 ScavengerVisitor visitor(isolate, this, from); |
| 812 page_space->AcquireDataLock(); | 812 page_space->AcquireDataLock(); |
| 813 IterateRoots(isolate, &visitor); | 813 IterateRoots(isolate, &visitor); |
| 814 int64_t start = OS::GetCurrentTimeMicros(); | 814 int64_t start = OS::GetCurrentTimeMicros(); |
| 815 ProcessToSpace(&visitor); | 815 ProcessToSpace(&visitor); |
| 816 int64_t middle = OS::GetCurrentTimeMicros(); | 816 int64_t middle = OS::GetCurrentTimeMicros(); |
| 817 { | 817 { |
| 818 TIMELINE_FUNCTION_GC_DURATION(thread, "WeakHandleProcessing"); | 818 TIMELINE_FUNCTION_GC_DURATION(thread, "WeakHandleProcessing"); |
| 819 FinalizationQueue* queue = new FinalizationQueue(); | 819 if (FLAG_background_finalization) { |
| 820 ScavengerWeakVisitor weak_visitor(thread, this, queue); | 820 FinalizationQueue* queue = new FinalizationQueue(); |
| 821 IterateWeakRoots(isolate, &weak_visitor); | 821 ScavengerWeakVisitor weak_visitor(thread, this, queue); |
| 822 if (queue->length() > 0) { | 822 IterateWeakRoots(isolate, &weak_visitor); |
| 823 Dart::thread_pool()->Run(new BackgroundFinalizer(isolate, queue)); | 823 if (queue->length() > 0) { |
| 824 Dart::thread_pool()->Run(new BackgroundFinalizer(isolate, queue)); |
| 825 } else { |
| 826 delete queue; |
| 827 } |
| 824 } else { | 828 } else { |
| 825 delete queue; | 829 ScavengerWeakVisitor weak_visitor(thread, this, NULL); |
| 830 IterateWeakRoots(isolate, &weak_visitor); |
| 826 } | 831 } |
| 827 } | 832 } |
| 828 ProcessWeakReferences(); | 833 ProcessWeakReferences(); |
| 829 page_space->ReleaseDataLock(); | 834 page_space->ReleaseDataLock(); |
| 830 | 835 |
| 831 // Scavenge finished. Run accounting. | 836 // Scavenge finished. Run accounting. |
| 832 int64_t end = OS::GetCurrentTimeMicros(); | 837 int64_t end = OS::GetCurrentTimeMicros(); |
| 833 heap_->RecordTime(kProcessToSpace, middle - start); | 838 heap_->RecordTime(kProcessToSpace, middle - start); |
| 834 heap_->RecordTime(kIterateWeaks, end - middle); | 839 heap_->RecordTime(kIterateWeaks, end - middle); |
| 835 stats_history_.Add( | 840 stats_history_.Add( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 } | 899 } |
| 895 | 900 |
| 896 | 901 |
| 897 void Scavenger::FreeExternal(intptr_t size) { | 902 void Scavenger::FreeExternal(intptr_t size) { |
| 898 ASSERT(size >= 0); | 903 ASSERT(size >= 0); |
| 899 external_size_ -= size; | 904 external_size_ -= size; |
| 900 ASSERT(external_size_ >= 0); | 905 ASSERT(external_size_ >= 0); |
| 901 } | 906 } |
| 902 | 907 |
| 903 } // namespace dart | 908 } // namespace dart |
| OLD | NEW |