< prev index next >
src/hotspot/os/windows/os_windows.cpp
Print this page
*** 2761,2802 ****
return false;
}
// Test if GDI functions work when memory spans
// two adjacent memory reservations.
! static bool gdi_can_use_split_reservation_memory(bool use_large_pages, size_t granule) {
! DWORD mem_large_pages = use_large_pages ? MEM_LARGE_PAGES : 0;
! // Find virtual memory range. Two granules for regions and one for alignment.
void* reserved = VirtualAlloc(NULL,
! granule * 3,
MEM_RESERVE,
PAGE_NOACCESS);
if (reserved == NULL) {
// Can't proceed with test - pessimistically report false
return false;
}
VirtualFreeChecked(reserved, 0, MEM_RELEASE);
! // Ensure proper alignment
! void* res0 = align_up(reserved, granule);
! void* res1 = (char*)res0 + granule;
// Reserve and commit the first part
void* mem0 = VirtualAlloc(res0,
granule,
! MEM_RESERVE|MEM_COMMIT|mem_large_pages,
PAGE_READWRITE);
if (mem0 != res0) {
// Can't proceed with test - pessimistically report false
return false;
}
// Reserve and commit the second part
void* mem1 = VirtualAlloc(res1,
granule,
! MEM_RESERVE|MEM_COMMIT|mem_large_pages,
PAGE_READWRITE);
if (mem1 != res1) {
VirtualFreeChecked(mem0, 0, MEM_RELEASE);
// Can't proceed with test - pessimistically report false
return false;
--- 2761,2801 ----
return false;
}
// Test if GDI functions work when memory spans
// two adjacent memory reservations.
! static bool gdi_can_use_split_reservation_memory() {
! size_t granule = os::vm_allocation_granularity();
! // Find virtual memory range
void* reserved = VirtualAlloc(NULL,
! granule * 2,
MEM_RESERVE,
PAGE_NOACCESS);
if (reserved == NULL) {
// Can't proceed with test - pessimistically report false
return false;
}
VirtualFreeChecked(reserved, 0, MEM_RELEASE);
! void* res0 = reserved;
! void* res1 = (char*)reserved + granule;
// Reserve and commit the first part
void* mem0 = VirtualAlloc(res0,
granule,
! MEM_RESERVE|MEM_COMMIT,
PAGE_READWRITE);
if (mem0 != res0) {
// Can't proceed with test - pessimistically report false
return false;
}
// Reserve and commit the second part
void* mem1 = VirtualAlloc(res1,
granule,
! MEM_RESERVE|MEM_COMMIT,
PAGE_READWRITE);
if (mem1 != res1) {
VirtualFreeChecked(mem0, 0, MEM_RELEASE);
// Can't proceed with test - pessimistically report false
return false;
*** 2914,2924 ****
WARN("Process does not cover multiple NUMA nodes.");
WARN("...Ignoring UseNUMAInterleaving flag.");
return false;
}
! if (!gdi_can_use_split_reservation_memory(UseLargePages, min_interleave_granularity)) {
WARN("Windows GDI cannot handle split reservations.");
WARN("...Ignoring UseNUMAInterleaving flag.");
return false;
}
--- 2913,2923 ----
WARN("Process does not cover multiple NUMA nodes.");
WARN("...Ignoring UseNUMAInterleaving flag.");
return false;
}
! if (!gdi_can_use_split_reservation_memory()) {
WARN("Windows GDI cannot handle split reservations.");
WARN("...Ignoring UseNUMAInterleaving flag.");
return false;
}
*** 3080,3108 ****
if (LargePageSizeInBytes > 0 && LargePageSizeInBytes % size == 0) {
size = LargePageSizeInBytes;
}
- // Now test allocating a page
- void* large_page = VirtualAlloc(NULL,
- size,
- MEM_RESERVE|MEM_COMMIT|MEM_LARGE_PAGES,
- PAGE_READWRITE);
- if (large_page == NULL) {
- WARN("JVM cannot allocate one single large page.");
- return 0;
- }
-
- // Detect if GDI can use memory backed by large pages
- if (!gdi_can_use_memory(large_page)) {
- WARN("JVM cannot use large pages because of bug in Windows GDI.");
- return 0;
- }
-
- // Release test page
- VirtualFreeChecked(large_page, 0, MEM_RELEASE);
-
#undef WARN
return size;
}
--- 3079,3088 ----
*** 3119,3138 ****
_page_sizes[1] = default_page_size;
_page_sizes[2] = 0;
}
UseLargePages = _large_page_size != 0;
-
- if (UseLargePages && UseLargePagesIndividualAllocation) {
- if (!gdi_can_use_split_reservation_memory(true /* use_large_pages */, _large_page_size)) {
- if (FLAG_IS_CMDLINE(UseLargePagesIndividualAllocation)) {
- warning("Windows GDI cannot handle split reservations.");
- warning("...Ignoring UseLargePagesIndividualAllocation flag.");
- }
- UseLargePagesIndividualAllocation = false;
- }
- }
}
int os::create_file_for_heap(const char* dir) {
const char name_template[] = "/jvmheap.XXXXXX";
--- 3099,3108 ----
< prev index next >