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

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: make context allocation isolate-independent 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
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 ClassHeapStats** ClassTable::CountAddressFor(intptr_t cid,
445 bool is_new_space,
446 intptr_t* offset) {
447 const intptr_t class_offset = ClassOffsetFor(cid);
448 const intptr_t count_field_offset = is_new_space
449 ? ClassHeapStats::allocated_since_gc_new_space_offset()
450 : ClassHeapStats::allocated_since_gc_old_space_offset();
451 *offset = class_offset + count_field_offset;
452 return TableAddressFor(cid);
453 }
454
455
456 ClassHeapStats** ClassTable::StateAddressFor(intptr_t cid, intptr_t* offset) {
457 const uword class_offset = ClassOffsetFor(cid);
458 const uword state_offset = ClassHeapStats::state_offset();
459 *offset = class_offset + state_offset;
460 return TableAddressFor(cid);
461 }
462
463
464 intptr_t ClassTable::SizeOffsetFor(intptr_t cid, bool is_new_space) {
465 const uword class_offset = ClassOffsetFor(cid);
466 const uword size_field_offset = is_new_space
467 ? ClassHeapStats::allocated_size_since_gc_new_space_offset()
468 : ClassHeapStats::allocated_size_since_gc_old_space_offset();
469 return class_offset + size_field_offset;
470 }
471
472
425 void ClassTable::AllocationProfilePrintJSON(JSONStream* stream) { 473 void ClassTable::AllocationProfilePrintJSON(JSONStream* stream) {
426 Isolate* isolate = Isolate::Current(); 474 Isolate* isolate = Isolate::Current();
427 ASSERT(isolate != NULL); 475 ASSERT(isolate != NULL);
428 Heap* heap = isolate->heap(); 476 Heap* heap = isolate->heap();
429 ASSERT(heap != NULL); 477 ASSERT(heap != NULL);
430 JSONObject obj(stream); 478 JSONObject obj(stream);
431 obj.AddProperty("type", "AllocationProfile"); 479 obj.AddProperty("type", "AllocationProfile");
432 obj.AddPropertyF( 480 obj.AddPropertyF(
433 "dateLastAccumulatorReset", 481 "dateLastAccumulatorReset",
434 "%" Pd64 "", 482 "%" Pd64 "",
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 530
483 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) { 531 void ClassTable::UpdateLiveNew(intptr_t cid, intptr_t size) {
484 ClassHeapStats* stats = PreliminaryStatsAt(cid); 532 ClassHeapStats* stats = PreliminaryStatsAt(cid);
485 ASSERT(stats != NULL); 533 ASSERT(stats != NULL);
486 ASSERT(size >= 0); 534 ASSERT(size >= 0);
487 stats->post_gc.AddNew(size); 535 stats->post_gc.AddNew(size);
488 } 536 }
489 537
490 538
491 } // namespace dart 539 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698