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

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

Issue 747463002: Fix allocation stats bug on ARM; add unit test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/class_table.h ('k') | runtime/vm/heap_test.cc » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/class_table.h" 5 #include "vm/class_table.h"
6 #include "vm/flags.h" 6 #include "vm/flags.h"
7 #include "vm/freelist.h" 7 #include "vm/freelist.h"
8 #include "vm/heap.h" 8 #include "vm/heap.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/raw_object.h" 10 #include "vm/raw_object.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 post_gc.Reset(); 205 post_gc.Reset();
206 recent.Reset(); 206 recent.Reset();
207 accumulated.Reset(); 207 accumulated.Reset();
208 last_reset.Reset(); 208 last_reset.Reset();
209 promoted_count = 0; 209 promoted_count = 0;
210 promoted_size = 0; 210 promoted_size = 0;
211 } 211 }
212 212
213 213
214 void ClassHeapStats::ResetAtNewGC() { 214 void ClassHeapStats::ResetAtNewGC() {
215 Verify();
215 pre_gc.new_count = post_gc.new_count + recent.new_count; 216 pre_gc.new_count = post_gc.new_count + recent.new_count;
216 pre_gc.new_size = post_gc.new_size + recent.new_size; 217 pre_gc.new_size = post_gc.new_size + recent.new_size;
217 // Accumulate allocations. 218 // Accumulate allocations.
218 accumulated.new_count += recent.new_count - last_reset.new_count; 219 accumulated.new_count += recent.new_count - last_reset.new_count;
219 accumulated.new_size += recent.new_size - last_reset.new_size; 220 accumulated.new_size += recent.new_size - last_reset.new_size;
220 last_reset.ResetNew(); 221 last_reset.ResetNew();
221 post_gc.ResetNew(); 222 post_gc.ResetNew();
222 recent.ResetNew(); 223 recent.ResetNew();
223 old_pre_new_gc_count_ = recent.old_count; 224 old_pre_new_gc_count_ = recent.old_count;
224 old_pre_new_gc_size_ = recent.old_size; 225 old_pre_new_gc_size_ = recent.old_size;
225 } 226 }
226 227
227 228
228 void ClassHeapStats::ResetAtOldGC() { 229 void ClassHeapStats::ResetAtOldGC() {
230 Verify();
229 pre_gc.old_count = post_gc.old_count + recent.old_count; 231 pre_gc.old_count = post_gc.old_count + recent.old_count;
230 pre_gc.old_size = post_gc.old_size + recent.old_size; 232 pre_gc.old_size = post_gc.old_size + recent.old_size;
231 // Accumulate allocations. 233 // Accumulate allocations.
232 accumulated.old_count += recent.old_count - last_reset.old_count; 234 accumulated.old_count += recent.old_count - last_reset.old_count;
233 accumulated.old_size += recent.old_size - last_reset.old_size; 235 accumulated.old_size += recent.old_size - last_reset.old_size;
234 last_reset.ResetOld(); 236 last_reset.ResetOld();
235 post_gc.ResetOld(); 237 post_gc.ResetOld();
236 recent.ResetOld(); 238 recent.ResetOld();
237 } 239 }
238 240
239 241
242 void ClassHeapStats::Verify() {
243 pre_gc.Verify();
244 post_gc.Verify();
245 recent.Verify();
246 accumulated.Verify();
247 last_reset.Verify();
248 }
249
250
240 void ClassHeapStats::UpdateSize(intptr_t instance_size) { 251 void ClassHeapStats::UpdateSize(intptr_t instance_size) {
241 pre_gc.UpdateSize(instance_size); 252 pre_gc.UpdateSize(instance_size);
242 post_gc.UpdateSize(instance_size); 253 post_gc.UpdateSize(instance_size);
243 recent.UpdateSize(instance_size); 254 recent.UpdateSize(instance_size);
244 accumulated.UpdateSize(instance_size); 255 accumulated.UpdateSize(instance_size);
245 last_reset.UpdateSize(instance_size); 256 last_reset.UpdateSize(instance_size);
246 promoted_size = promoted_count * instance_size; 257 promoted_size = promoted_count * instance_size;
247 old_pre_new_gc_size_ = old_pre_new_gc_count_ * instance_size; 258 old_pre_new_gc_size_ = old_pre_new_gc_count_ * instance_size;
248 } 259 }
249 260
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 } 349 }
339 Class& cls = Class::Handle(At(cid)); 350 Class& cls = Class::Handle(At(cid));
340 if (!(cls.is_finalized() || cls.is_prefinalized())) { 351 if (!(cls.is_finalized() || cls.is_prefinalized())) {
341 // Not finalized. 352 // Not finalized.
342 return NULL; 353 return NULL;
343 } 354 }
344 ClassHeapStats* stats = PreliminaryStatsAt(cid); 355 ClassHeapStats* stats = PreliminaryStatsAt(cid);
345 if (ShouldUpdateSizeForClassId(cid)) { 356 if (ShouldUpdateSizeForClassId(cid)) {
346 stats->UpdateSize(cls.instance_size()); 357 stats->UpdateSize(cls.instance_size());
347 } 358 }
359 stats->Verify();
348 return stats; 360 return stats;
349 } 361 }
350 362
351 363
352 void ClassTable::ResetCountersOld() { 364 void ClassTable::ResetCountersOld() {
353 for (intptr_t i = 0; i < kNumPredefinedCids; i++) { 365 for (intptr_t i = 0; i < kNumPredefinedCids; i++) {
354 predefined_class_heap_stats_table_[i].ResetAtOldGC(); 366 predefined_class_heap_stats_table_[i].ResetAtOldGC();
355 } 367 }
356 for (intptr_t i = kNumPredefinedCids; i < top_; i++) { 368 for (intptr_t i = kNumPredefinedCids; i < top_; i++) {
357 class_heap_stats_table_[i].ResetAtOldGC(); 369 class_heap_stats_table_[i].ResetAtOldGC();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 452
441 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { 453 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) {
442 ClassHeapStats* stats = PreliminaryStatsAt(cid); 454 ClassHeapStats* stats = PreliminaryStatsAt(cid);
443 ASSERT(stats != NULL); 455 ASSERT(stats != NULL);
444 ASSERT(size >= 0); 456 ASSERT(size >= 0);
445 stats->post_gc.AddNew(size); 457 stats->post_gc.AddNew(size);
446 } 458 }
447 459
448 460
449 } // namespace dart 461 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_table.h ('k') | runtime/vm/heap_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698