--- old/src/os/posix/vm/os_posix.cpp 2016-08-15 19:49:08.133889400 -0700 +++ new/src/os/posix/vm/os_posix.cpp 2016-08-15 19:49:07.762390000 -0700 @@ -145,7 +145,7 @@ // Multiple threads can race in this code, and can remap over each other with MAP_FIXED, // so on posix, unmap the section at the start and at the end of the chunk that we mapped // rather than unmapping and remapping the whole chunk to get requested alignment. -char* os::reserve_memory_aligned(size_t size, size_t alignment) { +char* os::reserve_memory_aligned(size_t size, size_t alignment, int file_desc) { assert((alignment & (os::vm_allocation_granularity() - 1)) == 0, "Alignment must be a multiple of allocation granularity (page size)"); assert((size & (alignment -1)) == 0, "size must be 'alignment' aligned"); @@ -180,6 +180,11 @@ os::release_memory(extra_base + begin_offset + size, end_offset); } + if (file_desc != -1) { + if (os::map_memory_to_file(aligned_base, size, file_desc) == NULL) { + vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory")); + } + } return aligned_base; }