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

src/os/windows/vm/os_windows.cpp

Print this page




3043   // Windows os::reserve_memory() fails of the requested address range is
3044   // not avilable.
3045   return reserve_memory(bytes, requested_addr);
3046 }
3047 
3048 size_t os::large_page_size() {
3049   return _large_page_size;
3050 }
3051 
3052 bool os::can_commit_large_page_memory() {
3053   // Windows only uses large page memory when the entire region is reserved
3054   // and committed in a single VirtualAlloc() call. This may change in the
3055   // future, but with Windows 2003 it's not possible to commit on demand.
3056   return false;
3057 }
3058 
3059 bool os::can_execute_large_page_memory() {
3060   return true;
3061 }
3062 
3063 char* os::reserve_memory_special(size_t bytes, char* addr, bool exec) {





3064 
3065   const DWORD prot = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
3066   const DWORD flags = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
3067 
3068   // with large pages, there are two cases where we need to use Individual Allocation
3069   // 1) the UseLargePagesIndividualAllocation flag is set (set by default on WS2003)
3070   // 2) NUMA Interleaving is enabled, in which case we use a different node for each page
3071   if (UseLargePagesIndividualAllocation || UseNUMAInterleaving) {
3072     if (TracePageSizes && Verbose) {
3073        tty->print_cr("Reserving large pages individually.");
3074     }
3075     char * p_buf = allocate_pages_individually(bytes, addr, flags, prot, LargePagesIndividualAllocationInjectError);
3076     if (p_buf == NULL) {
3077       // give an appropriate warning message
3078       if (UseNUMAInterleaving) {
3079         warning("NUMA large page allocation failed, UseLargePages flag ignored");
3080       }
3081       if (UseLargePagesIndividualAllocation) {
3082         warning("Individually allocated large pages failed, "
3083                 "use -XX:-UseLargePagesIndividualAllocation to turn off");


5519    assert(initialized && _OpenProcessToken != NULL,
5520      "AdvapiAvailable() not yet called");
5521     return _OpenProcessToken(ProcessHandle, DesiredAccess, TokenHandle);
5522 }
5523 
5524 BOOL os::Advapi32Dll::LookupPrivilegeValue(LPCTSTR lpSystemName, LPCTSTR lpName, PLUID lpLuid) {
5525    assert(initialized && _LookupPrivilegeValue != NULL,
5526      "AdvapiAvailable() not yet called");
5527   return _LookupPrivilegeValue(lpSystemName, lpName, lpLuid);
5528 }
5529 
5530 BOOL os::Advapi32Dll::AdvapiAvailable() {
5531   if (!initialized) {
5532     initialize();
5533   }
5534   return _AdjustTokenPrivileges != NULL &&
5535     _OpenProcessToken != NULL &&
5536     _LookupPrivilegeValue != NULL;
5537 }
5538 






5539 #endif


3043   // Windows os::reserve_memory() fails of the requested address range is
3044   // not avilable.
3045   return reserve_memory(bytes, requested_addr);
3046 }
3047 
3048 size_t os::large_page_size() {
3049   return _large_page_size;
3050 }
3051 
3052 bool os::can_commit_large_page_memory() {
3053   // Windows only uses large page memory when the entire region is reserved
3054   // and committed in a single VirtualAlloc() call. This may change in the
3055   // future, but with Windows 2003 it's not possible to commit on demand.
3056   return false;
3057 }
3058 
3059 bool os::can_execute_large_page_memory() {
3060   return true;
3061 }
3062 
3063 char* os::reserve_memory_special(size_t bytes, size_t alignment, char* addr, bool exec) {
3064   assert(UseLargePages, "only for large pages");
3065 
3066   if (!is_size_aligned(bytes, os::large_page_size()) || alignment > os::large_page_size()) {
3067     return NULL; // Fallback to small pages.
3068   }
3069 
3070   const DWORD prot = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
3071   const DWORD flags = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
3072 
3073   // with large pages, there are two cases where we need to use Individual Allocation
3074   // 1) the UseLargePagesIndividualAllocation flag is set (set by default on WS2003)
3075   // 2) NUMA Interleaving is enabled, in which case we use a different node for each page
3076   if (UseLargePagesIndividualAllocation || UseNUMAInterleaving) {
3077     if (TracePageSizes && Verbose) {
3078        tty->print_cr("Reserving large pages individually.");
3079     }
3080     char * p_buf = allocate_pages_individually(bytes, addr, flags, prot, LargePagesIndividualAllocationInjectError);
3081     if (p_buf == NULL) {
3082       // give an appropriate warning message
3083       if (UseNUMAInterleaving) {
3084         warning("NUMA large page allocation failed, UseLargePages flag ignored");
3085       }
3086       if (UseLargePagesIndividualAllocation) {
3087         warning("Individually allocated large pages failed, "
3088                 "use -XX:-UseLargePagesIndividualAllocation to turn off");


5524    assert(initialized && _OpenProcessToken != NULL,
5525      "AdvapiAvailable() not yet called");
5526     return _OpenProcessToken(ProcessHandle, DesiredAccess, TokenHandle);
5527 }
5528 
5529 BOOL os::Advapi32Dll::LookupPrivilegeValue(LPCTSTR lpSystemName, LPCTSTR lpName, PLUID lpLuid) {
5530    assert(initialized && _LookupPrivilegeValue != NULL,
5531      "AdvapiAvailable() not yet called");
5532   return _LookupPrivilegeValue(lpSystemName, lpName, lpLuid);
5533 }
5534 
5535 BOOL os::Advapi32Dll::AdvapiAvailable() {
5536   if (!initialized) {
5537     initialize();
5538   }
5539   return _AdjustTokenPrivileges != NULL &&
5540     _OpenProcessToken != NULL &&
5541     _LookupPrivilegeValue != NULL;
5542 }
5543 
5544 #endif
5545 
5546 #ifndef PRODUCT
5547 void TestReserveMemorySpecial_test() {
5548   // No tests available for this platform
5549 }
5550 #endif
src/os/windows/vm/os_windows.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File