| Index: third_party/tcmalloc/vendor/src/system-alloc.cc
|
| ===================================================================
|
| --- third_party/tcmalloc/vendor/src/system-alloc.cc (revision 126727)
|
| +++ third_party/tcmalloc/vendor/src/system-alloc.cc (working copy)
|
| @@ -48,7 +48,7 @@
|
| #include <unistd.h> // for sbrk, getpagesize, off_t
|
| #endif
|
| #include <new> // for operator new
|
| -#include <gperftools/malloc_extension.h>
|
| +#include <google/malloc_extension.h>
|
| #include "base/basictypes.h"
|
| #include "base/commandlineflags.h"
|
| #include "base/spinlock.h" // for SpinLockHolder, SpinLock, etc
|
| @@ -61,13 +61,6 @@
|
| # define MAP_ANONYMOUS MAP_ANON
|
| #endif
|
|
|
| -// MADV_FREE is specifically designed for use by malloc(), but only
|
| -// FreeBSD supports it; in linux we fall back to the somewhat inferior
|
| -// MADV_DONTNEED.
|
| -#if !defined(MADV_FREE) && defined(MADV_DONTNEED)
|
| -# define MADV_FREE MADV_DONTNEED
|
| -#endif
|
| -
|
| // Solaris has a bug where it doesn't declare madvise() for C++.
|
| // http://www.opensolaris.org/jive/thread.jspa?threadID=21035&tstart=0
|
| #if defined(__sun) && defined(__SVR4)
|
| @@ -83,10 +76,6 @@
|
| static const bool kDebugMode = true;
|
| #endif
|
|
|
| -// TODO(sanjay): Move the code below into the tcmalloc namespace
|
| -using tcmalloc::kLog;
|
| -using tcmalloc::Log;
|
| -
|
| // Anonymous namespace to avoid name conflicts on "CheckAddressBits".
|
| namespace {
|
|
|
| @@ -114,7 +103,7 @@
|
|
|
| static SpinLock spinlock(SpinLock::LINKER_INITIALIZED);
|
|
|
| -#if defined(HAVE_MMAP) || defined(MADV_FREE)
|
| +#if defined(HAVE_MMAP) || defined(MADV_DONTNEED)
|
| // Page size is initialized on demand (only needed for mmap-based allocators)
|
| static size_t pagesize = 0;
|
| #endif
|
| @@ -431,6 +420,7 @@
|
| if (result != NULL) {
|
| return result;
|
| }
|
| + TCMalloc_MESSAGE(__FILE__, __LINE__, "%s failed.\n", names_[i]);
|
| failed_[i] = true;
|
| }
|
| }
|
| @@ -494,10 +484,10 @@
|
| }
|
|
|
| void TCMalloc_SystemRelease(void* start, size_t length) {
|
| -#ifdef MADV_FREE
|
| +#ifdef MADV_DONTNEED
|
| if (FLAGS_malloc_devmem_start) {
|
| - // It's not safe to use MADV_FREE/MADV_DONTNEED if we've been
|
| - // mapping /dev/mem for heap memory.
|
| + // It's not safe to use MADV_DONTNEED if we've been mapping
|
| + // /dev/mem for heap memory
|
| return;
|
| }
|
| if (pagesize == 0) pagesize = getpagesize();
|
| @@ -521,7 +511,7 @@
|
| // Note -- ignoring most return codes, because if this fails it
|
| // doesn't matter...
|
| while (madvise(reinterpret_cast<char*>(new_start), new_end - new_start,
|
| - MADV_FREE) == -1 &&
|
| + MADV_DONTNEED) == -1 &&
|
| errno == EAGAIN) {
|
| // NOP
|
| }
|
|
|