OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ | 5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ |
6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ | 6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 // Set the thread name in the AllocationContextTracker of current thread if | 51 // Set the thread name in the AllocationContextTracker of current thread if |
52 // capture is enabled. | 52 // capture is enabled. |
53 static void SetCurrentThreadName(const char* name); | 53 static void SetCurrentThreadName(const char* name); |
54 | 54 |
55 // Pushes a frame onto the thread-local pseudo stack. | 55 // Pushes a frame onto the thread-local pseudo stack. |
56 void PushPseudoStackFrame(StackFrame frame); | 56 void PushPseudoStackFrame(StackFrame frame); |
57 | 57 |
58 // Pops a frame from the thread-local pseudo stack. | 58 // Pops a frame from the thread-local pseudo stack. |
59 void PopPseudoStackFrame(StackFrame frame); | 59 void PopPseudoStackFrame(StackFrame frame); |
60 | 60 |
61 // Push and pop current task's context. A stack is used to support nested | |
62 // tasks and the top of the stack will be used in allocation context. | |
63 void PushCurrentTaskContext(const char* context); | |
Primiano Tucci (use gerrit)
2016/03/31 15:37:16
I aware about the fact that I am a real pain on na
ssid
2016/03/31 16:02:49
Yes but I feel this will be reused for some other
Primiano Tucci (use gerrit)
2016/03/31 16:10:59
Ahh ok, if you have upcoming use cases in mind it'
ssid
2016/04/01 04:34:54
I changed the comment and function name. wdyt?
Primiano Tucci (use gerrit)
2016/04/01 08:36:16
Much better, thanks.
| |
64 void PopCurrentTaskContext(const char* context); | |
65 | |
61 // Returns a snapshot of the current thread-local context. | 66 // Returns a snapshot of the current thread-local context. |
62 AllocationContext GetContextSnapshot(); | 67 AllocationContext GetContextSnapshot(); |
63 | 68 |
64 ~AllocationContextTracker(); | 69 ~AllocationContextTracker(); |
65 | 70 |
66 private: | 71 private: |
67 AllocationContextTracker(); | 72 AllocationContextTracker(); |
68 | 73 |
69 static subtle::Atomic32 capture_enabled_; | 74 static subtle::Atomic32 capture_enabled_; |
70 | 75 |
71 // The pseudo stack where frames are |TRACE_EVENT| names. | 76 // The pseudo stack where frames are |TRACE_EVENT| names. |
72 std::vector<StackFrame> pseudo_stack_; | 77 std::vector<StackFrame> pseudo_stack_; |
73 | 78 |
74 // The thread name is used as the first entry in the pseudo stack. | 79 // The thread name is used as the first entry in the pseudo stack. |
75 const char* thread_name_; | 80 const char* thread_name_; |
76 | 81 |
82 // Stack of tasks' contexts. Context serves as a different dimension than | |
83 // pseudo stack to study the heap. | |
Primiano Tucci (use gerrit)
2016/03/31 15:37:16
s/to study the heap/to cluster allocations/
ssid
2016/04/01 04:34:54
Done.
| |
84 std::vector<const char*> task_contexts_; | |
85 | |
77 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker); | 86 DISALLOW_COPY_AND_ASSIGN(AllocationContextTracker); |
78 }; | 87 }; |
79 | 88 |
80 } // namespace trace_event | 89 } // namespace trace_event |
81 } // namespace base | 90 } // namespace base |
82 | 91 |
83 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ | 92 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_TRACKER_H_ |
OLD | NEW |