Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 #elif OS(WIN) | 51 #elif OS(WIN) |
| 52 | 52 |
| 53 #include <windows.h> | 53 #include <windows.h> |
| 54 | 54 |
| 55 #else | 55 #else |
| 56 #error Unknown OS | 56 #error Unknown OS |
| 57 #endif // OS(POSIX) | 57 #endif // OS(POSIX) |
| 58 | 58 |
| 59 namespace WTF { | 59 namespace WTF { |
| 60 | 60 |
| 61 #if OS(WIN) | |
| 62 | |
| 63 static bool shouldUseAddressHint() | |
| 64 { | |
| 65 #if !CPU(X86_64) | |
| 66 // Determine if userspace is limited to 2 GB. | |
| 67 static bool architectureKnown = false; | |
| 68 static bool useHint = true; | |
| 69 if (!architectureKnown) { | |
| 70 SYSTEM_INFO systemInfo = { 0 }; | |
| 71 ::GetNativeSystemInfo(&systemInfo); | |
| 72 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
| |
| 73 useHint = false; | |
| 74 architectureKnown = true; | |
| 75 } | |
| 76 return useHint; | |
| 77 #else // !CPU(X86_64) | |
| 78 return true; | |
| 79 #endif // !CPU(X86_64) | |
| 80 } | |
| 81 | |
| 82 #endif // OS(WIN) | |
| 83 | |
| 61 // This simple internal function wraps the OS-specific page allocation call so | 84 // This simple internal function wraps the OS-specific page allocation call so |
| 62 // that it behaves consistently: the address is a hint and if it cannot be used, | 85 // that it behaves consistently: the address is a hint and if it cannot be used, |
| 63 // the allocation will be placed elsewhere. | 86 // the allocation will be placed elsewhere. |
| 64 static void* systemAllocPages(void* addr, size_t len) | 87 static void* systemAllocPages(void* addr, size_t len) |
| 65 { | 88 { |
| 66 ASSERT(!(len & kPageAllocationGranularityOffsetMask)); | 89 ASSERT(!(len & kPageAllocationGranularityOffsetMask)); |
| 67 ASSERT(!(reinterpret_cast<uintptr_t>(addr) & kPageAllocationGranularityOffse tMask)); | 90 ASSERT(!(reinterpret_cast<uintptr_t>(addr) & kPageAllocationGranularityOffse tMask)); |
| 68 void* ret; | 91 void* ret = 0; |
| 69 #if OS(WIN) | 92 #if OS(WIN) |
| 70 ret = VirtualAlloc(addr, len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); | 93 if (shouldUseAddressHint()) |
| 94 ret = VirtualAlloc(addr, len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); | |
| 71 if (!ret) | 95 if (!ret) |
| 72 ret = VirtualAlloc(0, len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); | 96 ret = VirtualAlloc(0, len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); |
| 73 #else | 97 #else |
| 74 ret = mmap(addr, len, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, - 1, 0); | 98 ret = mmap(addr, len, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, - 1, 0); |
| 75 if (ret == MAP_FAILED) | 99 if (ret == MAP_FAILED) |
| 76 ret = 0; | 100 ret = 0; |
| 77 #endif | 101 #endif |
| 78 return ret; | 102 return ret; |
| 79 } | 103 } |
| 80 | 104 |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 ASSERT(!(len & kSystemPageOffsetMask)); | 240 ASSERT(!(len & kSystemPageOffsetMask)); |
| 217 #if OS(POSIX) | 241 #if OS(POSIX) |
| 218 (void) addr; | 242 (void) addr; |
| 219 #else | 243 #else |
| 220 setSystemPagesAccessible(addr, len); | 244 setSystemPagesAccessible(addr, len); |
| 221 #endif | 245 #endif |
| 222 } | 246 } |
| 223 | 247 |
| 224 } // namespace WTF | 248 } // namespace WTF |
| 225 | 249 |
| OLD | NEW |