| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 } | 186 } |
| 187 | 187 |
| 188 // Initialize the num_objects_to_move array. | 188 // Initialize the num_objects_to_move array. |
| 189 for (size_t cl = 1; cl < kNumClasses; ++cl) { | 189 for (size_t cl = 1; cl < kNumClasses; ++cl) { |
| 190 num_objects_to_move_[cl] = NumMoveSize(ByteSizeForClass(cl)); | 190 num_objects_to_move_[cl] = NumMoveSize(ByteSizeForClass(cl)); |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 | 193 |
| 194 // Metadata allocator -- keeps stats about how many bytes allocated. | 194 // Metadata allocator -- keeps stats about how many bytes allocated. |
| 195 static uint64_t metadata_system_bytes_ = 0; | 195 static uint64_t metadata_system_bytes_ = 0; |
| 196 static uint64_t metadata_unmapped_bytes_ = 0; |
| 197 |
| 196 void* MetaDataAlloc(size_t bytes) { | 198 void* MetaDataAlloc(size_t bytes) { |
| 197 static size_t pagesize; | 199 static size_t pagesize; |
| 198 #ifdef HAVE_GETPAGESIZE | 200 #ifdef HAVE_GETPAGESIZE |
| 199 if (pagesize == 0) | 201 if (pagesize == 0) |
| 200 pagesize = getpagesize(); | 202 pagesize = getpagesize(); |
| 201 #endif | 203 #endif |
| 202 | 204 |
| 203 void* result = TCMalloc_SystemAlloc(bytes, NULL, pagesize); | 205 void* result = TCMalloc_SystemAlloc(bytes, NULL, pagesize); |
| 204 if (result != NULL) { | 206 if (result != NULL) { |
| 205 metadata_system_bytes_ += bytes; | 207 metadata_system_bytes_ += bytes; |
| 206 } | 208 } |
| 207 return result; | 209 return result; |
| 208 } | 210 } |
| 209 | 211 |
| 210 uint64_t metadata_system_bytes() { return metadata_system_bytes_; } | 212 uint64_t metadata_system_bytes() { return metadata_system_bytes_; } |
| 213 uint64_t metadata_unmapped_bytes() { return metadata_unmapped_bytes_; } |
| 211 | 214 |
| 212 void increment_metadata_system_bytes(size_t bytes) { | 215 void update_metadata_system_bytes(int diff) { |
| 213 metadata_system_bytes_ += bytes; | 216 metadata_system_bytes_ += diff; |
| 217 } |
| 218 void update_metadata_unmapped_bytes(int diff) { |
| 219 metadata_unmapped_bytes_ += diff; |
| 214 } | 220 } |
| 215 | 221 |
| 216 } // namespace tcmalloc | 222 } // namespace tcmalloc |
| OLD | NEW |