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

src/os/windows/vm/os_windows.cpp

Print this page




2878   cleanup_after_large_page_init();
2879   UseLargePages = success;
2880 }
2881 
2882 // On win32, one cannot release just a part of reserved memory, it's an
2883 // all or nothing deal.  When we split a reservation, we must break the
2884 // reservation into two reservations.
2885 void os::pd_split_reserved_memory(char *base, size_t size, size_t split,
2886                               bool realloc) {
2887   if (size > 0) {
2888     release_memory(base, size);
2889     if (realloc) {
2890       reserve_memory(split, base);
2891     }
2892     if (size != split) {
2893       reserve_memory(size - split, base + split);
2894     }
2895   }
2896 }
2897 



























2898 char* os::pd_reserve_memory(size_t bytes, char* addr, size_t alignment_hint) {
2899   assert((size_t)addr % os::vm_allocation_granularity() == 0,
2900          "reserve alignment");
2901   assert(bytes % os::vm_allocation_granularity() == 0, "reserve block size");
2902   char* res;
2903   // note that if UseLargePages is on, all the areas that require interleaving
2904   // will go thru reserve_memory_special rather than thru here.
2905   bool use_individual = (UseNUMAInterleaving && !UseLargePages);
2906   if (!use_individual) {
2907     res = (char*)VirtualAlloc(addr, bytes, MEM_RESERVE, PAGE_READWRITE);
2908   } else {
2909     elapsedTimer reserveTimer;
2910     if( Verbose && PrintMiscellaneous ) reserveTimer.start();
2911     // in numa interleaving, we have to allocate pages individually
2912     // (well really chunks of NUMAInterleaveGranularity size)
2913     res = allocate_pages_individually(bytes, addr, MEM_RESERVE, PAGE_READWRITE);
2914     if (res == NULL) {
2915       warning("NUMA page allocation failed");
2916     }
2917     if( Verbose && PrintMiscellaneous ) {




2878   cleanup_after_large_page_init();
2879   UseLargePages = success;
2880 }
2881 
2882 // On win32, one cannot release just a part of reserved memory, it's an
2883 // all or nothing deal.  When we split a reservation, we must break the
2884 // reservation into two reservations.
2885 void os::pd_split_reserved_memory(char *base, size_t size, size_t split,
2886                               bool realloc) {
2887   if (size > 0) {
2888     release_memory(base, size);
2889     if (realloc) {
2890       reserve_memory(split, base);
2891     }
2892     if (size != split) {
2893       reserve_memory(size - split, base + split);
2894     }
2895   }
2896 }
2897 
2898 char* os::reserve_memory_aligned(size_t size, size_t alignment) {
2899   assert((alignment & (os::vm_allocation_granularity() - 1)) == 0,
2900       "Alignment must be a multiple of allocation granularity (page size)");
2901   assert((size & (alignment -1)) == 0, "size must be 'alignment' aligned");
2902 
2903   size_t extra_size = size + alignment;
2904   assert(extra_size >= size, "overflow, size is too large to allow alignment");
2905 
2906   char* aligned_base = NULL;
2907 
2908   do {
2909     char* extra_base = os::reserve_memory(extra_size, NULL, alignment);
2910     if (extra_base == NULL) {
2911       return NULL;
2912     }
2913     // Do manual alignment
2914     aligned_base = (char*) align_size_up((uintptr_t) extra_base, alignment);
2915 
2916     os::release_memory(extra_base, extra_size);
2917 
2918     aligned_base = os::reserve_memory(size, aligned_base);
2919 
2920   } while (aligned_base == NULL);
2921 
2922   return aligned_base;
2923 }
2924 
2925 char* os::pd_reserve_memory(size_t bytes, char* addr, size_t alignment_hint) {
2926   assert((size_t)addr % os::vm_allocation_granularity() == 0,
2927          "reserve alignment");
2928   assert(bytes % os::vm_allocation_granularity() == 0, "reserve block size");
2929   char* res;
2930   // note that if UseLargePages is on, all the areas that require interleaving
2931   // will go thru reserve_memory_special rather than thru here.
2932   bool use_individual = (UseNUMAInterleaving && !UseLargePages);
2933   if (!use_individual) {
2934     res = (char*)VirtualAlloc(addr, bytes, MEM_RESERVE, PAGE_READWRITE);
2935   } else {
2936     elapsedTimer reserveTimer;
2937     if( Verbose && PrintMiscellaneous ) reserveTimer.start();
2938     // in numa interleaving, we have to allocate pages individually
2939     // (well really chunks of NUMAInterleaveGranularity size)
2940     res = allocate_pages_individually(bytes, addr, MEM_RESERVE, PAGE_READWRITE);
2941     if (res == NULL) {
2942       warning("NUMA page allocation failed");
2943     }
2944     if( Verbose && PrintMiscellaneous ) {


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