Index: base/trace_event/memory_profiler_allocation_context.h |
diff --git a/base/trace_event/memory_profiler_allocation_context.h b/base/trace_event/memory_profiler_allocation_context.h |
index c9b8f737f095f61c33a5928aa45cbd1ce4e5d313..94333664dd93b7098a5dd95ca8fd0555f67bb233 100644 |
--- a/base/trace_event/memory_profiler_allocation_context.h |
+++ b/base/trace_event/memory_profiler_allocation_context.h |
@@ -69,25 +69,16 @@ class BASE_EXPORT AllocationStack { |
// |
// See the design doc (https://goo.gl/4s7v7b) for more details. |
-// The allocation context is context metadata that is kept for every allocation |
-// when heap profiling is enabled. To simplify memory management for |
-// bookkeeping, this struct has a fixed size. All |const char*|s here |
-// must have static lifetime. |
-struct BASE_EXPORT AllocationContext { |
- struct Backtrace { |
- // Unused backtrace frames are filled with nullptr frames. If the stack is |
- // higher than what can be stored here, the bottom frames are stored. Based |
- // on the data above, a depth of 12 captures the full stack in the vast |
- // majority of the cases. |
- StackFrame frames[12]; |
- } backtrace; |
- |
- // There is room for two arbitrary context fields, which can be set by the |
- // |TRACE_ALLOCATION_CONTEXT| macro. A nullptr key indicates that the field is |
- // unused. |
- std::pair<const char*, const char*> fields[2]; |
+struct BASE_EXPORT Backtrace { |
+ // Unused backtrace frames are filled with nullptr frames. If the stack is |
+ // higher than what can be stored here, the bottom frames are stored. Based |
+ // on the data above, a depth of 12 captures the full stack in the vast |
+ // majority of the cases. |
+ StackFrame frames[12]; |
}; |
+bool BASE_EXPORT operator==(const Backtrace& lhs, const Backtrace& rhs); |
+ |
// A data structure that allows grouping a set of backtraces in a space- |
// efficient manner by creating a call tree and writing it as a set of (node, |
// parent) pairs. The tree nodes reference both parent and children. The parent |
@@ -117,10 +108,9 @@ class BASE_EXPORT StackFrameDeduplicator { |
StackFrameDeduplicator(); |
~StackFrameDeduplicator(); |
- // Inserts a backtrace and returns the index of its leaf node in the range |
- // defined by |begin| and |end|. I.e. if this returns |n|, the node is |
- // |begin() + n|. Returns -1 if the backtrace is empty. |
- int Insert(const AllocationContext::Backtrace& bt); |
+ // Inserts a backtrace and returns the index of its leaf node in |frames_|. |
+ // Returns -1 if the backtrace is empty. |
+ int Insert(const Backtrace& bt); |
// Iterators over the frame nodes in the call tree. |
ConstIterator begin() const { return frames_.begin(); } |
@@ -133,6 +123,19 @@ class BASE_EXPORT StackFrameDeduplicator { |
DISALLOW_COPY_AND_ASSIGN(StackFrameDeduplicator); |
}; |
+// The allocation context is context metadata that is kept for every allocation |
Primiano Tucci (use gerrit)
2015/10/27 11:56:20
s/allocation context/AllocationContext/
Ruud van Asseldonk
2015/10/27 11:59:31
Done.
|
+// when heap profiling is enabled. To simplify memory management for |
+// bookkeeping, this struct has a fixed size. All |const char*|s here |
+// must have static lifetime. |
+struct BASE_EXPORT AllocationContext { |
+ Backtrace backtrace; |
+ |
+ // There is room for two arbitrary context fields, which can be set by the |
+ // |TRACE_ALLOCATION_CONTEXT| macro. A nullptr key indicates that the field is |
+ // unused. |
+ std::pair<const char*, const char*> fields[2]; |
+}; |
+ |
// The allocation context tracker keeps track of thread-local context for heap |
// profiling. It includes a pseudo stack of trace events, and it might contain |
// arbitrary (key, value) context. On every allocation the tracker provides a |
@@ -197,4 +200,13 @@ class BASE_EXPORT AllocationContextTracker { |
} // namespace trace_event |
} // namespace base |
+namespace BASE_HASH_NAMESPACE { |
+ |
+template <> |
+struct hash<base::trace_event::Backtrace> { |
+ uint32_t operator()(const base::trace_event::Backtrace& backtrace) const; |
Primiano Tucci (use gerrit)
2015/10/27 11:56:20
I think you should return size_t here and just let
Ruud van Asseldonk
2015/10/27 11:59:31
Done.
|
+}; |
+ |
+} // BASE_HASH_NAMESPACE |
+ |
#endif // BASE_TRACE_EVENT_MEMORY_PROFILER_ALLOCATION_CONTEXT_H_ |