--- old/share/memory/virtualspace.cpp 2018-06-14 13:09:53.860858446 -0700 +++ new/share/memory/virtualspace.cpp 2018-06-14 13:09:53.828858445 -0700 @@ -213,7 +213,7 @@ _size = size; _alignment = alignment; // If heap is reserved with a backing file, the entire space has been committed. So set the _special flag to true - if (_fd_for_heap != -1) { + if (_fd_for_heap != -1 && AllocateOldGenAt == NULL) { _special = true; } } @@ -321,7 +321,6 @@ Universe::set_narrow_oop_use_implicit_null_checks(false); } } - _base += _noaccess_prefix; _size -= _noaccess_prefix; assert(((uintptr_t)_base % _alignment == 0), "must be exactly of required alignment"); @@ -403,7 +402,7 @@ _alignment = alignment; // If heap is reserved with a backing file, the entire space has been committed. So set the _special flag to true - if (_fd_for_heap != -1) { + if (_fd_for_heap != -1 && AllocateOldGenAt == NULL) { _special = true; } @@ -607,6 +606,24 @@ return; } + // Open AllocateOldGenAt file + if (AllocateOldGenAt != NULL) { + _fd_for_heap = os::create_file_for_heap(AllocateOldGenAt); + if (_fd_for_heap== -1) { + vm_exit_during_initialization( + err_msg("Could not create file for Heap at location %s", AllocateOldGenAt)); + } + if (UseParallelOldGC) { + // For ParallelOldGC, adaptive sizing picks _old_gen virtual space sizes as needed. + // allocate Xmx on NVDIMM as adaptive sizing may put lot of pressure on NVDIMM. + os::allocate_file(_fd_for_heap, MaxHeapSize); + os::set_nvdimm_fd(_fd_for_heap); + os::set_nvdimm_present(true); + } + } else { + _fd_for_heap = -1; + } + if (heap_allocation_directory != NULL) { _fd_for_heap = os::create_file_for_heap(heap_allocation_directory); if (_fd_for_heap == -1) { @@ -637,9 +654,14 @@ if (base() != NULL) { MemTracker::record_virtual_memory_type((address)base(), mtJavaHeap); + if (AllocateOldGenAt != NULL && _fd_for_heap != -1) { + os::set_nvdimm_present(true); + os::set_nvdimm_heapbase((address)_base); + os::set_nvdimm_fd(_fd_for_heap); + } } - if (_fd_for_heap != -1) { + if (_fd_for_heap != -1 && AllocateOldGenAt == NULL) { os::close(_fd_for_heap); } }