| 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 |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 | 829 |
| 830 | 830 |
| 831 void Scavenger::WriteProtect(bool read_only) { | 831 void Scavenger::WriteProtect(bool read_only) { |
| 832 ASSERT(!scavenging_); | 832 ASSERT(!scavenging_); |
| 833 ASSERT(from_ == NULL); | 833 ASSERT(from_ == NULL); |
| 834 to_->WriteProtect(read_only); | 834 to_->WriteProtect(read_only); |
| 835 } | 835 } |
| 836 | 836 |
| 837 | 837 |
| 838 void Scavenger::PrintToJSONObject(JSONObject* object) { | 838 void Scavenger::PrintToJSONObject(JSONObject* object) { |
| 839 Isolate* isolate = Isolate::Current(); |
| 840 ASSERT(isolate != NULL); |
| 839 JSONObject space(object, "new"); | 841 JSONObject space(object, "new"); |
| 840 space.AddProperty("type", "Scavenger"); | 842 space.AddProperty("type", "Scavenger"); |
| 841 space.AddProperty("id", "heaps/new"); | 843 space.AddProperty("id", "heaps/new"); |
| 842 space.AddProperty("name", "Scavenger"); | 844 space.AddProperty("name", "Scavenger"); |
| 843 space.AddProperty("user_name", "new"); | 845 space.AddProperty("user_name", "new"); |
| 844 space.AddProperty("collections", collections()); | 846 space.AddProperty("collections", collections()); |
| 847 { |
| 848 int64_t run_time = OS::GetCurrentTimeMicros() - isolate->start_time(); |
| 849 run_time = Utils::Maximum(run_time, static_cast<int64_t>(0)); |
| 850 double run_time_millis = MicrosecondsToMilliseconds(run_time); |
| 851 double avg_time_between_collections = |
| 852 run_time_millis / static_cast<double>(collections()); |
| 853 space.AddProperty("avgCollectionPeriodMillis", |
| 854 avg_time_between_collections); |
| 855 } |
| 845 space.AddProperty("used", UsedInWords() * kWordSize); | 856 space.AddProperty("used", UsedInWords() * kWordSize); |
| 846 space.AddProperty("capacity", CapacityInWords() * kWordSize); | 857 space.AddProperty("capacity", CapacityInWords() * kWordSize); |
| 847 space.AddProperty("external", ExternalInWords() * kWordSize); | 858 space.AddProperty("external", ExternalInWords() * kWordSize); |
| 848 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros())); | 859 space.AddProperty("time", MicrosecondsToSeconds(gc_time_micros())); |
| 849 } | 860 } |
| 850 | 861 |
| 851 | 862 |
| 852 void Scavenger::AllocateExternal(intptr_t size) { | 863 void Scavenger::AllocateExternal(intptr_t size) { |
| 853 ASSERT(size >= 0); | 864 ASSERT(size >= 0); |
| 854 external_size_ += size; | 865 external_size_ += size; |
| 855 } | 866 } |
| 856 | 867 |
| 857 | 868 |
| 858 void Scavenger::FreeExternal(intptr_t size) { | 869 void Scavenger::FreeExternal(intptr_t size) { |
| 859 ASSERT(size >= 0); | 870 ASSERT(size >= 0); |
| 860 external_size_ -= size; | 871 external_size_ -= size; |
| 861 ASSERT(external_size_ >= 0); | 872 ASSERT(external_size_ >= 0); |
| 862 } | 873 } |
| 863 | 874 |
| 864 } // namespace dart | 875 } // namespace dart |
| OLD | NEW |