Chromium Code Reviews| Index: Source/wtf/PageAllocator.cpp |
| diff --git a/Source/wtf/PageAllocator.cpp b/Source/wtf/PageAllocator.cpp |
| index 182a76ce2b99e1b5bf9e122ba1c2a134b9c9003d..d580f28cb6083f5939aec909573cfee35a3ddbb3 100644 |
| --- a/Source/wtf/PageAllocator.cpp |
| +++ b/Source/wtf/PageAllocator.cpp |
| @@ -58,6 +58,28 @@ |
| namespace WTF { |
| +#if OS(WIN) |
| + |
| +static bool shouldUseAddressHint() |
| +{ |
| +#if !CPU(X86_64) |
| + static bool architectureKnown = false; |
| + static bool useHint = true; |
| + if (!architectureKnown) { |
| + SYSTEM_INFO systemInfo = { 0 }; |
| + ::GetNativeSystemInfo(&systemInfo); |
| + if (systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) |
|
Chris Evans
2014/07/18 18:03:47
I don't understand this. It sounds from the CL des
Tom Sepez
2014/07/18 18:10:06
Exactly. Will add comment.
|
| + useHint = false; |
| + architectureKnown = true; |
| + } |
| + return useHint; |
| +#else // !CPU(X86_64) |
| + return true; |
| +#endif // !CPU(X86_64) |
| +} |
| + |
| +#endif // OS(WIN) |
| + |
| // This simple internal function wraps the OS-specific page allocation call so |
| // that it behaves consistently: the address is a hint and if it cannot be used, |
| // the allocation will be placed elsewhere. |
| @@ -65,9 +87,10 @@ static void* systemAllocPages(void* addr, size_t len) |
| { |
| ASSERT(!(len & kPageAllocationGranularityOffsetMask)); |
| ASSERT(!(reinterpret_cast<uintptr_t>(addr) & kPageAllocationGranularityOffsetMask)); |
| - void* ret; |
| + void* ret = 0; |
| #if OS(WIN) |
| - ret = VirtualAlloc(addr, len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); |
| + if (shouldUseAddressHint()) |
| + ret = VirtualAlloc(addr, len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); |
| if (!ret) |
| ret = VirtualAlloc(0, len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); |
| #else |