 Chromium Code Reviews
 Chromium Code Reviews Issue 7671034:
  doubly-linked free-lists for thread caches and page heaps  (Closed) 
  Base URL: http://git.chromium.org/git/chromium.git@trunk
    
  
    Issue 7671034:
  doubly-linked free-lists for thread caches and page heaps  (Closed) 
  Base URL: http://git.chromium.org/git/chromium.git@trunk| OLD | NEW | 
|---|---|
| 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 Loading... | |
| 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 (IS_64_BIT_POINTERS) { | |
| 159 class_to_size_[FIRST_USABLE_SIZE_CLASS - 1] = | |
| 160 class_to_size_[FIRST_USABLE_SIZE_CLASS]; | |
| 
jar (doing other things)
2011/08/25 02:07:50
This was cute :-).  I expect some tests or asserti
 
bxx
2011/08/25 20:23:18
Done.
 | |
| 161 } | |
| 158 | 162 | 
| 159 // Double-check sizes just to be safe | 163 // Double-check sizes just to be safe | 
| 160 for (size_t size = 0; size <= kMaxSize; size++) { | 164 for (size_t size = 0; size <= kMaxSize; size++) { | 
| 161 const int sc = SizeClass(size); | 165 const int sc = SizeClass(size); | 
| 162 if (sc <= 0 || sc >= kNumClasses) { | 166 if (sc <= 0 || sc >= kNumClasses) { | 
| 163 CRASH("Bad size class %d for %" PRIuS "\n", sc, size); | 167 CRASH("Bad size class %d for %" PRIuS "\n", sc, size); | 
| 164 } | 168 } | 
| 165 if (sc > 1 && size <= class_to_size_[sc-1]) { | 169 if (sc > FIRST_USABLE_SIZE_CLASS && size <= class_to_size_[sc-1]) { | 
| 166 CRASH("Allocating unnecessarily large class %d for %" PRIuS | 170 CRASH("Allocating unnecessarily large class %d for %" PRIuS | 
| 167 "\n", sc, size); | 171 "\n", sc, size); | 
| 168 } | 172 } | 
| 169 const size_t s = class_to_size_[sc]; | 173 const size_t s = class_to_size_[sc]; | 
| 170 if (size > s) { | 174 if (size > s) { | 
| 171 CRASH("Bad size %" PRIuS " for %" PRIuS " (sc = %d)\n", s, size, sc); | 175 CRASH("Bad size %" PRIuS " for %" PRIuS " (sc = %d)\n", s, size, sc); | 
| 172 } | 176 } | 
| 173 if (s == 0) { | 177 if (s == 0) { | 
| 174 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); | 
| 175 } | 179 } | 
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 return result; | 212 return result; | 
| 209 } | 213 } | 
| 210 | 214 | 
| 211 uint64_t metadata_system_bytes() { return metadata_system_bytes_; } | 215 uint64_t metadata_system_bytes() { return metadata_system_bytes_; } | 
| 212 | 216 | 
| 213 void increment_metadata_system_bytes(size_t bytes) { | 217 void increment_metadata_system_bytes(size_t bytes) { | 
| 214 metadata_system_bytes_ += bytes; | 218 metadata_system_bytes_ += bytes; | 
| 215 } | 219 } | 
| 216 | 220 | 
| 217 } // namespace tcmalloc | 221 } // namespace tcmalloc | 
| OLD | NEW |