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

Unified Diff: src/platform/virtual-memory.cc

Issue 23542027: Don't align size on allocation granularity for unaligned ReserveRegion calls. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/virtual-memory.cc
diff --git a/src/platform/virtual-memory.cc b/src/platform/virtual-memory.cc
index 7e535424fd7d17a43e1490d377d9d39d264c2488..f72bc9054c392daa7f5837daee76563eb81678fd 100644
--- a/src/platform/virtual-memory.cc
+++ b/src/platform/virtual-memory.cc
@@ -158,7 +158,7 @@ void* VirtualMemory::ReserveRegion(size_t size, size_t* size_return) {
if (size < 64 * KB) {
size = 64 * KB;
}
- size = RoundUp(size, GetAllocationGranularity());
+ size = RoundUp(size, GetPageSize());
LPVOID address = NULL;
// Try and randomize the allocation address (up to three attempts).
for (unsigned attempts = 0; address == NULL && attempts < 3; ++attempts) {
@@ -189,13 +189,14 @@ void* VirtualMemory::ReserveRegion(size_t size,
ASSERT_NE(NULL, size_return);
ASSERT(IsAligned(alignment, GetAllocationGranularity()));
- size_t reserved_size;
+ size_t reserved_size = RoundUp(size + alignment, GetAllocationGranularity());
Address reserved_base = static_cast<Address>(
- ReserveRegion(size + alignment, &reserved_size));
+ ReserveRegion(reserved_size, &reserved_size));
if (reserved_base == NULL) {
return NULL;
}
ASSERT_LE(size, reserved_size);
+ ASSERT_LE(size + alignment, reserved_size);
ASSERT(IsAligned(reserved_size, GetPageSize()));
// Try reducing the size by freeing and then reallocating a specific area.
@@ -218,6 +219,7 @@ void* VirtualMemory::ReserveRegion(size_t size,
}
// Resizing failed, just go with a bigger area.
+ ASSERT(IsAligned(reserved_size, GetAllocationGranularity()));
return ReserveRegion(reserved_size, size_return);
}
@@ -291,6 +293,7 @@ size_t VirtualMemory::GetAllocationGranularity() {
allocation_granularity = system_info.dwAllocationGranularity;
MemoryBarrier();
}
+ ASSERT_GE(allocation_granularity, GetPageSize());
return allocation_granularity;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698