| Index: third_party/tcmalloc/chromium/src/system-alloc.cc
|
| diff --git a/third_party/tcmalloc/chromium/src/system-alloc.cc b/third_party/tcmalloc/chromium/src/system-alloc.cc
|
| index ea718b3990f60531b267410d1b075aad4f3a190c..d11a6021335454421484c2533be3286e77ea612a 100644
|
| --- a/third_party/tcmalloc/chromium/src/system-alloc.cc
|
| +++ b/third_party/tcmalloc/chromium/src/system-alloc.cc
|
| @@ -114,8 +114,7 @@ union MemoryAligner {
|
|
|
| static SpinLock spinlock(SpinLock::LINKER_INITIALIZED);
|
|
|
| -#if defined(HAVE_MMAP) || defined(MADV_FREE)
|
| -// Page size is initialized on demand (only needed for mmap-based allocators)
|
| +#ifdef HAVE_GETPAGESIZE
|
| static size_t pagesize = 0;
|
| #endif
|
|
|
| @@ -195,7 +194,6 @@ static const char mmap_name[] = "MmapSysAllocator";
|
| void* SbrkSysAllocator::Alloc(size_t size, size_t *actual_size,
|
| size_t alignment) {
|
| #ifndef HAVE_SBRK
|
| - failed_ = true;
|
| return NULL;
|
| #else
|
| // Check if we should use sbrk allocation.
|
| @@ -210,7 +208,7 @@ void* SbrkSysAllocator::Alloc(size_t size, size_t *actual_size,
|
|
|
| // sbrk will release memory if passed a negative number, so we do
|
| // a strict check here
|
| - if (static_cast<ptrdiff_t>(size + alignment) < 0) return NULL;
|
| + if (static_cast<std::ptrdiff_t>(size + alignment) < 0) return NULL;
|
|
|
| // This doesn't overflow because TCMalloc_SystemAlloc has already
|
| // tested for overflow at the alignment boundary.
|
| @@ -267,7 +265,6 @@ void* SbrkSysAllocator::Alloc(size_t size, size_t *actual_size,
|
| void* MmapSysAllocator::Alloc(size_t size, size_t *actual_size,
|
| size_t alignment) {
|
| #ifndef HAVE_MMAP
|
| - failed_ = true;
|
| return NULL;
|
| #else
|
| // Check if we should use mmap allocation.
|
| @@ -336,7 +333,6 @@ void* MmapSysAllocator::Alloc(size_t size, size_t *actual_size,
|
| void* DevMemSysAllocator::Alloc(size_t size, size_t *actual_size,
|
| size_t alignment) {
|
| #ifndef HAVE_MMAP
|
| - failed_ = true;
|
| return NULL;
|
| #else
|
| static bool initialized = false;
|
| @@ -493,6 +489,21 @@ void* TCMalloc_SystemAlloc(size_t size, size_t *actual_size,
|
| return result;
|
| }
|
|
|
| +size_t TCMalloc_SystemAddGuard(void* start, size_t size) {
|
| +#ifdef HAVE_GETPAGESIZE
|
| + if (pagesize == 0)
|
| + pagesize = getpagesize();
|
| +
|
| + if (size < pagesize || (reinterpret_cast<size_t>(start) % pagesize) != 0)
|
| + return 0;
|
| +
|
| + if (!mprotect(start, pagesize, PROT_NONE))
|
| + return pagesize;
|
| +#endif
|
| +
|
| + return 0;
|
| +}
|
| +
|
| void TCMalloc_SystemRelease(void* start, size_t length) {
|
| #ifdef MADV_FREE
|
| if (FLAGS_malloc_devmem_start) {
|
| @@ -528,3 +539,9 @@ void TCMalloc_SystemRelease(void* start, size_t length) {
|
| }
|
| #endif
|
| }
|
| +
|
| +void TCMalloc_SystemCommit(void* start, size_t length) {
|
| + // Nothing to do here. TCMalloc_SystemRelease does not alter pages
|
| + // such that they need to be re-committed before they can be used by the
|
| + // application.
|
| +}
|
|
|