| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // --- | 5 // --- |
| 6 // Author: Sainbayar Sukhbaatar | 6 // Author: Sainbayar Sukhbaatar |
| 7 // Dai Mikurube | 7 // Dai Mikurube |
| 8 // | 8 // |
| 9 // This file contains a class DeepHeapProfile and its public function | 9 // This file contains a class DeepHeapProfile and its public function |
| 10 // DeepHeapProfile::FillOrderedProfile() which works as an alternative of | 10 // DeepHeapProfile::FillOrderedProfile() which works as an alternative of |
| 11 // HeapProfileTable::FillOrderedProfile(). | 11 // HeapProfileTable::FillOrderedProfile(). |
| 12 // | 12 // |
| 13 // DeepHeapProfile::FillOrderedProfile() dumps more detailed information about | 13 // DeepHeapProfile::FillOrderedProfile() dumps more detailed information about |
| 14 // heap usage, which includes OS-level information such as whether the memory | 14 // heap usage, which includes OS-level information such as whether the memory |
| 15 // block is actually in memory, or not. DeepHeapProfile::FillOrderedProfile() | 15 // block is actually in memory, or not. DeepHeapProfile::FillOrderedProfile() |
| 16 // uses logged data in HeapProfileTable as one of its data sources. | 16 // uses logged data in HeapProfileTable as one of its data sources. |
| 17 // DeepHeapProfile works only when its FillOrderedProfile() is called. It has | 17 // DeepHeapProfile works only when its FillOrderedProfile() is called. It has |
| 18 // overhead when dumping, but no overhead when logging. | 18 // overhead when dumping, but no overhead when logging. |
| 19 // | 19 // |
| 20 // It currently works only on Linux. It just delegates to HeapProfileTable in | 20 // It currently works only on Linux. It just delegates to HeapProfileTable in |
| 21 // non-Linux environments. | 21 // non-Linux environments. |
| 22 | 22 |
| 23 | 23 |
| 24 #ifndef BASE_DEEP_HEAP_PROFILE_H_ | 24 #ifndef BASE_DEEP_HEAP_PROFILE_H_ |
| 25 #define BASE_DEEP_HEAP_PROFILE_H_ | 25 #define BASE_DEEP_HEAP_PROFILE_H_ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 | 28 |
| 29 #if defined(TYPE_PROFILING) |
| 30 #include <typeinfo> |
| 31 #endif |
| 32 |
| 29 #if defined(__linux__) | 33 #if defined(__linux__) |
| 30 #define DEEP_HEAP_PROFILE 1 | 34 #define DEEP_HEAP_PROFILE 1 |
| 31 #endif | 35 #endif |
| 32 | 36 |
| 33 #include "addressmap-inl.h" | 37 #include "addressmap-inl.h" |
| 34 #include "heap-profile-table.h" | 38 #include "heap-profile-table.h" |
| 35 | 39 |
| 36 class DeepHeapProfile { | 40 class DeepHeapProfile { |
| 37 public: | 41 public: |
| 38 typedef HeapProfileTable::Bucket Bucket; | 42 typedef HeapProfileTable::Bucket Bucket; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // of HeapProfileTable::FillOrderedProfile. | 84 // of HeapProfileTable::FillOrderedProfile. |
| 81 // | 85 // |
| 82 // The profile buckets are dumped in the decreasing order of currently | 86 // The profile buckets are dumped in the decreasing order of currently |
| 83 // allocated bytes. We do not provision for 0-terminating |buffer|. | 87 // allocated bytes. We do not provision for 0-terminating |buffer|. |
| 84 int FillOrderedProfile(char buffer[], int buffer_size); | 88 int FillOrderedProfile(char buffer[], int buffer_size); |
| 85 | 89 |
| 86 private: | 90 private: |
| 87 #ifdef DEEP_HEAP_PROFILE | 91 #ifdef DEEP_HEAP_PROFILE |
| 88 struct DeepBucket { | 92 struct DeepBucket { |
| 89 Bucket* bucket; | 93 Bucket* bucket; |
| 94 #if defined(TYPE_PROFILING) |
| 95 const std::type_info* type; |
| 96 #endif |
| 90 size_t committed_size; | 97 size_t committed_size; |
| 91 bool is_mmap; | 98 bool is_mmap; |
| 92 int id; // Unique ID of the bucket. | 99 int id; // Unique ID of the bucket. |
| 93 bool is_logged; // True if the stracktrace is logged to a file. | 100 bool is_logged; // True if the stracktrace is logged to a file. |
| 94 DeepBucket* next; // Next entry in hash-table. | 101 DeepBucket* next; // Next entry in hash-table. |
| 95 }; | 102 }; |
| 96 | 103 |
| 97 typedef AddressMap<DeepBucket> DeepBucketMap; | 104 typedef AddressMap<DeepBucket> DeepBucketMap; |
| 98 | 105 |
| 99 struct PageState { | 106 struct PageState { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 GlobalStats* stats, | 211 GlobalStats* stats, |
| 205 MMapListEntry* mmap_list, | 212 MMapListEntry* mmap_list, |
| 206 int mmap_list_length); | 213 int mmap_list_length); |
| 207 | 214 |
| 208 // Add a uintptr_t integer to a hash-value for GetDeepBucket. | 215 // Add a uintptr_t integer to a hash-value for GetDeepBucket. |
| 209 inline static void AddIntegerToHashValue( | 216 inline static void AddIntegerToHashValue( |
| 210 uintptr_t add, uintptr_t* hash_value); | 217 uintptr_t add, uintptr_t* hash_value); |
| 211 | 218 |
| 212 // Get the DeepBucket object corresponding to the given |bucket|. | 219 // Get the DeepBucket object corresponding to the given |bucket|. |
| 213 // DeepBucket is an extension to Bucket which is declared above. | 220 // DeepBucket is an extension to Bucket which is declared above. |
| 214 DeepBucket* GetDeepBucket(Bucket* bucket, bool is_mmap, DeepBucket** table); | 221 DeepBucket* GetDeepBucket(Bucket* bucket, bool is_mmap, |
| 222 #if defined(TYPE_PROFILING) |
| 223 const std::type_info* type, |
| 224 #endif |
| 225 DeepBucket** table); |
| 215 | 226 |
| 216 // Reset committed_size member variables in DeepBucket objects to 0. | 227 // Reset committed_size member variables in DeepBucket objects to 0. |
| 217 void ResetCommittedSize(DeepBucket** deep_table); | 228 void ResetCommittedSize(DeepBucket** deep_table); |
| 218 | 229 |
| 219 // Fill bucket data in |bucket_table| into buffer |buffer| of size | 230 // Fill bucket data in |bucket_table| into buffer |buffer| of size |
| 220 // |buffer_size|, and return the size occupied by the bucket data in | 231 // |buffer_size|, and return the size occupied by the bucket data in |
| 221 // |buffer|. |bucket_length| is the offset for |buffer| to start filling. | 232 // |buffer|. |bucket_length| is the offset for |buffer| to start filling. |
| 222 int SnapshotBucketTableWithoutMalloc(DeepBucket** deep_table, | 233 int SnapshotBucketTableWithoutMalloc(DeepBucket** deep_table, |
| 223 int used_in_buffer, | 234 int used_in_buffer, |
| 224 int buffer_size, | 235 int buffer_size, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 int mmap_list_length_; | 300 int mmap_list_length_; |
| 290 int num_mmap_allocations_; | 301 int num_mmap_allocations_; |
| 291 #endif // DEEP_HEAP_PROFILE | 302 #endif // DEEP_HEAP_PROFILE |
| 292 | 303 |
| 293 HeapProfileTable* heap_profile_; | 304 HeapProfileTable* heap_profile_; |
| 294 | 305 |
| 295 DISALLOW_COPY_AND_ASSIGN(DeepHeapProfile); | 306 DISALLOW_COPY_AND_ASSIGN(DeepHeapProfile); |
| 296 }; | 307 }; |
| 297 | 308 |
| 298 #endif // BASE_DEEP_HEAP_PROFILE_H_ | 309 #endif // BASE_DEEP_HEAP_PROFILE_H_ |
| OLD | NEW |