| Index: runtime/vm/class_table.cc
|
| diff --git a/runtime/vm/class_table.cc b/runtime/vm/class_table.cc
|
| index 46965376694d6e082f643353603da735d1f7394d..2f2c0ab136390bd1725456eb1c61c9ebe2b7e6c8 100644
|
| --- a/runtime/vm/class_table.cc
|
| +++ b/runtime/vm/class_table.cc
|
| @@ -133,42 +133,35 @@ void ClassTable::PrintToJSONStream(JSONStream* stream) {
|
|
|
|
|
| void ClassHeapStats::Initialize() {
|
| - allocated_before_gc_old_space = 0;
|
| - allocated_before_gc_new_space = 0;
|
| - allocated_size_before_gc_old_space = 0;
|
| - allocated_size_before_gc_new_space = 0;
|
| - live_after_gc_old_space = 0;
|
| - live_after_gc_new_space = 0;
|
| - live_size_after_gc_old_space = 0;
|
| - live_size_after_gc_new_space = 0;
|
| - allocated_since_gc_new_space = 0;
|
| - allocated_since_gc_old_space = 0;
|
| - allocated_size_since_gc_new_space = 0;
|
| - allocated_size_since_gc_old_space = 0;
|
| + pre_gc.Reset();
|
| + post_gc.Reset();
|
| + recent.Reset();
|
| + accumulated.Reset();
|
| + last_reset.Reset();
|
| }
|
|
|
|
|
| void ClassHeapStats::ResetAtNewGC() {
|
| - allocated_before_gc_new_space = live_after_gc_new_space +
|
| - allocated_since_gc_new_space;
|
| - allocated_size_before_gc_new_space = live_size_after_gc_new_space +
|
| - allocated_size_since_gc_new_space;
|
| - live_after_gc_new_space = 0;
|
| - live_size_after_gc_new_space = 0;
|
| - allocated_since_gc_new_space = 0;
|
| - allocated_size_since_gc_new_space = 0;
|
| + pre_gc.new_count = post_gc.new_count + recent.new_count;
|
| + pre_gc.new_size = post_gc.new_size + recent.new_size;
|
| + // Accumulate allocations.
|
| + accumulated.new_count += recent.new_count - last_reset.new_count;
|
| + accumulated.new_size += recent.new_size - last_reset.new_size;
|
| + last_reset.ResetNew();
|
| + post_gc.ResetNew();
|
| + recent.ResetNew();
|
| }
|
|
|
|
|
| void ClassHeapStats::ResetAtOldGC() {
|
| - allocated_before_gc_old_space = live_after_gc_old_space +
|
| - allocated_since_gc_old_space;
|
| - allocated_size_before_gc_old_space = live_size_after_gc_old_space +
|
| - allocated_size_since_gc_old_space;
|
| - live_after_gc_old_space = 0;
|
| - live_size_after_gc_old_space = 0;
|
| - allocated_since_gc_old_space = 0;
|
| - allocated_size_since_gc_old_space = 0;
|
| + pre_gc.old_count = post_gc.old_count + recent.old_count;
|
| + pre_gc.old_size = post_gc.old_size + recent.old_size;
|
| + // Accumulate allocations.
|
| + accumulated.old_count += recent.old_count - last_reset.old_count;
|
| + accumulated.old_size += recent.old_size - last_reset.old_size;
|
| + last_reset.ResetOld();
|
| + post_gc.ResetOld();
|
| + recent.ResetOld();
|
| }
|
|
|
|
|
| @@ -176,18 +169,23 @@ void ClassHeapStats::UpdateSize(intptr_t instance_size) {
|
| ASSERT(instance_size > 0);
|
| // For classes with fixed instance size we do not emit code to update
|
| // the size statistics. Update them here.
|
| - allocated_size_before_gc_old_space =
|
| - allocated_before_gc_old_space * instance_size;
|
| - allocated_size_before_gc_new_space =
|
| - allocated_before_gc_new_space * instance_size;
|
| - live_size_after_gc_old_space =
|
| - live_after_gc_old_space * instance_size;
|
| - live_size_after_gc_new_space =
|
| - live_after_gc_new_space * instance_size;
|
| - allocated_size_since_gc_new_space =
|
| - allocated_since_gc_new_space * instance_size;
|
| - allocated_size_since_gc_old_space =
|
| - allocated_since_gc_old_space * instance_size;
|
| + pre_gc.old_size = pre_gc.old_count * instance_size;
|
| + pre_gc.new_size = pre_gc.new_count * instance_size;
|
| + post_gc.old_size = post_gc.old_count * instance_size;
|
| + post_gc.new_size = post_gc.new_count * instance_size;
|
| + recent.new_size = recent.new_count * instance_size;
|
| + recent.old_size = recent.old_count * instance_size;
|
| +}
|
| +
|
| +
|
| +void ClassHeapStats::ResetAccumulator() {
|
| + // Remember how much was allocated so we can subtract this from the result
|
| + // when printing.
|
| + last_reset.new_count = recent.new_count;
|
| + last_reset.new_size = recent.new_size;
|
| + last_reset.old_count = recent.old_count;
|
| + last_reset.old_size = recent.old_size;
|
| + accumulated.Reset();
|
| }
|
|
|
|
|
| @@ -197,21 +195,29 @@ void ClassHeapStats::PrintTOJSONArray(const Class& cls, JSONArray* array) {
|
| obj.AddProperty("class", cls);
|
| {
|
| JSONArray new_stats(&obj, "new");
|
| - new_stats.AddValue(allocated_before_gc_new_space);
|
| - new_stats.AddValue(allocated_size_before_gc_new_space);
|
| - new_stats.AddValue(live_after_gc_new_space);
|
| - new_stats.AddValue(live_size_after_gc_new_space);
|
| - new_stats.AddValue(allocated_since_gc_new_space);
|
| - new_stats.AddValue(allocated_size_since_gc_new_space);
|
| + new_stats.AddValue(pre_gc.new_count);
|
| + new_stats.AddValue(pre_gc.new_size);
|
| + new_stats.AddValue(post_gc.new_count);
|
| + new_stats.AddValue(post_gc.new_size);
|
| + new_stats.AddValue(recent.new_count);
|
| + new_stats.AddValue(recent.new_size);
|
| + new_stats.AddValue64(accumulated.new_count + recent.new_count -
|
| + last_reset.new_count);
|
| + new_stats.AddValue64(accumulated.new_size + recent.new_size -
|
| + last_reset.new_size);
|
| }
|
| {
|
| JSONArray old_stats(&obj, "old");
|
| - old_stats.AddValue(allocated_before_gc_old_space);
|
| - old_stats.AddValue(allocated_size_before_gc_old_space);
|
| - old_stats.AddValue(live_after_gc_old_space);
|
| - old_stats.AddValue(live_size_after_gc_old_space);
|
| - old_stats.AddValue(allocated_since_gc_old_space);
|
| - old_stats.AddValue(allocated_size_since_gc_old_space);
|
| + old_stats.AddValue(pre_gc.old_count);
|
| + old_stats.AddValue(pre_gc.old_size);
|
| + old_stats.AddValue(post_gc.old_count);
|
| + old_stats.AddValue(post_gc.old_size);
|
| + old_stats.AddValue(recent.old_count);
|
| + old_stats.AddValue(recent.old_size);
|
| + old_stats.AddValue64(accumulated.old_count + recent.old_count -
|
| + last_reset.old_count);
|
| + old_stats.AddValue64(accumulated.old_size + recent.old_size -
|
| + last_reset.old_size);
|
| }
|
| }
|
|
|
| @@ -220,8 +226,7 @@ void ClassTable::UpdateAllocatedNew(intptr_t cid, intptr_t size) {
|
| ClassHeapStats* stats = StatsAt(cid);
|
| ASSERT(stats != NULL);
|
| ASSERT(size != 0);
|
| - stats->allocated_since_gc_new_space++;
|
| - stats->allocated_size_since_gc_new_space += size;
|
| + stats->recent.AddNew(size);
|
| }
|
|
|
|
|
| @@ -229,8 +234,7 @@ void ClassTable::UpdateAllocatedOld(intptr_t cid, intptr_t size) {
|
| ClassHeapStats* stats = StatsAt(cid);
|
| ASSERT(stats != NULL);
|
| ASSERT(size != 0);
|
| - stats->allocated_since_gc_old_space++;
|
| - stats->allocated_size_since_gc_old_space += size;
|
| + stats->recent.AddOld(size);
|
| }
|
|
|
|
|
| @@ -322,12 +326,48 @@ void ClassTable::AllocationProfilePrintToJSONStream(JSONStream* stream) {
|
| }
|
|
|
|
|
| +void ClassTable::ResetAllocationAccumulators() {
|
| + Class& cls = Class::Handle();
|
| + for (intptr_t i = 1; i < kNumPredefinedCids; i++) {
|
| + if (!HasValidClassAt(i) || (i == kFreeListElement) || (i == kSmiCid)) {
|
| + continue;
|
| + }
|
| + cls = At(i);
|
| + if (!(cls.is_finalized() || cls.is_prefinalized())) {
|
| + // Not finalized.
|
| + continue;
|
| + }
|
| + // Update size before resetting accumulator.
|
| + if (ShouldUpdateSizeForClassId(i)) {
|
| + intptr_t instance_size = cls.instance_size();
|
| + predefined_class_heap_stats_table_[i].UpdateSize(instance_size);
|
| + }
|
| + predefined_class_heap_stats_table_[i].ResetAccumulator();
|
| + }
|
| + for (intptr_t i = kNumPredefinedCids; i < top_; i++) {
|
| + if (!HasValidClassAt(i)) {
|
| + continue;
|
| + }
|
| + cls = At(i);
|
| + if (!(cls.is_finalized() || cls.is_prefinalized())) {
|
| + // Not finalized.
|
| + continue;
|
| + }
|
| + // Update size before resetting accumulator.
|
| + if (ShouldUpdateSizeForClassId(i)) {
|
| + intptr_t instance_size = cls.instance_size();
|
| + class_heap_stats_table_[i].UpdateSize(instance_size);
|
| + }
|
| + class_heap_stats_table_[i].ResetAccumulator();
|
| + }
|
| +}
|
| +
|
| +
|
| void ClassTable::UpdateLiveOld(intptr_t cid, intptr_t size) {
|
| ClassHeapStats* stats = StatsAt(cid);
|
| ASSERT(stats != NULL);
|
| ASSERT(size >= 0);
|
| - stats->live_after_gc_old_space++;
|
| - stats->live_size_after_gc_old_space += size;
|
| + stats->post_gc.AddOld(size);
|
| }
|
|
|
|
|
| @@ -335,8 +375,7 @@ void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) {
|
| ClassHeapStats* stats = StatsAt(cid);
|
| ASSERT(stats != NULL);
|
| ASSERT(size >= 0);
|
| - stats->live_after_gc_new_space++;
|
| - stats->live_size_after_gc_new_space += size;
|
| + stats->post_gc.AddNew(size);
|
| }
|
|
|
|
|
|
|