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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 lock_.Unlock(); | 312 lock_.Unlock(); |
313 const size_t npages = Static::sizemap()->class_to_pages(size_class_); | 313 const size_t npages = Static::sizemap()->class_to_pages(size_class_); |
314 | 314 |
315 Span* span; | 315 Span* span; |
316 { | 316 { |
317 SpinLockHolder h(Static::pageheap_lock()); | 317 SpinLockHolder h(Static::pageheap_lock()); |
318 span = Static::pageheap()->New(npages); | 318 span = Static::pageheap()->New(npages); |
319 if (span) Static::pageheap()->RegisterSizeClass(span, size_class_); | 319 if (span) Static::pageheap()->RegisterSizeClass(span, size_class_); |
320 } | 320 } |
321 if (span == NULL) { | 321 if (span == NULL) { |
322 MESSAGE("tcmalloc: allocation failed", npages << kPageShift); | 322 Log(kLog, __FILE__, __LINE__, |
| 323 "tcmalloc: allocation failed", npages << kPageShift); |
323 lock_.Lock(); | 324 lock_.Lock(); |
324 return; | 325 return; |
325 } | 326 } |
326 ASSERT(span->length == npages); | 327 ASSERT(span->length == npages); |
327 // Cache sizeclass info eagerly. Locking is not necessary. | 328 // Cache sizeclass info eagerly. Locking is not necessary. |
328 // (Instead of being eager, we could just replace any stale info | 329 // (Instead of being eager, we could just replace any stale info |
329 // about this span, but that seems to be no better in practice.) | 330 // about this span, but that seems to be no better in practice.) |
330 for (int i = 0; i < npages; i++) { | 331 for (int i = 0; i < npages; i++) { |
331 Static::pageheap()->CacheSizeClass(span->start + i, size_class_); | 332 Static::pageheap()->CacheSizeClass(span->start + i, size_class_); |
332 } | 333 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 return 0; | 367 return 0; |
367 } | 368 } |
368 const size_t pages_per_span = Static::sizemap()->class_to_pages(size_class_); | 369 const size_t pages_per_span = Static::sizemap()->class_to_pages(size_class_); |
369 const size_t object_size = Static::sizemap()->class_to_size(size_class_); | 370 const size_t object_size = Static::sizemap()->class_to_size(size_class_); |
370 ASSERT(object_size > 0); | 371 ASSERT(object_size > 0); |
371 const size_t overhead_per_span = (pages_per_span * kPageSize) % object_size; | 372 const size_t overhead_per_span = (pages_per_span * kPageSize) % object_size; |
372 return num_spans_ * overhead_per_span; | 373 return num_spans_ * overhead_per_span; |
373 } | 374 } |
374 | 375 |
375 } // namespace tcmalloc | 376 } // namespace tcmalloc |
OLD | NEW |