Chromium Code Reviews| Index: third_party/tcmalloc/chromium/src/heap-profile-stats.h | 
| diff --git a/third_party/tcmalloc/chromium/src/heap-profile-stats.h b/third_party/tcmalloc/chromium/src/heap-profile-stats.h | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..064dde0eb0a23c6ce3a5f96ec2d7973b3e80d9ab | 
| --- /dev/null | 
| +++ b/third_party/tcmalloc/chromium/src/heap-profile-stats.h | 
| @@ -0,0 +1,36 @@ | 
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. | 
| +// Use of this source code is governed by a BSD-style license that can be | 
| +// found in the LICENSE file. | 
| + | 
| +// This file defines structs to accumulate memory allocation and deallocation | 
| +// counts. These structs are commonly used for malloc (in HeapProfileTable) | 
| +// and mmap (in MemoryRegionMap). | 
| + | 
| +#ifndef HEAP_PROFILE_STATS_H_ | 
| +#define HEAP_PROFILE_STATS_H_ | 
| + | 
| +struct HeapProfileStats { | 
| + int32 allocs; // Number of allocation calls. | 
| 
 
Alexander Potapenko
2013/03/07 14:50:52
Again, methods before members and DISALLOW_COPY_AN
 
Dai Mikurube (NOT FULLTIME)
2013/03/07 17:14:24
Reordered.  And, I don't add DISALLOW_COPY_AND_ASS
 
 | 
| + int32 frees; // Number of free calls. | 
| + int64 alloc_size; // Total size of all allocated objects so far. | 
| + int64 free_size; // Total size of all freed objects so far. | 
| + | 
| + // Returns true if the two HeapProfileStats are semantically equal. | 
| + bool Equivalent(const HeapProfileStats& x) const { | 
| + return allocs - frees == x.allocs - x.frees && | 
| + alloc_size - free_size == x.alloc_size - x.free_size; | 
| + } | 
| +}; | 
| + | 
| +// Allocation and deallocation statistics per each stack trace. | 
| +struct HeapProfileBucket : public HeapProfileStats { | 
| + // Longest stack trace we record. | 
| + static const int kMaxStackDepth = 32; | 
| + | 
| + uintptr_t hash; // Hash value of the stack trace. | 
| + int depth; // Depth of stack trace. | 
| + const void** stack; // Stack trace. | 
| + HeapProfileBucket* next; // Next entry in hash-table. | 
| +}; | 
| + | 
| +#endif // HEAP_PROFILE_STATS_H_ |