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

Side by Side Diff: third_party/tcmalloc/chromium/src/common.cc

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: added references to SLL_* functions 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 // Initialize the mapping arrays 149 // Initialize the mapping arrays
150 int next_size = 0; 150 int next_size = 0;
151 for (int c = 1; c < kNumClasses; c++) { 151 for (int c = 1; c < kNumClasses; c++) {
152 const int max_size_in_class = class_to_size_[c]; 152 const int max_size_in_class = class_to_size_[c];
153 for (int s = next_size; s <= max_size_in_class; s += kAlignment) { 153 for (int s = next_size; s <= max_size_in_class; s += kAlignment) {
154 class_array_[ClassIndex(s)] = c; 154 class_array_[ClassIndex(s)] = c;
155 } 155 }
156 next_size = max_size_in_class + kAlignment; 156 next_size = max_size_in_class + kAlignment;
157 } 157 }
158 if (HAS_64_BIT_POINTERS) {
159 class_to_size_[FIRST_NON_0_SIZE_CLASS - 1] =
160 class_to_size_[FIRST_NON_0_SIZE_CLASS];
161 for (int i = 0; i < FIRST_NON_0_SIZE_CLASS; i++) {
162 class_array_[i] = FIRST_NON_0_SIZE_CLASS;
163 }
164 }
158 165
159 // Double-check sizes just to be safe 166 // Double-check sizes just to be safe
160 for (size_t size = 0; size <= kMaxSize; size++) { 167 for (size_t size = 0; size <= kMaxSize; size++) {
161 const int sc = SizeClass(size); 168 const int sc = SizeClass(size);
162 if (sc <= 0 || sc >= kNumClasses) { 169 if (sc <= 0 || sc >= kNumClasses) {
163 CRASH("Bad size class %d for %" PRIuS "\n", sc, size); 170 CRASH("Bad size class %d for %" PRIuS "\n", sc, size);
164 } 171 }
165 if (sc > 1 && size <= class_to_size_[sc-1]) { 172 if (sc > FIRST_NON_0_SIZE_CLASS && size <= class_to_size_[sc-1]) {
166 CRASH("Allocating unnecessarily large class %d for %" PRIuS 173 CRASH("Allocating unnecessarily large class %d for %" PRIuS
167 "\n", sc, size); 174 "\n", sc, size);
168 } 175 }
169 const size_t s = class_to_size_[sc]; 176 const size_t s = class_to_size_[sc];
170 if (size > s) { 177 if (size > s) {
171 CRASH("Bad size %" PRIuS " for %" PRIuS " (sc = %d)\n", s, size, sc); 178 CRASH("Bad size %" PRIuS " for %" PRIuS " (sc = %d)\n", s, size, sc);
172 } 179 }
173 if (s == 0) { 180 if (s == 0) {
174 CRASH("Bad size %" PRIuS " for %" PRIuS " (sc = %d)\n", s, size, sc); 181 CRASH("Bad size %" PRIuS " for %" PRIuS " (sc = %d)\n", s, size, sc);
175 } 182 }
183 if (HAS_64_BIT_POINTERS) {
184 if (sc > 0 && sc < FIRST_NON_0_SIZE_CLASS){
185 CRASH("Bad size class %d for %" PRIuS "\n", sc, size);
186 }
187 if (s > 0 && s < FIRST_NON_0_SIZE) {
188 CRASH("Bad size %" PRIuS " for %" PRIuS " (sc = %d)\n", s, size, sc);
189 }
190 }
176 } 191 }
177 192
178 // Initialize the num_objects_to_move array. 193 // Initialize the num_objects_to_move array.
179 for (size_t cl = 1; cl < kNumClasses; ++cl) { 194 for (size_t cl = 1; cl < kNumClasses; ++cl) {
180 num_objects_to_move_[cl] = NumMoveSize(ByteSizeForClass(cl)); 195 num_objects_to_move_[cl] = NumMoveSize(ByteSizeForClass(cl));
181 } 196 }
182 } 197 }
183 198
184 void SizeMap::Dump(TCMalloc_Printer* out) { 199 void SizeMap::Dump(TCMalloc_Printer* out) {
185 // Dump class sizes and maximum external wastage per size class 200 // Dump class sizes and maximum external wastage per size class
(...skipping 22 matching lines...) Expand all
208 return result; 223 return result;
209 } 224 }
210 225
211 uint64_t metadata_system_bytes() { return metadata_system_bytes_; } 226 uint64_t metadata_system_bytes() { return metadata_system_bytes_; }
212 227
213 void increment_metadata_system_bytes(size_t bytes) { 228 void increment_metadata_system_bytes(size_t bytes) {
214 metadata_system_bytes_ += bytes; 229 metadata_system_bytes_ += bytes;
215 } 230 }
216 231
217 } // namespace tcmalloc 232 } // namespace tcmalloc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698