6830069: UseLargePages is broken on Win64

Tue, 21 Apr 2009 16:12:51 -0400

author
coleenp
date
Tue, 21 Apr 2009 16:12:51 -0400
changeset 1152
c8152ae3f339
parent 1149
981375ca07b7
child 1153
670013185256

6830069: UseLargePages is broken on Win64
Summary: Making VirtualAlloc/VirtualProtect two calls for PAGE_EXECUTE_READWRITE doesn't work for MEM_LARGE_PAGES.
Reviewed-by: xlu, kvn, jcoomes

src/os/windows/vm/os_windows.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/os/windows/vm/os_windows.cpp	Fri Apr 17 12:22:18 2009 -0700
     1.2 +++ b/src/os/windows/vm/os_windows.cpp	Tue Apr 21 16:12:51 2009 -0400
     1.3 @@ -2632,6 +2632,8 @@
     1.4  
     1.5  char* os::reserve_memory_special(size_t bytes, char* addr, bool exec) {
     1.6  
     1.7 +  const DWORD prot = exec ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
     1.8 +
     1.9    if (UseLargePagesIndividualAllocation) {
    1.10      if (TracePageSizes && Verbose) {
    1.11         tty->print_cr("Reserving large pages individually.");
    1.12 @@ -2694,13 +2696,7 @@
    1.13          p_new = (char *) VirtualAlloc(next_alloc_addr,
    1.14                                      bytes_to_rq,
    1.15                                      MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES,
    1.16 -                                    PAGE_READWRITE);
    1.17 -        if (p_new != NULL && exec) {
    1.18 -          DWORD oldprot;
    1.19 -          // Windows doc says to use VirtualProtect to get execute permissions
    1.20 -          VirtualProtect(next_alloc_addr, bytes_to_rq,
    1.21 -                         PAGE_EXECUTE_READWRITE, &oldprot);
    1.22 -        }
    1.23 +                                    prot);
    1.24        }
    1.25  
    1.26        if (p_new == NULL) {
    1.27 @@ -2729,12 +2725,7 @@
    1.28    } else {
    1.29      // normal policy just allocate it all at once
    1.30      DWORD flag = MEM_RESERVE | MEM_COMMIT | MEM_LARGE_PAGES;
    1.31 -    char * res = (char *)VirtualAlloc(NULL, bytes, flag, PAGE_READWRITE);
    1.32 -    if (res != NULL && exec) {
    1.33 -      DWORD oldprot;
    1.34 -      // Windows doc says to use VirtualProtect to get execute permissions
    1.35 -      VirtualProtect(res, bytes, PAGE_EXECUTE_READWRITE, &oldprot);
    1.36 -    }
    1.37 +    char * res = (char *)VirtualAlloc(NULL, bytes, flag, prot);
    1.38      return res;
    1.39    }
    1.40  }

mercurial