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

Unified Diff: runtime/vm/assembler_ia32.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 7 years, 2 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
Index: runtime/vm/assembler_ia32.cc
diff --git a/runtime/vm/assembler_ia32.cc b/runtime/vm/assembler_ia32.cc
index 8f6164fcfef9614c1d1274517dbbf0993e02246e..71337266955d9c97c02a1b4ceb1bbe71fd3895dd 100644
--- a/runtime/vm/assembler_ia32.cc
+++ b/runtime/vm/assembler_ia32.cc
@@ -8,6 +8,7 @@
#include "vm/assembler.h"
#include "vm/code_generator.h"
#include "vm/heap.h"
+#include "vm/heap_class_stats.h"
#include "vm/memory_region.h"
#include "vm/runtime_entry.h"
#include "vm/stack_frame.h"
@@ -2263,6 +2264,23 @@ void Assembler::Bind(Label* label) {
}
+// Updates the allocation count for cid.
+void Assembler::BumpAllocationCount(intptr_t cid,
+ Register temp_reg) {
+ ASSERT(temp_reg != kNoRegister);
+ HeapClassStatistics* heap_class_stats =
+ Isolate::Current()->heap_class_stats();
+ // temp_reg gets address of class table pointer.
+ movl(temp_reg, Address::Absolute(heap_class_stats->ClassStatsTableAddress()));
+ // Offset into class table.
+ const intptr_t offset = cid * sizeof(HeapClassData); // NOLINT
+ // temp_reg points at HeapClassData for cid + offset to allocation count.
+ leal(temp_reg, Address(temp_reg, offset));
+ // Increment allocation count.
+ addl(Address(temp_reg, HeapClassData::allocated_since_gc_offset()),
+ Immediate(1));
+}
+
void Assembler::TryAllocate(const Class& cls,
Label* failure,
bool near_jump,
@@ -2279,6 +2297,9 @@ void Assembler::TryAllocate(const Class& cls,
// Successfully allocated the object, now update top to point to
// next object start and store the class in the class field of object.
movl(Address::Absolute(heap->TopAddress()), instance_reg);
+ pushl(instance_reg);
Florian Schneider 2013/10/31 09:56:01 I suspect that this will make bump allocation a _l
Cutch 2013/10/31 11:20:02 I will run some tests tomorrow against patch set 2
+ BumpAllocationCount(cls.id(), instance_reg);
+ popl(instance_reg);
ASSERT(instance_size >= kHeapObjectTag);
subl(instance_reg, Immediate(instance_size - kHeapObjectTag));
uword tags = 0;

Powered by Google App Engine
This is Rietveld 408576698