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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 heap_->RecordData(kStoreBufferEntries, total_count); | 480 heap_->RecordData(kStoreBufferEntries, total_count); |
481 heap_->RecordData(kDataUnused1, 0); | 481 heap_->RecordData(kDataUnused1, 0); |
482 heap_->RecordData(kDataUnused2, 0); | 482 heap_->RecordData(kDataUnused2, 0); |
483 // Done iterating through old objects remembered in the store buffers. | 483 // Done iterating through old objects remembered in the store buffers. |
484 visitor->VisitingOldObject(NULL); | 484 visitor->VisitingOldObject(NULL); |
485 } | 485 } |
486 | 486 |
487 | 487 |
488 void Scavenger::IterateObjectIdTable(Isolate* isolate, | 488 void Scavenger::IterateObjectIdTable(Isolate* isolate, |
489 ScavengerVisitor* visitor) { | 489 ScavengerVisitor* visitor) { |
| 490 #ifndef PRODUCT |
490 if (!FLAG_support_service) { | 491 if (!FLAG_support_service) { |
491 return; | 492 return; |
492 } | 493 } |
493 ObjectIdRing* ring = isolate->object_id_ring(); | 494 ObjectIdRing* ring = isolate->object_id_ring(); |
494 if (ring == NULL) { | 495 if (ring == NULL) { |
495 // --gc_at_alloc can get us here before the ring has been initialized. | 496 // --gc_at_alloc can get us here before the ring has been initialized. |
496 ASSERT(FLAG_gc_at_alloc); | 497 ASSERT(FLAG_gc_at_alloc); |
497 return; | 498 return; |
498 } | 499 } |
499 ring->VisitPointers(visitor); | 500 ring->VisitPointers(visitor); |
| 501 #endif // !PRODUCT |
500 } | 502 } |
501 | 503 |
502 | 504 |
503 void Scavenger::IterateRoots(Isolate* isolate, ScavengerVisitor* visitor) { | 505 void Scavenger::IterateRoots(Isolate* isolate, ScavengerVisitor* visitor) { |
504 int64_t start = OS::GetCurrentTimeMicros(); | 506 int64_t start = OS::GetCurrentTimeMicros(); |
505 isolate->VisitObjectPointers(visitor, | 507 isolate->VisitObjectPointers(visitor, |
506 StackFrameIterator::kDontValidateFrames); | 508 StackFrameIterator::kDontValidateFrames); |
507 int64_t middle = OS::GetCurrentTimeMicros(); | 509 int64_t middle = OS::GetCurrentTimeMicros(); |
508 IterateStoreBuffers(isolate, visitor); | 510 IterateStoreBuffers(isolate, visitor); |
509 IterateObjectIdTable(isolate, visitor); | 511 IterateObjectIdTable(isolate, visitor); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 scavenging_ = false; | 853 scavenging_ = false; |
852 } | 854 } |
853 | 855 |
854 | 856 |
855 void Scavenger::WriteProtect(bool read_only) { | 857 void Scavenger::WriteProtect(bool read_only) { |
856 ASSERT(!scavenging_); | 858 ASSERT(!scavenging_); |
857 to_->WriteProtect(read_only); | 859 to_->WriteProtect(read_only); |
858 } | 860 } |
859 | 861 |
860 | 862 |
| 863 #ifndef PRODUCT |
861 void Scavenger::PrintToJSONObject(JSONObject* object) const { | 864 void Scavenger::PrintToJSONObject(JSONObject* object) const { |
862 if (!FLAG_support_service) { | 865 if (!FLAG_support_service) { |
863 return; | 866 return; |
864 } | 867 } |
865 Isolate* isolate = Isolate::Current(); | 868 Isolate* isolate = Isolate::Current(); |
866 ASSERT(isolate != NULL); | 869 ASSERT(isolate != NULL); |
867 JSONObject space(object, "new"); | 870 JSONObject space(object, "new"); |
868 space.AddProperty("type", "HeapSpace"); | 871 space.AddProperty("type", "HeapSpace"); |
869 space.AddProperty("name", "new"); | 872 space.AddProperty("name", "new"); |
870 space.AddProperty("vmName", "Scavenger"); | 873 space.AddProperty("vmName", "Scavenger"); |
871 space.AddProperty("collections", collections()); | 874 space.AddProperty("collections", collections()); |
872 if (collections() > 0) { | 875 if (collections() > 0) { |
873 int64_t run_time = OS::GetCurrentTimeMicros() - isolate->start_time(); | 876 int64_t run_time = OS::GetCurrentTimeMicros() - isolate->start_time(); |
874 run_time = Utils::Maximum(run_time, static_cast<int64_t>(0)); | 877 run_time = Utils::Maximum(run_time, static_cast<int64_t>(0)); |
875 double run_time_millis = MicrosecondsToMilliseconds(run_time); | 878 double run_time_millis = MicrosecondsToMilliseconds(run_time); |
876 double avg_time_between_collections = | 879 double avg_time_between_collections = |
877 run_time_millis / static_cast<double>(collections()); | 880 run_time_millis / static_cast<double>(collections()); |
878 space.AddProperty("avgCollectionPeriodMillis", | 881 space.AddProperty("avgCollectionPeriodMillis", |
879 avg_time_between_collections); | 882 avg_time_between_collections); |
880 } else { | 883 } else { |
881 space.AddProperty("avgCollectionPeriodMillis", 0.0); | 884 space.AddProperty("avgCollectionPeriodMillis", 0.0); |
882 } | 885 } |
883 space.AddProperty64("used", UsedInWords() * kWordSize); | 886 space.AddProperty64("used", UsedInWords() * kWordSize); |
884 space.AddProperty64("capacity", CapacityInWords() * kWordSize); | 887 space.AddProperty64("capacity", CapacityInWords() * kWordSize); |
885 space.AddProperty64("external", ExternalInWords() * kWordSize); | 888 space.AddProperty64("external", ExternalInWords() * kWordSize); |
886 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros())); | 889 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros())); |
887 } | 890 } |
| 891 #endif // !PRODUCT |
888 | 892 |
889 | 893 |
890 void Scavenger::AllocateExternal(intptr_t size) { | 894 void Scavenger::AllocateExternal(intptr_t size) { |
891 ASSERT(size >= 0); | 895 ASSERT(size >= 0); |
892 external_size_ += size; | 896 external_size_ += size; |
893 } | 897 } |
894 | 898 |
895 | 899 |
896 void Scavenger::FreeExternal(intptr_t size) { | 900 void Scavenger::FreeExternal(intptr_t size) { |
897 ASSERT(size >= 0); | 901 ASSERT(size >= 0); |
898 external_size_ -= size; | 902 external_size_ -= size; |
899 ASSERT(external_size_ >= 0); | 903 ASSERT(external_size_ >= 0); |
900 } | 904 } |
901 | 905 |
902 } // namespace dart | 906 } // namespace dart |
OLD | NEW |