src/os/windows/vm/os_windows.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hsx-rt.8007074 Sdiff src/os/windows/vm

src/os/windows/vm/os_windows.cpp

Print this page




3139   // Windows os::reserve_memory() fails of the requested address range is
3140   // not avilable.
3141   return reserve_memory(bytes, requested_addr);
3142 }
3143 
3144 size_t os::large_page_size() {
3145   return _large_page_size;
3146 }
3147 
3148 bool os::can_commit_large_page_memory() {
3149   // Windows only uses large page memory when the entire region is reserved
3150   // and committed in a single VirtualAlloc() call. This may change in the
3151   // future, but with Windows 2003 it's not possible to commit on demand.
3152   return false;
3153 }
3154 
3155 bool os::can_execute_large_page_memory() {
3156   return true;
3157 }
3158 
3159 char* os::reserve_memory_special(size_t bytes, char* addr, bool exec) {





3160 
3161   const DWORD prot = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
3162   const DWORD flags = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
3163 
3164   // with large pages, there are two cases where we need to use Individual Allocation
3165   // 1) the UseLargePagesIndividualAllocation flag is set (set by default on WS2003)
3166   // 2) NUMA Interleaving is enabled, in which case we use a different node for each page
3167   if (UseLargePagesIndividualAllocation || UseNUMAInterleaving) {
3168     if (TracePageSizes && Verbose) {
3169        tty->print_cr("Reserving large pages individually.");
3170     }
3171     char * p_buf = allocate_pages_individually(bytes, addr, flags, prot, LargePagesIndividualAllocationInjectError);
3172     if (p_buf == NULL) {
3173       // give an appropriate warning message
3174       if (UseNUMAInterleaving) {
3175         warning("NUMA large page allocation failed, UseLargePages flag ignored");
3176       }
3177       if (UseLargePagesIndividualAllocation) {
3178         warning("Individually allocated large pages failed, "
3179                 "use -XX:-UseLargePagesIndividualAllocation to turn off");


5620    assert(initialized && _OpenProcessToken != NULL,
5621      "AdvapiAvailable() not yet called");
5622     return _OpenProcessToken(ProcessHandle, DesiredAccess, TokenHandle);
5623 }
5624 
5625 BOOL os::Advapi32Dll::LookupPrivilegeValue(LPCTSTR lpSystemName, LPCTSTR lpName, PLUID lpLuid) {
5626    assert(initialized && _LookupPrivilegeValue != NULL,
5627      "AdvapiAvailable() not yet called");
5628   return _LookupPrivilegeValue(lpSystemName, lpName, lpLuid);
5629 }
5630 
5631 BOOL os::Advapi32Dll::AdvapiAvailable() {
5632   if (!initialized) {
5633     initialize();
5634   }
5635   return _AdjustTokenPrivileges != NULL &&
5636     _OpenProcessToken != NULL &&
5637     _LookupPrivilegeValue != NULL;
5638 }
5639 






5640 #endif


3139   // Windows os::reserve_memory() fails of the requested address range is
3140   // not avilable.
3141   return reserve_memory(bytes, requested_addr);
3142 }
3143 
3144 size_t os::large_page_size() {
3145   return _large_page_size;
3146 }
3147 
3148 bool os::can_commit_large_page_memory() {
3149   // Windows only uses large page memory when the entire region is reserved
3150   // and committed in a single VirtualAlloc() call. This may change in the
3151   // future, but with Windows 2003 it's not possible to commit on demand.
3152   return false;
3153 }
3154 
3155 bool os::can_execute_large_page_memory() {
3156   return true;
3157 }
3158 
3159 char* os::reserve_memory_special(size_t bytes, size_t alignment, char* addr, bool exec) {
3160   assert(UseLargePages, "only for large pages");
3161 
3162   if (!is_size_aligned(bytes, os::large_page_size()) || alignment > os::large_page_size()) {
3163     return NULL; // Fallback to small pages.
3164   }
3165 
3166   const DWORD prot = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
3167   const DWORD flags = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
3168 
3169   // with large pages, there are two cases where we need to use Individual Allocation
3170   // 1) the UseLargePagesIndividualAllocation flag is set (set by default on WS2003)
3171   // 2) NUMA Interleaving is enabled, in which case we use a different node for each page
3172   if (UseLargePagesIndividualAllocation || UseNUMAInterleaving) {
3173     if (TracePageSizes && Verbose) {
3174        tty->print_cr("Reserving large pages individually.");
3175     }
3176     char * p_buf = allocate_pages_individually(bytes, addr, flags, prot, LargePagesIndividualAllocationInjectError);
3177     if (p_buf == NULL) {
3178       // give an appropriate warning message
3179       if (UseNUMAInterleaving) {
3180         warning("NUMA large page allocation failed, UseLargePages flag ignored");
3181       }
3182       if (UseLargePagesIndividualAllocation) {
3183         warning("Individually allocated large pages failed, "
3184                 "use -XX:-UseLargePagesIndividualAllocation to turn off");


5625    assert(initialized && _OpenProcessToken != NULL,
5626      "AdvapiAvailable() not yet called");
5627     return _OpenProcessToken(ProcessHandle, DesiredAccess, TokenHandle);
5628 }
5629 
5630 BOOL os::Advapi32Dll::LookupPrivilegeValue(LPCTSTR lpSystemName, LPCTSTR lpName, PLUID lpLuid) {
5631    assert(initialized && _LookupPrivilegeValue != NULL,
5632      "AdvapiAvailable() not yet called");
5633   return _LookupPrivilegeValue(lpSystemName, lpName, lpLuid);
5634 }
5635 
5636 BOOL os::Advapi32Dll::AdvapiAvailable() {
5637   if (!initialized) {
5638     initialize();
5639   }
5640   return _AdjustTokenPrivileges != NULL &&
5641     _OpenProcessToken != NULL &&
5642     _LookupPrivilegeValue != NULL;
5643 }
5644 
5645 #endif
5646 
5647 #ifndef PRODUCT
5648 void TestReserveMemorySpecial_test() {
5649   // No tests available for this platform
5650 }
5651 #endif
src/os/windows/vm/os_windows.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File