Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: third_party/tcmalloc/chromium/src/system-alloc.cc

Issue 9323026: [NOT TO COMMIT!] r109: Diff of the current tcmalloc from the original google-perftools r109. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/tcmalloc/chromium/src/system-alloc.h ('k') | third_party/tcmalloc/chromium/src/tcmalloc.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 690953d722a35ab27e2f211506f5975bb5b232e5..03fc9340ec9334e4d8eef20c4a653586d2e192c7 100644
--- a/third_party/tcmalloc/chromium/src/system-alloc.cc
+++ b/third_party/tcmalloc/chromium/src/system-alloc.cc
@@ -103,8 +103,7 @@ union MemoryAligner {
static SpinLock spinlock(SpinLock::LINKER_INITIALIZED);
-#if defined(HAVE_MMAP) || defined(MADV_DONTNEED)
-// Page size is initialized on demand (only needed for mmap-based allocators)
+#ifdef HAVE_GETPAGESIZE
static size_t pagesize = 0;
#endif
@@ -160,6 +159,7 @@ class DefaultSysAllocator : public SysAllocator {
for (int i = 0; i < kMaxAllocators; i++) {
failed_[i] = true;
allocs_[i] = NULL;
+ names_[i] = NULL;
}
}
void SetChildAllocator(SysAllocator* alloc, unsigned int index,
@@ -167,6 +167,7 @@ class DefaultSysAllocator : public SysAllocator {
if (index < kMaxAllocators && alloc != NULL) {
allocs_[index] = alloc;
failed_[index] = false;
+ names_[index] = name;
}
}
void* Alloc(size_t size, size_t *actual_size, size_t alignment);
@@ -186,7 +187,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.
@@ -201,7 +201,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.
@@ -258,7 +258,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.
@@ -327,7 +326,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;
@@ -485,6 +483,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_DONTNEED
if (FLAGS_malloc_devmem_start) {
@@ -520,3 +533,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.
+}
« no previous file with comments | « third_party/tcmalloc/chromium/src/system-alloc.h ('k') | third_party/tcmalloc/chromium/src/tcmalloc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698