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_H_ | 5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ |
6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ | 6 #define BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... | |
28 // The number of stack frames stored in the backtrace is a trade off between | 28 // The number of stack frames stored in the backtrace is a trade off between |
29 // memory used for tracing and accuracy. Measurements done on a prototype | 29 // memory used for tracing and accuracy. Measurements done on a prototype |
30 // revealed that: | 30 // revealed that: |
31 // | 31 // |
32 // - In 60 percent of the cases, stack depth <= 7. | 32 // - In 60 percent of the cases, stack depth <= 7. |
33 // - In 87 percent of the cases, stack depth <= 9. | 33 // - In 87 percent of the cases, stack depth <= 9. |
34 // - In 95 percent of the cases, stack depth <= 11. | 34 // - In 95 percent of the cases, stack depth <= 11. |
35 // | 35 // |
36 // See the design doc (https://goo.gl/4s7v7b) for more details. | 36 // See the design doc (https://goo.gl/4s7v7b) for more details. |
37 | 37 |
38 using StackFrame = const char*; | 38 using StackFrame = const void*; |
39 | |
40 enum StackFrameType { | |
Primiano Tucci (use gerrit)
2016/04/01 15:56:28
do we really need this run-time information per ea
Dmitry Skiba
2016/04/04 22:38:33
It's called that way, but it's used per backtrace,
| |
41 STACK_FRAME_TYPE_SYMBOL, // const char* string | |
42 STACK_FRAME_TYPE_PC // as returned by StackTrace::Addresses() | |
43 }; | |
39 | 44 |
40 struct BASE_EXPORT Backtrace { | 45 struct BASE_EXPORT Backtrace { |
46 StackFrameType frame_type; | |
41 // Unused backtrace frames are filled with nullptr frames. If the stack is | 47 // Unused backtrace frames are filled with nullptr frames. If the stack is |
42 // higher than what can be stored here, the bottom frames are stored. Based | 48 // higher than what can be stored here, the bottom frames are stored. Based |
43 // on the data above, a depth of 12 captures the full stack in the vast | 49 // on the data above, a depth of 12 captures the full stack in the vast |
44 // majority of the cases. | 50 // majority of the cases. |
45 StackFrame frames[12]; | 51 StackFrame frames[12]; |
46 }; | 52 }; |
47 | 53 |
48 bool BASE_EXPORT operator==(const Backtrace& lhs, const Backtrace& rhs); | 54 bool BASE_EXPORT operator==(const Backtrace& lhs, const Backtrace& rhs); |
49 | 55 |
50 // The |AllocationContext| is context metadata that is kept for every allocation | 56 // The |AllocationContext| is context metadata that is kept for every allocation |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 }; | 94 }; |
89 | 95 |
90 template <> | 96 template <> |
91 struct BASE_EXPORT hash<base::trace_event::AllocationContext> { | 97 struct BASE_EXPORT hash<base::trace_event::AllocationContext> { |
92 size_t operator()(const base::trace_event::AllocationContext& context) const; | 98 size_t operator()(const base::trace_event::AllocationContext& context) const; |
93 }; | 99 }; |
94 | 100 |
95 } // BASE_HASH_NAMESPACE | 101 } // BASE_HASH_NAMESPACE |
96 | 102 |
97 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ | 103 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_ALLOCATION_CONTEXT_H_ |
OLD | NEW |