OLD | NEW |
1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // We have a separate lock per free-list to reduce contention. | 58 // We have a separate lock per free-list to reduce contention. |
59 static CentralFreeListPadded* central_cache() { return central_cache_; } | 59 static CentralFreeListPadded* central_cache() { return central_cache_; } |
60 | 60 |
61 static SizeMap* sizemap() { return &sizemap_; } | 61 static SizeMap* sizemap() { return &sizemap_; } |
62 | 62 |
63 ////////////////////////////////////////////////////////////////////// | 63 ////////////////////////////////////////////////////////////////////// |
64 // In addition to the explicit initialization comment, the variables below | 64 // In addition to the explicit initialization comment, the variables below |
65 // must be protected by pageheap_lock. | 65 // must be protected by pageheap_lock. |
66 | 66 |
67 // Page-level allocator. | 67 // Page-level allocator. |
68 static PageHeap* pageheap() { return pageheap_; } | 68 static PageHeap* pageheap() { |
| 69 return reinterpret_cast<PageHeap*>(pageheap_memory_); |
| 70 } |
69 | 71 |
70 static PageHeapAllocator<Span>* span_allocator() { return &span_allocator_; } | 72 static PageHeapAllocator<Span>* span_allocator() { return &span_allocator_; } |
71 | 73 |
72 static PageHeapAllocator<StackTrace>* stacktrace_allocator() { | 74 static PageHeapAllocator<StackTrace>* stacktrace_allocator() { |
73 return &stacktrace_allocator_; | 75 return &stacktrace_allocator_; |
74 } | 76 } |
75 | 77 |
76 static StackTrace* growth_stacks() { return growth_stacks_; } | 78 static StackTrace* growth_stacks() { return growth_stacks_; } |
77 static void set_growth_stacks(StackTrace* s) { growth_stacks_ = s; } | 79 static void set_growth_stacks(StackTrace* s) { growth_stacks_ = s; } |
78 | 80 |
(...skipping 17 matching lines...) Expand all Loading... |
96 static PageHeapAllocator<StackTrace> stacktrace_allocator_; | 98 static PageHeapAllocator<StackTrace> stacktrace_allocator_; |
97 static Span sampled_objects_; | 99 static Span sampled_objects_; |
98 static PageHeapAllocator<StackTraceTable::Bucket> bucket_allocator_; | 100 static PageHeapAllocator<StackTraceTable::Bucket> bucket_allocator_; |
99 | 101 |
100 // Linked list of stack traces recorded every time we allocated memory | 102 // Linked list of stack traces recorded every time we allocated memory |
101 // from the system. Useful for finding allocation sites that cause | 103 // from the system. Useful for finding allocation sites that cause |
102 // increase in the footprint of the system. The linked list pointer | 104 // increase in the footprint of the system. The linked list pointer |
103 // is stored in trace->stack[kMaxStackDepth-1]. | 105 // is stored in trace->stack[kMaxStackDepth-1]. |
104 static StackTrace* growth_stacks_; | 106 static StackTrace* growth_stacks_; |
105 | 107 |
106 static PageHeap* pageheap_; | 108 // PageHeap uses a constructor for initialization. Like the members above, |
| 109 // we can't depend on initialization order, so pageheap is new'd |
| 110 // into this buffer. |
| 111 static char pageheap_memory_[sizeof(PageHeap)]; |
107 }; | 112 }; |
108 | 113 |
109 } // namespace tcmalloc | 114 } // namespace tcmalloc |
110 | 115 |
111 #endif // TCMALLOC_STATIC_VARS_H_ | 116 #endif // TCMALLOC_STATIC_VARS_H_ |
OLD | NEW |