Index: third_party/tcmalloc/chromium/src/common.cc |
diff --git a/third_party/tcmalloc/chromium/src/common.cc b/third_party/tcmalloc/chromium/src/common.cc |
index 8221b0869f45e9ead12a51ed44c9dbfb2e33c62f..69514b6f4d08f5363015c4f98754312d8465367f 100644 |
--- a/third_party/tcmalloc/chromium/src/common.cc |
+++ b/third_party/tcmalloc/chromium/src/common.cc |
@@ -34,6 +34,10 @@ |
#include "common.h" |
#include "system-alloc.h" |
+#if defined(HAVE_UNISTD_H) && defined(HAVE_GETPAGESIZE) |
+#include <unistd.h> // for getpagesize |
+#endif |
+ |
namespace tcmalloc { |
// Note: the following only works for "n"s that fit in 32-bits, but |
@@ -106,7 +110,7 @@ void SizeMap::Init() { |
int alignment = kAlignment; |
CHECK_CONDITION(kAlignment <= 16); |
int last_lg = -1; |
- for (size_t size = kAlignment; size <= kMaxSize; size += alignment) { |
+ for (size_t size = kMinClassSize; size <= kMaxSize; size += alignment) { |
int lg = LgFloor(size); |
if (lg > last_lg) { |
// Increase alignment every so often to reduce number of size classes. |
@@ -201,7 +205,13 @@ void SizeMap::Dump(TCMalloc_Printer* out) { |
// Metadata allocator -- keeps stats about how many bytes allocated. |
static uint64_t metadata_system_bytes_ = 0; |
void* MetaDataAlloc(size_t bytes) { |
- void* result = TCMalloc_SystemAlloc(bytes, NULL); |
+ static size_t pagesize; |
+#ifdef HAVE_GETPAGESIZE |
+ if (pagesize == 0) |
+ pagesize = getpagesize(); |
+#endif |
+ |
+ void* result = TCMalloc_SystemAlloc(bytes, NULL, pagesize); |
if (result != NULL) { |
metadata_system_bytes_ += bytes; |
} |
@@ -210,4 +220,8 @@ void* MetaDataAlloc(size_t bytes) { |
uint64_t metadata_system_bytes() { return metadata_system_bytes_; } |
+void increment_metadata_system_bytes(size_t bytes) { |
+ metadata_system_bytes_ += bytes; |
+} |
+ |
} // namespace tcmalloc |