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

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

Issue 1241863002: VM: Refactor allocation stats code and remove duplicate code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comments Created 5 years, 5 months 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
« no previous file with comments | « runtime/vm/class_table.h ('k') | runtime/vm/dart_api_impl_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/growable_array.h" 8 #include "vm/growable_array.h"
9 #include "vm/heap.h" 9 #include "vm/heap.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 void ClassTable::UpdatePromoted() { 415 void ClassTable::UpdatePromoted() {
416 for (intptr_t i = 0; i < kNumPredefinedCids; i++) { 416 for (intptr_t i = 0; i < kNumPredefinedCids; i++) {
417 predefined_class_heap_stats_table_[i].UpdatePromotedAfterNewGC(); 417 predefined_class_heap_stats_table_[i].UpdatePromotedAfterNewGC();
418 } 418 }
419 for (intptr_t i = kNumPredefinedCids; i < top_; i++) { 419 for (intptr_t i = kNumPredefinedCids; i < top_; i++) {
420 class_heap_stats_table_[i].UpdatePromotedAfterNewGC(); 420 class_heap_stats_table_[i].UpdatePromotedAfterNewGC();
421 } 421 }
422 } 422 }
423 423
424 424
425 ClassHeapStats** ClassTable::TableAddressFor(intptr_t cid) {
426 return (cid < kNumPredefinedCids)
427 ? &predefined_class_heap_stats_table_
428 : &class_heap_stats_table_;
429 }
430
431
432 intptr_t ClassTable::TableOffsetFor(intptr_t cid) {
433 return (cid < kNumPredefinedCids)
434 ? OFFSET_OF(ClassTable, predefined_class_heap_stats_table_)
435 : OFFSET_OF(ClassTable, class_heap_stats_table_);
436 }
437
438
439 intptr_t ClassTable::ClassOffsetFor(intptr_t cid) {
440 return cid * sizeof(ClassHeapStats); // NOLINT
441 }
442
443
444 intptr_t ClassTable::CounterOffsetFor(intptr_t cid, bool is_new_space) {
445 const intptr_t class_offset = ClassOffsetFor(cid);
446 const intptr_t count_field_offset = is_new_space
447 ? ClassHeapStats::allocated_since_gc_new_space_offset()
448 : ClassHeapStats::allocated_since_gc_old_space_offset();
449 return class_offset + count_field_offset;
450 }
451
452
453 ClassHeapStats** ClassTable::StateAddressFor(intptr_t cid,
454 intptr_t* state_offset) {
455 *state_offset = ClassOffsetFor(cid)+ ClassHeapStats::state_offset();
456 return TableAddressFor(cid);
457 }
458
459
460 intptr_t ClassTable::SizeOffsetFor(intptr_t cid, bool is_new_space) {
461 const uword class_offset = ClassOffsetFor(cid);
462 const uword size_field_offset = is_new_space
463 ? ClassHeapStats::allocated_size_since_gc_new_space_offset()
464 : ClassHeapStats::allocated_size_since_gc_old_space_offset();
465 return class_offset + size_field_offset;
466 }
467
468
425 void ClassTable::AllocationProfilePrintJSON(JSONStream* stream) { 469 void ClassTable::AllocationProfilePrintJSON(JSONStream* stream) {
426 Isolate* isolate = Isolate::Current(); 470 Isolate* isolate = Isolate::Current();
427 ASSERT(isolate != NULL); 471 ASSERT(isolate != NULL);
428 Heap* heap = isolate->heap(); 472 Heap* heap = isolate->heap();
429 ASSERT(heap != NULL); 473 ASSERT(heap != NULL);
430 JSONObject obj(stream); 474 JSONObject obj(stream);
431 obj.AddProperty("type", "AllocationProfile"); 475 obj.AddProperty("type", "AllocationProfile");
432 obj.AddPropertyF( 476 obj.AddPropertyF(
433 "dateLastAccumulatorReset", 477 "dateLastAccumulatorReset",
434 "%" Pd64 "", 478 "%" Pd64 "",
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 526
483 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { 527 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) {
484 ClassHeapStats* stats = PreliminaryStatsAt(cid); 528 ClassHeapStats* stats = PreliminaryStatsAt(cid);
485 ASSERT(stats != NULL); 529 ASSERT(stats != NULL);
486 ASSERT(size >= 0); 530 ASSERT(size >= 0);
487 stats->post_gc.AddNew(size); 531 stats->post_gc.AddNew(size);
488 } 532 }
489 533
490 534
491 } // namespace dart 535 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/class_table.h ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698