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

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

Issue 2091023002: Add flag to control background finalization. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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/gc_marker.cc ('k') | no next file » | 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 "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
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
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
OLDNEW
« no previous file with comments | « runtime/vm/gc_marker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698