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

Unified Diff: src/platform-linux.cc

Issue 8060052: Fix leakage of virtual address space on Linux platform. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 3 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 | « src/platform.h ('k') | src/platform-macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-linux.cc
diff --git a/src/platform-linux.cc b/src/platform-linux.cc
index 2d6160e473f12c89f67693e44759622b9a538bc6..855ebf78e16fe14beba51d616c84a83bd03df9f3 100644
--- a/src/platform-linux.cc
+++ b/src/platform-linux.cc
@@ -477,7 +477,7 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size,
PosixMemoryMappedFile::~PosixMemoryMappedFile() {
- if (memory_) munmap(memory_, size_);
+ if (memory_) OS::Free(memory_, size_);
fclose(file_);
}
@@ -559,7 +559,7 @@ void OS::SignalCodeMovingGC() {
void* addr = mmap(NULL, size, PROT_READ | PROT_EXEC, MAP_PRIVATE,
fileno(f), 0);
ASSERT(addr != MAP_FAILED);
- munmap(addr, size);
+ OS::Free(addr, size);
fclose(f);
}
@@ -621,21 +621,31 @@ VirtualMemory::VirtualMemory(size_t size, size_t alignment)
kMmapFd,
kMmapFdOffset);
if (reservation == MAP_FAILED) return;
+
Address base = static_cast<Address>(reservation);
Address aligned_base = RoundUp(base, alignment);
- ASSERT(base <= aligned_base);
+ ASSERT_LE(base, aligned_base);
// Unmap extra memory reserved before and after the desired block.
- size_t bytes_prior = static_cast<size_t>(aligned_base - base);
- if (bytes_prior > 0) {
- munmap(base, bytes_prior);
+ if (aligned_base != base) {
+ size_t prefix_size = static_cast<size_t>(aligned_base - base);
+ OS::Free(base, prefix_size);
+ request_size -= prefix_size;
}
- if (static_cast<size_t>(aligned_base - base) < request_size - size) {
- munmap(aligned_base + size, request_size - size - bytes_prior);
+
+ size_t aligned_size = RoundUp(size, OS::AllocateAlignment());
+ ASSERT_LE(aligned_size, request_size);
+
+ if (aligned_size != request_size) {
+ size_t suffix_size = request_size - aligned_size;
+ OS::Free(aligned_base + aligned_size, suffix_size);
+ request_size -= suffix_size;
}
+ ASSERT(aligned_size == request_size);
+
address_ = static_cast<void*>(aligned_base);
- size_ = size;
+ size_ = aligned_size;
}
« no previous file with comments | « src/platform.h ('k') | src/platform-macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698