6830069: UseLargePages is broken on Win64
Making VirtualAlloc/VirtualProtect two calls for PAGE_EXECUTE_READWRITE doesn't work for MEM_LARGE_PAGES. Reviewed-by: xlu, kvn, jcoomes
This commit is contained in:
parent
425fb8197e
commit
2e43a0450f
@ -2632,6 +2632,8 @@ bool os::can_execute_large_page_memory() {
|
|||||||
|
|
||||||
char* os::reserve_memory_special(size_t bytes, char* addr, bool exec) {
|
char* os::reserve_memory_special(size_t bytes, char* addr, bool exec) {
|
||||||
|
|
||||||
|
const DWORD prot = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
|
||||||
|
|
||||||
if (UseLargePagesIndividualAllocation) {
|
if (UseLargePagesIndividualAllocation) {
|
||||||
if (TracePageSizes && Verbose) {
|
if (TracePageSizes && Verbose) {
|
||||||
tty->print_cr("Reserving large pages individually.");
|
tty->print_cr("Reserving large pages individually.");
|
||||||
@ -2694,13 +2696,7 @@ char* os::reserve_memory_special(size_t bytes, char* addr, bool exec) {
|
|||||||
p_new = (char *) VirtualAlloc(next_alloc_addr,
|
p_new = (char *) VirtualAlloc(next_alloc_addr,
|
||||||
bytes_to_rq,
|
bytes_to_rq,
|
||||||
MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES,
|
MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES,
|
||||||
PAGE_READWRITE);
|
prot);
|
||||||
if (p_new != NULL && exec) {
|
|
||||||
DWORD oldprot;
|
|
||||||
// Windows doc says to use VirtualProtect to get execute permissions
|
|
||||||
VirtualProtect(next_alloc_addr, bytes_to_rq,
|
|
||||||
PAGE_EXECUTE_READWRITE, &oldprot);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_new == NULL) {
|
if (p_new == NULL) {
|
||||||
@ -2729,12 +2725,7 @@ char* os::reserve_memory_special(size_t bytes, char* addr, bool exec) {
|
|||||||
} else {
|
} else {
|
||||||
// normal policy just allocate it all at once
|
// normal policy just allocate it all at once
|
||||||
DWORD flag = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
|
DWORD flag = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
|
||||||
char * res = (char *)VirtualAlloc(NULL, bytes, flag, PAGE_READWRITE);
|
char * res = (char *)VirtualAlloc(NULL, bytes, flag, prot);
|
||||||
if (res != NULL && exec) {
|
|
||||||
DWORD oldprot;
|
|
||||||
// Windows doc says to use VirtualProtect to get execute permissions
|
|
||||||
VirtualProtect(res, bytes, PAGE_EXECUTE_READWRITE, &oldprot);
|
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user