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