Chromium Code Reviews| 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..e0b7908ed20663c389a5e7893040e6e685e4b614 100644 |
| --- a/third_party/tcmalloc/chromium/src/tcmalloc.cc |
| +++ b/third_party/tcmalloc/chromium/src/tcmalloc.cc |
| @@ -1089,31 +1089,28 @@ 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)) { |
|
jar (doing other things)
2013/03/15 23:00:47
It would probably be clearer to not even risk call
jln (very slow on Chromium)
2013/03/17 10:21:51
For security, I would really be wary of making any
|
| + 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. |
|
jar (doing other things)
2013/03/15 23:00:47
...but this line of optimization points a scary fi
|
| + |
| + 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; |
| return ret; |