Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/tcmalloc/chromium/src/thread_cache.h

Issue 7671034: doubly-linked free-lists for thread caches and page heaps (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: code style fixes Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2008, Google Inc. 1 // Copyright (c) 2011, 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
11 // copyright notice, this list of conditions and the following disclaimer 11 // copyright notice, this list of conditions and the following disclaimer
(...skipping 23 matching lines...) Expand all
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
jar (doing other things) 2011/08/20 02:40:30 minimalist: don't reorder includes.
bxx 2011/08/24 00:19:24 I was removing duplicates of includes: common.h, p
46 #include "linked_list.h" 46 #include "free_list.h" // for FL_Pop, FL_PopRange, etc
47 #include "internal_logging.h" // for ASSERT, etc
jar (doing other things) 2011/08/20 02:40:30 again... don't reorder.
bxx 2011/08/24 00:19:24 Ditto with the duplicated includes. On 2011/08/20
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // Is list empty? 185 // Is list empty?
192 bool empty() const { 186 bool empty() const {
193 return list_ == NULL; 187 return list_ == NULL;
194 } 188 }
195 189
196 // Low-water mark management 190 // Low-water mark management
197 int lowwatermark() const { return lowater_; } 191 int lowwatermark() const { return lowater_; }
198 void clear_lowwatermark() { lowater_ = length_; } 192 void clear_lowwatermark() { lowater_ = length_; }
199 193
200 void Push(void* ptr) { 194 void Push(void* ptr) {
201 SLL_Push(&list_, ptr); 195 FL_Push(&list_, ptr);
202 length_++; 196 length_++;
203 } 197 }
204 198
205 void* Pop() { 199 void* Pop() {
206 ASSERT(list_ != NULL); 200 ASSERT(list_ != NULL);
207 length_--; 201 length_--;
208 if (length_ < lowater_) lowater_ = length_; 202 if (length_ < lowater_) lowater_ = length_;
209 return SLL_Pop(&list_); 203 return FL_Pop(&list_);
210 } 204 }
211 205
206
jar (doing other things) 2011/08/20 02:40:30 delete extra line.
bxx 2011/08/24 00:19:24 Done.
212 void PushRange(int N, void *start, void *end) { 207 void PushRange(int N, void *start, void *end) {
213 SLL_PushRange(&list_, start, end); 208 FL_PushRange(&list_, start, end);
214 length_ += N; 209 length_ += N;
215 } 210 }
216 211
217 void PopRange(int N, void **start, void **end) { 212 void PopRange(int N, void **start, void **end) {
218 SLL_PopRange(&list_, N, start, end); 213 FL_PopRange(&list_, N, start, end);
219 ASSERT(length_ >= N); 214 ASSERT(length_ >= N);
220 length_ -= N; 215 length_ -= N;
221 if (length_ < lowater_) lowater_ = length_; 216 if (length_ < lowater_) lowater_ = length_;
222 } 217 }
223 }; 218 };
224 219
225 // Gets and returns an object from the central cache, and, if possible, 220 // Gets and returns an object from the central cache, and, if possible,
226 // also adds some objects of that size class to this thread cache. 221 // also adds some objects of that size class to this thread cache.
227 void* FetchFromCentralCache(size_t cl, size_t byte_size); 222 void* FetchFromCentralCache(size_t cl, size_t byte_size);
228 223
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 // because we may be in the thread destruction code and may have 384 // because we may be in the thread destruction code and may have
390 // already cleaned up the cache for this thread. 385 // already cleaned up the cache for this thread.
391 inline ThreadCache* ThreadCache::GetCacheIfPresent() { 386 inline ThreadCache* ThreadCache::GetCacheIfPresent() {
392 if (!tsd_inited_) return NULL; 387 if (!tsd_inited_) return NULL;
393 return GetThreadHeap(); 388 return GetThreadHeap();
394 } 389 }
395 390
396 } // namespace tcmalloc 391 } // namespace tcmalloc
397 392
398 #endif // TCMALLOC_THREAD_CACHE_H_ 393 #endif // TCMALLOC_THREAD_CACHE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698