| Index: third_party/tcmalloc/chromium/src/tcmalloc.cc
|
| diff --git a/third_party/tcmalloc/chromium/src/tcmalloc.cc b/third_party/tcmalloc/chromium/src/tcmalloc.cc
|
| index 48e71c228ba4feb3396d9aefc0fa14bba4a65ebd..1a56a3adbf5049d2f69f4fbd8780b877bbd69498 100644
|
| --- a/third_party/tcmalloc/chromium/src/tcmalloc.cc
|
| +++ b/third_party/tcmalloc/chromium/src/tcmalloc.cc
|
| @@ -1062,7 +1062,10 @@ inline void* do_malloc_pages(ThreadCache* heap, size_t size) {
|
| Length num_pages = tcmalloc::pages(size);
|
| size = num_pages << kPageShift;
|
|
|
| - heap->AddToByteAllocatedTotal(size); // Chromium profiling.
|
| + // Chromium profiling. Measurements in March 2013 suggest this
|
| + // imposes a small enough runtime cost that there's no reason to
|
| + // try to optimize it.
|
| + heap->AddToByteAllocatedTotal(size);
|
|
|
| if ((FLAGS_tcmalloc_sample_parameter > 0) && heap->SampleAllocation(size)) {
|
| result = DoSampledAllocation(size);
|
| @@ -1089,33 +1092,30 @@ inline void* do_malloc(size_t size) {
|
|
|
| // The following call forces module initialization
|
| ThreadCache* heap = ThreadCache::GetCache();
|
| - // First, check if our security policy allows this size.
|
| - if (IsAllocSizePermitted(size)) {
|
| - if (size <= kMaxSize) {
|
| - size_t cl = Static::sizemap()->SizeClass(size);
|
| - size = Static::sizemap()->class_to_size(cl);
|
| -
|
| - // TODO(jar): If this has any detectable performance impact, it can be
|
| - // optimized by only tallying sizes if the profiler was activated to
|
| - // recall these tallies. I don't think this is performance critical, but
|
| - // we really should measure it.
|
| - heap->AddToByteAllocatedTotal(size); // Chromium profiling.
|
| -
|
| - if ((FLAGS_tcmalloc_sample_parameter > 0) &&
|
| - heap->SampleAllocation(size)) {
|
| - ret = DoSampledAllocation(size);
|
| - MarkAllocatedRegion(ret);
|
| - } else {
|
| - // The common case, and also the simplest. This just pops the
|
| - // size-appropriate freelist, after replenishing it if it's empty.
|
| - ret = CheckMallocResult(heap->Allocate(size, cl));
|
| - }
|
| - } else {
|
| - ret = do_malloc_pages(heap, size);
|
| + if (size <= kMaxSize && IsAllocSizePermitted(size)) {
|
| + size_t cl = Static::sizemap()->SizeClass(size);
|
| + size = Static::sizemap()->class_to_size(cl);
|
| +
|
| + // Chromium profiling. Measurements in March 2013 suggest this
|
| + // imposes a small enough runtime cost that there's no reason to
|
| + // try to optimize it.
|
| + heap->AddToByteAllocatedTotal(size);
|
| +
|
| + if ((FLAGS_tcmalloc_sample_parameter > 0) &&
|
| + heap->SampleAllocation(size)) {
|
| + ret = DoSampledAllocation(size);
|
| MarkAllocatedRegion(ret);
|
| + } else {
|
| + // The common case, and also the simplest. This just pops the
|
| + // size-appropriate freelist, after replenishing it if it's empty.
|
| + ret = CheckMallocResult(heap->Allocate(size, cl));
|
| }
|
| + } else if (IsAllocSizePermitted(size)) {
|
| + ret = do_malloc_pages(heap, size);
|
| + MarkAllocatedRegion(ret);
|
| }
|
| if (ret == NULL) errno = ENOMEM;
|
| + ASSERT(IsAllocSizePermitted(size) || ret == NULL);
|
| return ret;
|
| }
|
|
|
|
|