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 9323026: [NOT TO COMMIT!] r109: Diff of the current tcmalloc from the original google-perftools r109. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 10 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) 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
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 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
212 void PushRange(int N, void *start, void *end) { 206 void PushRange(int N, void *start, void *end) {
213 SLL_PushRange(&list_, start, end); 207 FL_PushRange(&list_, start, end);
214 length_ += N; 208 length_ += N;
215 } 209 }
216 210
217 void PopRange(int N, void **start, void **end) { 211 void PopRange(int N, void **start, void **end) {
218 SLL_PopRange(&list_, N, start, end); 212 FL_PopRange(&list_, N, start, end);
219 ASSERT(length_ >= N); 213 ASSERT(length_ >= N);
220 length_ -= N; 214 length_ -= N;
221 if (length_ < lowater_) lowater_ = length_; 215 if (length_ < lowater_) lowater_ = length_;
222 } 216 }
223 }; 217 };
224 218
225 // Gets and returns an object from the central cache, and, if possible, 219 // 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. 220 // also adds some objects of that size class to this thread cache.
227 void* FetchFromCentralCache(size_t cl, size_t byte_size); 221 void* FetchFromCentralCache(size_t cl, size_t byte_size);
228 222
(...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 383 // because we may be in the thread destruction code and may have
390 // already cleaned up the cache for this thread. 384 // already cleaned up the cache for this thread.
391 inline ThreadCache* ThreadCache::GetCacheIfPresent() { 385 inline ThreadCache* ThreadCache::GetCacheIfPresent() {
392 if (!tsd_inited_) return NULL; 386 if (!tsd_inited_) return NULL;
393 return GetThreadHeap(); 387 return GetThreadHeap();
394 } 388 }
395 389
396 } // namespace tcmalloc 390 } // namespace tcmalloc
397 391
398 #endif // TCMALLOC_THREAD_CACHE_H_ 392 #endif // TCMALLOC_THREAD_CACHE_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/third_party/valgrind.h ('k') | third_party/tcmalloc/chromium/src/thread_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698