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

Unified Diff: runtime/vm/assembler_x64.cc

Issue 51653006: Track live instance and allocation counts for classes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/assembler_x64.h ('k') | runtime/vm/class_table.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/assembler_x64.cc
diff --git a/runtime/vm/assembler_x64.cc b/runtime/vm/assembler_x64.cc
index 2b7156ee764e8e18fd905ab2440c8936313b9160..c08cecfd7ae3e32d68f57694b1039f21052267fd 100644
--- a/runtime/vm/assembler_x64.cc
+++ b/runtime/vm/assembler_x64.cc
@@ -2879,6 +2879,74 @@ void Assembler::LeaveStubFrame() {
}
+void Assembler::UpdateAllocationStats(intptr_t cid,
+ Heap::Space space) {
+ Register temp_reg = TMP;
+ ASSERT(cid > 0);
+ Isolate* isolate = Isolate::Current();
+ ClassTable* class_table = isolate->class_table();
+ if (cid < kNumPredefinedCids) {
+ const uword class_heap_stats_table_address =
+ class_table->PredefinedClassHeapStatsTableAddress();
+ const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
+ const uword count_field_offset = (space == Heap::kNew) ?
+ ClassHeapStats::allocated_since_gc_new_space_offset() :
+ ClassHeapStats::allocated_since_gc_old_space_offset();
+ movq(temp_reg, Immediate(class_heap_stats_table_address + class_offset));
+ const Address& count_address = Address(temp_reg, count_field_offset);
+ incq(count_address);
+ } else {
+ ASSERT(temp_reg != kNoRegister);
+ const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
+ const uword count_field_offset = (space == Heap::kNew) ?
+ ClassHeapStats::allocated_since_gc_new_space_offset() :
+ ClassHeapStats::allocated_since_gc_old_space_offset();
+ movq(temp_reg, Immediate(class_table->ClassStatsTableAddress()));
+ movq(temp_reg, Address(temp_reg, 0));
+ incq(Address(temp_reg, class_offset + count_field_offset));
+ }
+}
+
+
+void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
+ Register size_reg,
+ Heap::Space space) {
+ Register temp_reg = TMP;
+ ASSERT(cid > 0);
+ Isolate* isolate = Isolate::Current();
+ ClassTable* class_table = isolate->class_table();
+ if (cid < kNumPredefinedCids) {
+ const uword class_heap_stats_table_address =
+ class_table->PredefinedClassHeapStatsTableAddress();
+ const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
+ const uword count_field_offset = (space == Heap::kNew) ?
+ ClassHeapStats::allocated_since_gc_new_space_offset() :
+ ClassHeapStats::allocated_since_gc_old_space_offset();
+ const uword size_field_offset = (space == Heap::kNew) ?
+ ClassHeapStats::allocated_size_since_gc_new_space_offset() :
+ ClassHeapStats::allocated_size_since_gc_old_space_offset();
+ movq(temp_reg, Immediate(class_heap_stats_table_address + class_offset));
+ const Address& count_address = Address(temp_reg, count_field_offset);
+ const Address& size_address = Address(temp_reg, size_field_offset);
+ incq(count_address);
+ addq(size_address, size_reg);
+ } else {
+ ASSERT(temp_reg != kNoRegister);
+ const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
+ const uword count_field_offset = (space == Heap::kNew) ?
+ ClassHeapStats::allocated_since_gc_new_space_offset() :
+ ClassHeapStats::allocated_since_gc_old_space_offset();
+ const uword size_field_offset = (space == Heap::kNew) ?
+ ClassHeapStats::allocated_size_since_gc_new_space_offset() :
+ ClassHeapStats::allocated_size_since_gc_old_space_offset();
+ movq(temp_reg, Immediate(class_table->ClassStatsTableAddress()));
+ movq(temp_reg, Address(temp_reg, 0));
+ incq(Address(temp_reg, class_offset + count_field_offset));
+ addq(Address(temp_reg, class_offset + size_field_offset), size_reg);
+ }
+}
+
+
void Assembler::TryAllocate(const Class& cls,
Label* failure,
bool near_jump,
@@ -2899,6 +2967,7 @@ void Assembler::TryAllocate(const Class& cls,
// next object start and store the class in the class field of object.
LoadImmediate(TMP, Immediate(heap->TopAddress()), pp);
movq(Address(TMP, 0), instance_reg);
+ UpdateAllocationStats(cls.id());
ASSERT(instance_size >= kHeapObjectTag);
AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size), pp);
uword tags = 0;
« no previous file with comments | « runtime/vm/assembler_x64.h ('k') | runtime/vm/class_table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698