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

Side by Side Diff: third_party/tcmalloc/chromium/src/common.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: fix macros and size class checks Created 9 years, 3 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 12 matching lines...) Expand all
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 29
30 // --- 30 // ---
31 // Author: Sanjay Ghemawat <opensource@google.com> 31 // Author: Sanjay Ghemawat <opensource@google.com>
32 // 32 //
33 // Common definitions for tcmalloc code. 33 // Common definitions for tcmalloc code.
34
35 #ifndef TCMALLOC_COMMON_H_ 34 #ifndef TCMALLOC_COMMON_H_
36 #define TCMALLOC_COMMON_H_ 35 #define TCMALLOC_COMMON_H_
37 36
38 #include "config.h" 37 #include "config.h"
39 #include <stddef.h> // for size_t 38 #include <stddef.h> // for size_t
40 #ifdef HAVE_STDINT_H 39 #ifdef HAVE_STDINT_H
41 #include <stdint.h> // for uintptr_t, uint64_t 40 #include <stdint.h> // for uintptr_t, uint64_t
42 #endif 41 #endif
42 #include "free_list.h" // for SIZE_CLASS macros
43 #include "internal_logging.h" // for ASSERT, etc 43 #include "internal_logging.h" // for ASSERT, etc
44 44
45 // Type that can hold a page number 45 // Type that can hold a page number
46 typedef uintptr_t PageID; 46 typedef uintptr_t PageID;
47 47
48 // Type that can hold the length of a run of pages 48 // Type that can hold the length of a run of pages
49 typedef uintptr_t Length; 49 typedef uintptr_t Length;
50 50
51 //------------------------------------------------------------------- 51 //-------------------------------------------------------------------
52 // Configuration 52 // Configuration
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 (((1 << kPageShift) * 8u + 127 + (120 << 7)) >> 7) + 1; 168 (((1 << kPageShift) * 8u + 127 + (120 << 7)) >> 7) + 1;
169 unsigned char class_array_[kClassArraySize]; 169 unsigned char class_array_[kClassArraySize];
170 170
171 // Compute index of the class_array[] entry for a given size 171 // Compute index of the class_array[] entry for a given size
172 static inline int ClassIndex(int s) { 172 static inline int ClassIndex(int s) {
173 ASSERT(0 <= s); 173 ASSERT(0 <= s);
174 ASSERT(s <= kMaxSize); 174 ASSERT(s <= kMaxSize);
175 const bool big = (s > kMaxSmallSize); 175 const bool big = (s > kMaxSmallSize);
176 const int add_amount = big ? (127 + (120<<7)) : 7; 176 const int add_amount = big ? (127 + (120<<7)) : 7;
177 const int shift_amount = big ? 7 : 3; 177 const int shift_amount = big ? 7 : 3;
178 return (s + add_amount) >> shift_amount; 178 const int size_class = (s + add_amount) >> shift_amount;
179 if (HAS_64_BIT_POINTERS && s > 0 &&
180 size_class < FIRST_NON_0_SIZE_CLASS)
181 return FIRST_NON_0_SIZE_CLASS;
jar (doing other things) 2011/08/26 18:56:29 I haven't measured it... but I've been told that c
bxx 2011/08/26 21:45:10 Done.
182 return size_class;
179 } 183 }
180 184
181 int NumMoveSize(size_t size); 185 int NumMoveSize(size_t size);
182 186
183 // Mapping from size class to max size storable in that class 187 // Mapping from size class to max size storable in that class
184 size_t class_to_size_[kNumClasses]; 188 size_t class_to_size_[kNumClasses];
185 189
186 // Mapping from size class to number of pages to allocate at a time 190 // Mapping from size class to number of pages to allocate at a time
187 size_t class_to_pages_[kNumClasses]; 191 size_t class_to_pages_[kNumClasses];
188 192
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 static const int kMaxStackDepth = 31; 248 static const int kMaxStackDepth = 31;
245 struct StackTrace { 249 struct StackTrace {
246 uintptr_t size; // Size of object 250 uintptr_t size; // Size of object
247 uintptr_t depth; // Number of PC values stored in array below 251 uintptr_t depth; // Number of PC values stored in array below
248 void* stack[kMaxStackDepth]; 252 void* stack[kMaxStackDepth];
249 }; 253 };
250 254
251 } // namespace tcmalloc 255 } // namespace tcmalloc
252 256
253 #endif // TCMALLOC_COMMON_H_ 257 #endif // TCMALLOC_COMMON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698