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() { | 68 static PageHeap* pageheap() { return pageheap_; } |
69 return reinterpret_cast<PageHeap*>(pageheap_memory_); | |
70 } | |
71 | 69 |
72 static PageHeapAllocator<Span>* span_allocator() { return &span_allocator_; } | 70 static PageHeapAllocator<Span>* span_allocator() { return &span_allocator_; } |
73 | 71 |
74 static PageHeapAllocator<StackTrace>* stacktrace_allocator() { | 72 static PageHeapAllocator<StackTrace>* stacktrace_allocator() { |
75 return &stacktrace_allocator_; | 73 return &stacktrace_allocator_; |
76 } | 74 } |
77 | 75 |
78 static StackTrace* growth_stacks() { return growth_stacks_; } | 76 static StackTrace* growth_stacks() { return growth_stacks_; } |
79 static void set_growth_stacks(StackTrace* s) { growth_stacks_ = s; } | 77 static void set_growth_stacks(StackTrace* s) { growth_stacks_ = s; } |
80 | 78 |
(...skipping 17 matching lines...) Expand all Loading... |
98 static PageHeapAllocator<StackTrace> stacktrace_allocator_; | 96 static PageHeapAllocator<StackTrace> stacktrace_allocator_; |
99 static Span sampled_objects_; | 97 static Span sampled_objects_; |
100 static PageHeapAllocator<StackTraceTable::Bucket> bucket_allocator_; | 98 static PageHeapAllocator<StackTraceTable::Bucket> bucket_allocator_; |
101 | 99 |
102 // Linked list of stack traces recorded every time we allocated memory | 100 // Linked list of stack traces recorded every time we allocated memory |
103 // from the system. Useful for finding allocation sites that cause | 101 // from the system. Useful for finding allocation sites that cause |
104 // increase in the footprint of the system. The linked list pointer | 102 // increase in the footprint of the system. The linked list pointer |
105 // is stored in trace->stack[kMaxStackDepth-1]. | 103 // is stored in trace->stack[kMaxStackDepth-1]. |
106 static StackTrace* growth_stacks_; | 104 static StackTrace* growth_stacks_; |
107 | 105 |
108 // PageHeap uses a constructor for initialization. Like the members above, | 106 static PageHeap* pageheap_; |
109 // we can't depend on initialization order, so pageheap is new'd | |
110 // into this buffer. | |
111 static char pageheap_memory_[sizeof(PageHeap)]; | |
112 }; | 107 }; |
113 | 108 |
114 } // namespace tcmalloc | 109 } // namespace tcmalloc |
115 | 110 |
116 #endif // TCMALLOC_STATIC_VARS_H_ | 111 #endif // TCMALLOC_STATIC_VARS_H_ |
OLD | NEW |