| Index: src/platform-win32.cc
|
| ===================================================================
|
| --- src/platform-win32.cc (revision 5136)
|
| +++ src/platform-win32.cc (working copy)
|
| @@ -840,10 +840,23 @@
|
| bool is_executable) {
|
| // VirtualAlloc rounds allocated size to page size automatically.
|
| size_t msize = RoundUp(requested, static_cast<int>(GetPageSize()));
|
| -
|
| + intptr_t address = NULL;
|
| // Windows XP SP2 allows Data Excution Prevention (DEP).
|
| int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
|
| - LPVOID mbase = VirtualAlloc(NULL, msize, MEM_COMMIT | MEM_RESERVE, prot);
|
| + // TODO(805): Port to Linux
|
| + // For exectutable pages try and randomize the allocation address
|
| + if (prot == PAGE_EXECUTE_READWRITE && msize >= Page::kPageSize) {
|
| + address = (V8::Random() << kPageSizeBits) | kAllocationRandomAddressMin;
|
| + address &= kAllocationRandomAddressMax;
|
| + }
|
| +
|
| + LPVOID mbase = VirtualAlloc(reinterpret_cast<void *>(address),
|
| + msize,
|
| + MEM_COMMIT | MEM_RESERVE,
|
| + prot);
|
| + if (mbase == NULL && address != NULL)
|
| + mbase = VirtualAlloc(NULL, msize, MEM_COMMIT | MEM_RESERVE, prot);
|
| +
|
| if (mbase == NULL) {
|
| LOG(StringEvent("OS::Allocate", "VirtualAlloc failed"));
|
| return NULL;
|
|
|