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

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

Issue 2582543003: Update GC stats, ThreadPool, Timer and ScopedTimer to use monotonic time. (Closed)
Patch Set: . Created 4 years 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/scope_timer.h » ('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 "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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 // --gc_at_alloc can get us here before the ring has been initialized. 497 // --gc_at_alloc can get us here before the ring has been initialized.
498 ASSERT(FLAG_gc_at_alloc); 498 ASSERT(FLAG_gc_at_alloc);
499 return; 499 return;
500 } 500 }
501 ring->VisitPointers(visitor); 501 ring->VisitPointers(visitor);
502 #endif // !PRODUCT 502 #endif // !PRODUCT
503 } 503 }
504 504
505 505
506 void Scavenger::IterateRoots(Isolate* isolate, ScavengerVisitor* visitor) { 506 void Scavenger::IterateRoots(Isolate* isolate, ScavengerVisitor* visitor) {
507 int64_t start = OS::GetCurrentTimeMicros(); 507 int64_t start = OS::GetCurrentMonotonicMicros();
508 isolate->VisitObjectPointers(visitor, 508 isolate->VisitObjectPointers(visitor,
509 StackFrameIterator::kDontValidateFrames); 509 StackFrameIterator::kDontValidateFrames);
510 int64_t middle = OS::GetCurrentTimeMicros(); 510 int64_t middle = OS::GetCurrentMonotonicMicros();
511 IterateStoreBuffers(isolate, visitor); 511 IterateStoreBuffers(isolate, visitor);
512 IterateObjectIdTable(isolate, visitor); 512 IterateObjectIdTable(isolate, visitor);
513 int64_t end = OS::GetCurrentTimeMicros(); 513 int64_t end = OS::GetCurrentMonotonicMicros();
514 heap_->RecordData(kToKBAfterStoreBuffer, RoundWordsToKB(UsedInWords())); 514 heap_->RecordData(kToKBAfterStoreBuffer, RoundWordsToKB(UsedInWords()));
515 heap_->RecordTime(kVisitIsolateRoots, middle - start); 515 heap_->RecordTime(kVisitIsolateRoots, middle - start);
516 heap_->RecordTime(kIterateStoreBuffers, end - middle); 516 heap_->RecordTime(kIterateStoreBuffers, end - middle);
517 } 517 }
518 518
519 519
520 bool Scavenger::IsUnreachable(RawObject** p) { 520 bool Scavenger::IsUnreachable(RawObject** p) {
521 RawObject* raw_obj = *p; 521 RawObject* raw_obj = *p;
522 if (!raw_obj->IsHeapObject()) { 522 if (!raw_obj->IsHeapObject()) {
523 return false; 523 return false;
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 (survivor_end_ - FirstObjectStart()) / kWordSize; 801 (survivor_end_ - FirstObjectStart()) / kWordSize;
802 SemiSpace* from = Prologue(isolate, invoke_api_callbacks); 802 SemiSpace* from = Prologue(isolate, invoke_api_callbacks);
803 // The API prologue/epilogue may create/destroy zones, so we must not 803 // The API prologue/epilogue may create/destroy zones, so we must not
804 // depend on zone allocations surviving beyond the epilogue callback. 804 // depend on zone allocations surviving beyond the epilogue callback.
805 { 805 {
806 StackZone zone(thread); 806 StackZone zone(thread);
807 // Setup the visitor and run the scavenge. 807 // Setup the visitor and run the scavenge.
808 ScavengerVisitor visitor(isolate, this, from); 808 ScavengerVisitor visitor(isolate, this, from);
809 page_space->AcquireDataLock(); 809 page_space->AcquireDataLock();
810 IterateRoots(isolate, &visitor); 810 IterateRoots(isolate, &visitor);
811 int64_t start = OS::GetCurrentTimeMicros(); 811 int64_t start = OS::GetCurrentMonotonicMicros();
812 ProcessToSpace(&visitor); 812 ProcessToSpace(&visitor);
813 int64_t middle = OS::GetCurrentTimeMicros(); 813 int64_t middle = OS::GetCurrentMonotonicMicros();
814 { 814 {
815 TIMELINE_FUNCTION_GC_DURATION(thread, "WeakHandleProcessing"); 815 TIMELINE_FUNCTION_GC_DURATION(thread, "WeakHandleProcessing");
816 if (FLAG_background_finalization) { 816 if (FLAG_background_finalization) {
817 FinalizationQueue* queue = new FinalizationQueue(); 817 FinalizationQueue* queue = new FinalizationQueue();
818 ScavengerWeakVisitor weak_visitor(thread, this, queue); 818 ScavengerWeakVisitor weak_visitor(thread, this, queue);
819 IterateWeakRoots(isolate, &weak_visitor); 819 IterateWeakRoots(isolate, &weak_visitor);
820 if (queue->length() > 0) { 820 if (queue->length() > 0) {
821 Dart::thread_pool()->Run(new BackgroundFinalizer(isolate, queue)); 821 Dart::thread_pool()->Run(new BackgroundFinalizer(isolate, queue));
822 } else { 822 } else {
823 delete queue; 823 delete queue;
824 } 824 }
825 } else { 825 } else {
826 ScavengerWeakVisitor weak_visitor(thread, this, NULL); 826 ScavengerWeakVisitor weak_visitor(thread, this, NULL);
827 IterateWeakRoots(isolate, &weak_visitor); 827 IterateWeakRoots(isolate, &weak_visitor);
828 } 828 }
829 } 829 }
830 ProcessWeakReferences(); 830 ProcessWeakReferences();
831 page_space->ReleaseDataLock(); 831 page_space->ReleaseDataLock();
832 832
833 // Scavenge finished. Run accounting. 833 // Scavenge finished. Run accounting.
834 int64_t end = OS::GetCurrentTimeMicros(); 834 int64_t end = OS::GetCurrentMonotonicMicros();
835 heap_->RecordTime(kProcessToSpace, middle - start); 835 heap_->RecordTime(kProcessToSpace, middle - start);
836 heap_->RecordTime(kIterateWeaks, end - middle); 836 heap_->RecordTime(kIterateWeaks, end - middle);
837 stats_history_.Add(ScavengeStats( 837 stats_history_.Add(ScavengeStats(
838 start, end, usage_before, GetCurrentUsage(), promo_candidate_words, 838 start, end, usage_before, GetCurrentUsage(), promo_candidate_words,
839 visitor.bytes_promoted() >> kWordSizeLog2)); 839 visitor.bytes_promoted() >> kWordSizeLog2));
840 } 840 }
841 Epilogue(isolate, from, invoke_api_callbacks); 841 Epilogue(isolate, from, invoke_api_callbacks);
842 842
843 // TODO(koda): Make verification more compatible with concurrent sweep. 843 // TODO(koda): Make verification more compatible with concurrent sweep.
844 if (FLAG_verify_after_gc && !FLAG_concurrent_sweep) { 844 if (FLAG_verify_after_gc && !FLAG_concurrent_sweep) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } 896 }
897 897
898 898
899 void Scavenger::FreeExternal(intptr_t size) { 899 void Scavenger::FreeExternal(intptr_t size) {
900 ASSERT(size >= 0); 900 ASSERT(size >= 0);
901 external_size_ -= size; 901 external_size_ -= size;
902 ASSERT(external_size_ >= 0); 902 ASSERT(external_size_ >= 0);
903 } 903 }
904 904
905 } // namespace dart 905 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/pages.cc ('k') | runtime/vm/scope_timer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698