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

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 6a7af21729e638e7aedf9f3532f7644fba8078b6..772d79852c3087abdb80bde84e9bcf17ea80ee68 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"
@@ -2252,11 +2253,30 @@ 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,
- Register instance_reg) {
+ Register instance_reg,
+ Register temp_reg) {
ASSERT(failure != NULL);
+ ASSERT(temp_reg != kNoRegister);
if (FLAG_inline_alloc) {
Heap* heap = Isolate::Current()->heap();
const intptr_t instance_size = cls.instance_size();
@@ -2268,6 +2288,7 @@ 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);
+ BumpAllocationCount(cls.id(), temp_reg);
ASSERT(instance_size >= kHeapObjectTag);
subl(instance_reg, Immediate(instance_size - kHeapObjectTag));
uword tags = 0;

Powered by Google App Engine
This is Rietveld 408576698