Don't align size on allocation granularity for unaligned ReserveRegion calls.
Also add additional ASSERTs to help tracking the flaky test-alloc/CodeRange in Windows. R=verwaest@chromium.org Review URL: https://codereview.chromium.org/23542027 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16648 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
c570640334
commit
0e7f6a296e
@ -158,7 +158,7 @@ void* VirtualMemory::ReserveRegion(size_t size, size_t* size_return) {
|
|||||||
if (size < 64 * KB) {
|
if (size < 64 * KB) {
|
||||||
size = 64 * KB;
|
size = 64 * KB;
|
||||||
}
|
}
|
||||||
size = RoundUp(size, GetAllocationGranularity());
|
size = RoundUp(size, GetPageSize());
|
||||||
LPVOID address = NULL;
|
LPVOID address = NULL;
|
||||||
// Try and randomize the allocation address (up to three attempts).
|
// Try and randomize the allocation address (up to three attempts).
|
||||||
for (unsigned attempts = 0; address == NULL && attempts < 3; ++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_NE(NULL, size_return);
|
||||||
ASSERT(IsAligned(alignment, GetAllocationGranularity()));
|
ASSERT(IsAligned(alignment, GetAllocationGranularity()));
|
||||||
|
|
||||||
size_t reserved_size;
|
size_t reserved_size = RoundUp(size + alignment, GetAllocationGranularity());
|
||||||
Address reserved_base = static_cast<Address>(
|
Address reserved_base = static_cast<Address>(
|
||||||
ReserveRegion(size + alignment, &reserved_size));
|
ReserveRegion(reserved_size, &reserved_size));
|
||||||
if (reserved_base == NULL) {
|
if (reserved_base == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ASSERT_LE(size, reserved_size);
|
ASSERT_LE(size, reserved_size);
|
||||||
|
ASSERT_LE(size + alignment, reserved_size);
|
||||||
ASSERT(IsAligned(reserved_size, GetPageSize()));
|
ASSERT(IsAligned(reserved_size, GetPageSize()));
|
||||||
|
|
||||||
// Try reducing the size by freeing and then reallocating a specific area.
|
// 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.
|
// Resizing failed, just go with a bigger area.
|
||||||
|
ASSERT(IsAligned(reserved_size, GetAllocationGranularity()));
|
||||||
return ReserveRegion(reserved_size, size_return);
|
return ReserveRegion(reserved_size, size_return);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,6 +293,7 @@ size_t VirtualMemory::GetAllocationGranularity() {
|
|||||||
allocation_granularity = system_info.dwAllocationGranularity;
|
allocation_granularity = system_info.dwAllocationGranularity;
|
||||||
MemoryBarrier();
|
MemoryBarrier();
|
||||||
}
|
}
|
||||||
|
ASSERT_GE(allocation_granularity, GetPageSize());
|
||||||
return allocation_granularity;
|
return allocation_granularity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user