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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 #include <config.h> | 36 #include <config.h> |
37 #ifdef HAVE_PTHREAD | 37 #ifdef HAVE_PTHREAD |
38 #include <pthread.h> // for pthread_t, pthread_key_t | 38 #include <pthread.h> // for pthread_t, pthread_key_t |
39 #endif | 39 #endif |
40 #include <stddef.h> // for size_t, NULL | 40 #include <stddef.h> // for size_t, NULL |
41 #ifdef HAVE_STDINT_H | 41 #ifdef HAVE_STDINT_H |
42 #include <stdint.h> // for uint32_t, uint64_t | 42 #include <stdint.h> // for uint32_t, uint64_t |
43 #endif | 43 #endif |
44 #include <sys/types.h> // for ssize_t | 44 #include <sys/types.h> // for ssize_t |
45 #include "common.h" | 45 #include "common.h" // for SizeMap, kMaxSize, etc |
46 #include "linked_list.h" | 46 #include "free_list.h" // for FL_Pop, FL_PopRange, etc |
| 47 #include "internal_logging.h" // for ASSERT, etc |
47 #include "maybe_threads.h" | 48 #include "maybe_threads.h" |
48 #include "page_heap_allocator.h" | |
49 #include "sampler.h" | |
50 #include "static_vars.h" | |
51 | |
52 #include "common.h" // for SizeMap, kMaxSize, etc | |
53 #include "internal_logging.h" // for ASSERT, etc | |
54 #include "linked_list.h" // for SLL_Pop, SLL_PopRange, etc | |
55 #include "page_heap_allocator.h" // for PageHeapAllocator | 49 #include "page_heap_allocator.h" // for PageHeapAllocator |
56 #include "sampler.h" // for Sampler | 50 #include "sampler.h" // for Sampler |
57 #include "static_vars.h" // for Static | 51 #include "static_vars.h" // for Static |
58 | 52 |
59 namespace tcmalloc { | 53 namespace tcmalloc { |
60 | 54 |
61 // Even if we have support for thread-local storage in the compiler | 55 // Even if we have support for thread-local storage in the compiler |
62 // and linker, the OS may not support it. We need to check that at | 56 // and linker, the OS may not support it. We need to check that at |
63 // runtime. Right now, we have to keep a manual set of "bad" OSes. | 57 // runtime. Right now, we have to keep a manual set of "bad" OSes. |
64 #if defined(HAVE_TLS) | 58 #if defined(HAVE_TLS) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // Is list empty? | 180 // Is list empty? |
187 bool empty() const { | 181 bool empty() const { |
188 return list_ == NULL; | 182 return list_ == NULL; |
189 } | 183 } |
190 | 184 |
191 // Low-water mark management | 185 // Low-water mark management |
192 int lowwatermark() const { return lowater_; } | 186 int lowwatermark() const { return lowater_; } |
193 void clear_lowwatermark() { lowater_ = length_; } | 187 void clear_lowwatermark() { lowater_ = length_; } |
194 | 188 |
195 void Push(void* ptr) { | 189 void Push(void* ptr) { |
196 SLL_Push(&list_, ptr); | 190 FL_Push(&list_, ptr); |
197 length_++; | 191 length_++; |
198 } | 192 } |
199 | 193 |
200 void* Pop() { | 194 void* Pop() { |
201 ASSERT(list_ != NULL); | 195 ASSERT(list_ != NULL); |
202 length_--; | 196 length_--; |
203 if (length_ < lowater_) lowater_ = length_; | 197 if (length_ < lowater_) lowater_ = length_; |
204 return SLL_Pop(&list_); | 198 return FL_Pop(&list_); |
205 } | 199 } |
206 | 200 |
207 void* Next() { | 201 void* Next() { |
208 return SLL_Next(&list_); | 202 return FL_Next(&list_); |
209 } | 203 } |
210 | 204 |
211 void PushRange(int N, void *start, void *end) { | 205 void PushRange(int N, void *start, void *end) { |
212 SLL_PushRange(&list_, start, end); | 206 FL_PushRange(&list_, start, end); |
213 length_ += N; | 207 length_ += N; |
214 } | 208 } |
215 | 209 |
216 void PopRange(int N, void **start, void **end) { | 210 void PopRange(int N, void **start, void **end) { |
217 SLL_PopRange(&list_, N, start, end); | 211 FL_PopRange(&list_, N, start, end); |
218 ASSERT(length_ >= N); | 212 ASSERT(length_ >= N); |
219 length_ -= N; | 213 length_ -= N; |
220 if (length_ < lowater_) lowater_ = length_; | 214 if (length_ < lowater_) lowater_ = length_; |
221 } | 215 } |
222 }; | 216 }; |
223 | 217 |
224 // Gets and returns an object from the central cache, and, if possible, | 218 // Gets and returns an object from the central cache, and, if possible, |
225 // also adds some objects of that size class to this thread cache. | 219 // also adds some objects of that size class to this thread cache. |
226 void* FetchFromCentralCache(size_t cl, size_t byte_size); | 220 void* FetchFromCentralCache(size_t cl, size_t byte_size); |
227 | 221 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 // because we may be in the thread destruction code and may have | 388 // because we may be in the thread destruction code and may have |
395 // already cleaned up the cache for this thread. | 389 // already cleaned up the cache for this thread. |
396 inline ThreadCache* ThreadCache::GetCacheIfPresent() { | 390 inline ThreadCache* ThreadCache::GetCacheIfPresent() { |
397 if (!tsd_inited_) return NULL; | 391 if (!tsd_inited_) return NULL; |
398 return GetThreadHeap(); | 392 return GetThreadHeap(); |
399 } | 393 } |
400 | 394 |
401 } // namespace tcmalloc | 395 } // namespace tcmalloc |
402 | 396 |
403 #endif // TCMALLOC_THREAD_CACHE_H_ | 397 #endif // TCMALLOC_THREAD_CACHE_H_ |
OLD | NEW |