Chromium Code Reviews| Index: third_party/tcmalloc/chromium/src/deep-heap-profile.cc |
| diff --git a/third_party/tcmalloc/chromium/src/deep-heap-profile.cc b/third_party/tcmalloc/chromium/src/deep-heap-profile.cc |
| index fb2143c9f405f054bda3c2b6bf4e151575b30ec2..3577d04c92989b60bc4848ea31b70e96df744bed 100644 |
| --- a/third_party/tcmalloc/chromium/src/deep-heap-profile.cc |
| +++ b/third_party/tcmalloc/chromium/src/deep-heap-profile.cc |
| @@ -435,7 +435,11 @@ void DeepHeapProfile::AddIntegerToHashValue( |
| // ignored in usual Chromium runs. Another hash function can be tried in an |
| // easy way in future. |
| DeepHeapProfile::DeepBucket* DeepHeapProfile::GetDeepBucket( |
| - Bucket* bucket, bool is_mmap, DeepBucket **table) { |
| + Bucket* bucket, bool is_mmap, |
| +#if defined(PROFILING_ALLOCATED_TYPE) |
| + const std::type_info* type, |
| +#endif |
| + DeepBucket **table) { |
| // Make hash-value |
| uintptr_t h = 0; |
| @@ -444,6 +448,12 @@ DeepHeapProfile::DeepBucket* DeepHeapProfile::GetDeepBucket( |
| AddIntegerToHashValue(1, &h); |
| else |
| AddIntegerToHashValue(0, &h); |
| +#if defined(PROFILING_ALLOCATED_TYPE) |
| + if (type == NULL) |
|
M-A Ruel
2012/08/19 02:40:00
Mixing #if and conditions without bracket is a rec
Dai Mikurube (NOT FULLTIME)
2012/08/20 10:35:27
Done.
|
| + AddIntegerToHashValue(0, &h); |
| + else |
| + AddIntegerToHashValue(reinterpret_cast<uintptr_t>(type->name()), &h); |
| +#endif |
| h += h << 3; |
| h ^= h >> 11; |
| @@ -461,6 +471,9 @@ DeepHeapProfile::DeepBucket* DeepHeapProfile::GetDeepBucket( |
| reinterpret_cast<DeepBucket*>(heap_profile_->alloc_(sizeof(DeepBucket))); |
| memset(db, 0, sizeof(*db)); |
| db->bucket = bucket; |
| +#if defined(PROFILING_ALLOCATED_TYPE) |
| + db->type = type; |
| +#endif |
| db->committed_size = 0; |
| db->is_mmap = is_mmap; |
| db->id = (bucket_id_++); |
| @@ -521,7 +534,11 @@ void DeepHeapProfile::RecordAlloc(const void* pointer, |
| address, address + alloc_value->bytes - 1); |
| DeepBucket* deep_bucket = deep_profile->GetDeepBucket( |
| - alloc_value->bucket(), /* is_mmap */ false, deep_profile->deep_table_); |
| + alloc_value->bucket(), /* is_mmap */ false, |
| +#if defined(PROFILING_ALLOCATED_TYPE) |
| + LookupAllocatedType(pointer), |
| +#endif |
| + deep_profile->deep_table_); |
| deep_bucket->committed_size += committed; |
| deep_profile->stats_.profiled_malloc.AddToVirtualBytes(alloc_value->bytes); |
| deep_profile->stats_.profiled_malloc.AddToCommittedBytes(committed); |
| @@ -535,7 +552,11 @@ void DeepHeapProfile::RecordMMap(const void* pointer, |
| address, address + alloc_value->bytes - 1); |
| DeepBucket* deep_bucket = deep_profile->GetDeepBucket( |
| - alloc_value->bucket(), /* is_mmap */ true, deep_profile->deep_table_); |
| + alloc_value->bucket(), /* is_mmap */ true, |
| +#if defined(PROFILING_ALLOCATED_TYPE) |
| + NULL, |
| +#endif |
| + deep_profile->deep_table_); |
| deep_bucket->committed_size += committed; |
| deep_profile->stats_.profiled_mmap.AddToVirtualBytes(alloc_value->bytes); |
| deep_profile->stats_.profiled_mmap.AddToCommittedBytes(committed); |
| @@ -583,6 +604,28 @@ int DeepHeapProfile::FillBucketForBucketFile(const DeepBucket* deep_bucket, |
| } |
| used_in_buffer += printed; |
| +#if defined(PROFILING_ALLOCATED_TYPE) |
| + printed = snprintf(buffer + used_in_buffer, buffer_size - used_in_buffer, |
| + " t0x%" PRIxPTR, |
| + reinterpret_cast<uintptr_t>(deep_bucket->type)); |
| + if (IsPrintedStringValid(printed, buffer_size, used_in_buffer)) { |
| + return used_in_buffer; |
| + } |
| + used_in_buffer += printed; |
| + |
| + if (deep_bucket->type == NULL) { |
| + printed = snprintf(buffer + used_in_buffer, buffer_size - used_in_buffer, |
| + " nno_typeinfo"); |
| + } else { |
| + printed = snprintf(buffer + used_in_buffer, buffer_size - used_in_buffer, |
| + " n%s", deep_bucket->type->name()); |
| + } |
| + if (IsPrintedStringValid(printed, buffer_size, used_in_buffer)) { |
| + return used_in_buffer; |
| + } |
| + used_in_buffer += printed; |
| +#endif |
| + |
| for (int depth = 0; depth < bucket->depth; depth++) { |
| printed = snprintf(buffer + used_in_buffer, buffer_size - used_in_buffer, |
| " 0x%08" PRIxPTR, |