| OLD | NEW | 
|---|
| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 99   } | 99   } | 
| 100   if (ClassIndex(kMaxSize) >= sizeof(class_array_)) { | 100   if (ClassIndex(kMaxSize) >= sizeof(class_array_)) { | 
| 101     CRASH("Invalid class index %d for kMaxSize\n", ClassIndex(kMaxSize)); | 101     CRASH("Invalid class index %d for kMaxSize\n", ClassIndex(kMaxSize)); | 
| 102   } | 102   } | 
| 103 | 103 | 
| 104   // Compute the size classes we want to use | 104   // Compute the size classes we want to use | 
| 105   int sc = 1;   // Next size class to assign | 105   int sc = 1;   // Next size class to assign | 
| 106   int alignment = kAlignment; | 106   int alignment = kAlignment; | 
| 107   CHECK_CONDITION(kAlignment <= 16); | 107   CHECK_CONDITION(kAlignment <= 16); | 
| 108   int last_lg = -1; | 108   int last_lg = -1; | 
| 109   for (size_t size = kAlignment; size <= kMaxSize; size += alignment) { | 109   for (size_t size = kMinClassSize; size <= kMaxSize; size += alignment) { | 
| 110     int lg = LgFloor(size); | 110     int lg = LgFloor(size); | 
| 111     if (lg > last_lg) { | 111     if (lg > last_lg) { | 
| 112       // Increase alignment every so often to reduce number of size classes. | 112       // Increase alignment every so often to reduce number of size classes. | 
| 113       alignment = AlignmentForSize(size); | 113       alignment = AlignmentForSize(size); | 
| 114       last_lg = lg; | 114       last_lg = lg; | 
| 115     } | 115     } | 
| 116     CHECK_CONDITION((size % alignment) == 0); | 116     CHECK_CONDITION((size % alignment) == 0); | 
| 117 | 117 | 
| 118     // Allocate enough pages so leftover is less than 1/8 of total. | 118     // Allocate enough pages so leftover is less than 1/8 of total. | 
| 119     // This bounds wasted space to at most 12.5%. | 119     // This bounds wasted space to at most 12.5%. | 
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 208   return result; | 208   return result; | 
| 209 } | 209 } | 
| 210 | 210 | 
| 211 uint64_t metadata_system_bytes() { return metadata_system_bytes_; } | 211 uint64_t metadata_system_bytes() { return metadata_system_bytes_; } | 
| 212 | 212 | 
| 213 void increment_metadata_system_bytes(size_t bytes) { | 213 void increment_metadata_system_bytes(size_t bytes) { | 
| 214   metadata_system_bytes_ += bytes; | 214   metadata_system_bytes_ += bytes; | 
| 215 } | 215 } | 
| 216 | 216 | 
| 217 }  // namespace tcmalloc | 217 }  // namespace tcmalloc | 
| OLD | NEW | 
|---|