Index: src/heap-inl.h |
diff --git a/src/heap-inl.h b/src/heap-inl.h |
index 64125bc302c7d275133974a54f0566eb0126c916..6cf6da0993e6a84ccbc8b9b57ae23fb2ba089c2e 100644 |
--- a/src/heap-inl.h |
+++ b/src/heap-inl.h |
@@ -235,6 +235,43 @@ AllocationResult Heap::AllocateRaw(int size_in_bytes, |
} |
+void Heap::OnAllocationEvent(HeapObject* object, int size_in_bytes) { |
+ ++allocations_count_; |
+ |
+ Address object_address = object->address(); |
+ MemoryChunk* memory_chunk = MemoryChunk::FromAddress(object_address); |
+ uint32_t offset = |
+ static_cast<uint32_t>(object_address - memory_chunk->address()); |
+ |
+ UpdateAllocationsHash(offset); |
+ UpdateAllocationsHash(size_in_bytes); |
+ UpdateAllocationsHash(memory_chunk->owner()->identity()); |
+ |
+ if (FLAG_dump_allocations_digest_at_alloc > 0) { |
+ if (--dump_allocations_hash_countdown_ == 0) { |
+ dump_allocations_hash_countdown_ = FLAG_dump_allocations_digest_at_alloc; |
+ PrintAlloctionsHash(); |
+ } |
+ } |
+} |
+ |
+ |
+void Heap::UpdateAllocationsHash(uint32_t value) { |
+ uint16_t c1 = static_cast<uint16_t>(value); |
+ uint16_t c2 = static_cast<uint16_t>(value >> 16); |
+ raw_allocations_hash_ = |
+ StringHasher::AddCharacterCore(raw_allocations_hash_, c1); |
+ raw_allocations_hash_ = |
+ StringHasher::AddCharacterCore(raw_allocations_hash_, c2); |
+} |
+ |
+ |
+void Heap::PrintAlloctionsHash() { |
+ uint32_t hash = StringHasher::GetHashCore(raw_allocations_hash_); |
+ PrintF("\n### Allocations = %u, hash = 0x%08x\n", allocations_count_, hash); |
+} |
+ |
+ |
void Heap::FinalizeExternalString(String* string) { |
ASSERT(string->IsExternalString()); |
v8::String::ExternalStringResourceBase** resource_addr = |