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

Unified Diff: Source/wtf/PageAllocator.cpp

Issue 408483004: Avoid fragmenting address space on small windows systems. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Move comment higher. Created 6 years, 5 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: Source/wtf/PageAllocator.cpp
diff --git a/Source/wtf/PageAllocator.cpp b/Source/wtf/PageAllocator.cpp
index 182a76ce2b99e1b5bf9e122ba1c2a134b9c9003d..984dd9d1b22c2d7fa6689c4492e0ce19a76b2f39 100644
--- a/Source/wtf/PageAllocator.cpp
+++ b/Source/wtf/PageAllocator.cpp
@@ -58,6 +58,29 @@
namespace WTF {
+#if OS(WIN)
+
+static bool shouldUseAddressHint()
+{
+#if !CPU(X86_64)
+ // Determine if userspace is limited to 2 GB.
+ 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:21:00 Ah. Maybe I get it now. Is the 3G/1G for Windows 3
+ 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 +88,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
« 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