< prev index next >

src/os/windows/vm/os_windows.cpp

Print this page




3084   cleanup_after_large_page_init();
3085   UseLargePages = success;
3086 }
3087 
3088 // On win32, one cannot release just a part of reserved memory, it's an
3089 // all or nothing deal.  When we split a reservation, we must break the
3090 // reservation into two reservations.
3091 void os::pd_split_reserved_memory(char *base, size_t size, size_t split,
3092                                   bool realloc) {
3093   if (size > 0) {
3094     release_memory(base, size);
3095     if (realloc) {
3096       reserve_memory(split, base);
3097     }
3098     if (size != split) {
3099       reserve_memory(size - split, base + split);
3100     }
3101   }
3102 }
3103 





3104 // Multiple threads can race in this code but it's not possible to unmap small sections of
3105 // virtual space to get requested alignment, like posix-like os's.
3106 // Windows prevents multiple thread from remapping over each other so this loop is thread-safe.
3107 char* os::reserve_memory_aligned(size_t size, size_t alignment) {
3108   assert((alignment & (os::vm_allocation_granularity() - 1)) == 0,
3109          "Alignment must be a multiple of allocation granularity (page size)");
3110   assert((size & (alignment -1)) == 0, "size must be 'alignment' aligned");
3111 
3112   size_t extra_size = size + alignment;
3113   assert(extra_size >= size, "overflow, size is too large to allow alignment");
3114 
3115   char* aligned_base = NULL;
3116 
3117   do {
3118     char* extra_base = os::reserve_memory(extra_size, NULL, alignment);
3119     if (extra_base == NULL) {
3120       return NULL;
3121     }
3122     // Do manual alignment
3123     aligned_base = (char*) align_size_up((uintptr_t) extra_base, alignment);




3084   cleanup_after_large_page_init();
3085   UseLargePages = success;
3086 }
3087 
3088 // On win32, one cannot release just a part of reserved memory, it's an
3089 // all or nothing deal.  When we split a reservation, we must break the
3090 // reservation into two reservations.
3091 void os::pd_split_reserved_memory(char *base, size_t size, size_t split,
3092                                   bool realloc) {
3093   if (size > 0) {
3094     release_memory(base, size);
3095     if (realloc) {
3096       reserve_memory(split, base);
3097     }
3098     if (size != split) {
3099       reserve_memory(size - split, base + split);
3100     }
3101   }
3102 }
3103 
3104 char* os::reserve_memory_with_backing_file(size_t bytes, char* addr, size_t alignment_hint, const char* backingFile) {
3105   VMError::report_and_die("Allocating object heap with backing file is not supported for Windows");
3106         return NULL;
3107 }
3108 
3109 // Multiple threads can race in this code but it's not possible to unmap small sections of
3110 // virtual space to get requested alignment, like posix-like os's.
3111 // Windows prevents multiple thread from remapping over each other so this loop is thread-safe.
3112 char* os::reserve_memory_aligned(size_t size, size_t alignment) {
3113   assert((alignment & (os::vm_allocation_granularity() - 1)) == 0,
3114          "Alignment must be a multiple of allocation granularity (page size)");
3115   assert((size & (alignment -1)) == 0, "size must be 'alignment' aligned");
3116 
3117   size_t extra_size = size + alignment;
3118   assert(extra_size >= size, "overflow, size is too large to allow alignment");
3119 
3120   char* aligned_base = NULL;
3121 
3122   do {
3123     char* extra_base = os::reserve_memory(extra_size, NULL, alignment);
3124     if (extra_base == NULL) {
3125       return NULL;
3126     }
3127     // Do manual alignment
3128     aligned_base = (char*) align_size_up((uintptr_t) extra_base, alignment);


< prev index next >