Index: third_party/tcmalloc/chromium/src/system-alloc.cc |
=================================================================== |
--- third_party/tcmalloc/chromium/src/system-alloc.cc (revision 124832) |
+++ third_party/tcmalloc/chromium/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,11 +103,9 @@ |
static SpinLock spinlock(SpinLock::LINKER_INITIALIZED); |
-#if defined(HAVE_MMAP) || defined(MADV_FREE) |
#ifdef HAVE_GETPAGESIZE |
static size_t pagesize = 0; |
#endif |
-#endif |
// The current system allocator |
SysAllocator* sys_alloc = NULL; |
@@ -145,6 +132,7 @@ |
SbrkSysAllocator() : SysAllocator() { |
} |
void* Alloc(size_t size, size_t *actual_size, size_t alignment); |
+ void FlagsInitialized() {} |
}; |
static char sbrk_space[sizeof(SbrkSysAllocator)]; |
@@ -153,6 +141,7 @@ |
MmapSysAllocator() : SysAllocator() { |
} |
void* Alloc(size_t size, size_t *actual_size, size_t alignment); |
+ void FlagsInitialized() {} |
}; |
static char mmap_space[sizeof(MmapSysAllocator)]; |
@@ -161,6 +150,7 @@ |
DevMemSysAllocator() : SysAllocator() { |
} |
void* Alloc(size_t size, size_t *actual_size, size_t alignment); |
+ void FlagsInitialized() {} |
}; |
class DefaultSysAllocator : public SysAllocator { |
@@ -181,6 +171,7 @@ |
} |
} |
void* Alloc(size_t size, size_t *actual_size, size_t alignment); |
+ void FlagsInitialized() {} |
private: |
static const int kMaxAllocators = 2; |
@@ -429,6 +420,7 @@ |
if (result != NULL) { |
return result; |
} |
+ TCMalloc_MESSAGE(__FILE__, __LINE__, "%s failed.\n", names_[i]); |
failed_[i] = true; |
} |
} |
@@ -507,10 +499,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(); |
@@ -534,7 +526,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 |
} |