diff a/src/hotspot/share/memory/virtualspace.cpp b/src/hotspot/share/memory/virtualspace.cpp --- a/src/hotspot/share/memory/virtualspace.cpp +++ b/src/hotspot/share/memory/virtualspace.cpp @@ -111,10 +111,31 @@ } } return true; } +// Helper method. +static bool should_use_reserve_memory_special(bool large, + int fd_for_heap, + const char* fallback_log_message) +{ + // If OS doesn't support demand paging for large page memory, we need + // to use reserve_memory_special() to reserve and pin the entire region. + // If there is a backing file directory for this space then whether + // large pages are allocated is up to the filesystem of the backing file. + // So we ignore the UseLargePages flag in this case. + bool special = large && !os::can_commit_large_page_memory(); + if (special && fd_for_heap != -1) { + special = false; + if (UseLargePages && (!FLAG_IS_DEFAULT(UseLargePages) || + !FLAG_IS_DEFAULT(LargePageSizeInBytes))) { + log_debug(gc, heap)("%s", fallback_log_message); + } + } + return special; +} + void ReservedSpace::initialize(size_t size, size_t alignment, bool large, char* requested_address, bool executable) { const size_t granularity = os::vm_allocation_granularity(); assert((size & (granularity - 1)) == 0, @@ -134,23 +155,14 @@ _noaccess_prefix = 0; if (size == 0) { return; } - // If OS doesn't support demand paging for large page memory, we need - // to use reserve_memory_special() to reserve and pin the entire region. - // If there is a backing file directory for this space then whether - // large pages are allocated is up to the filesystem of the backing file. - // So we ignore the UseLargePages flag in this case. - bool special = large && !os::can_commit_large_page_memory(); - if (special && _fd_for_heap != -1) { - special = false; - if (UseLargePages && (!FLAG_IS_DEFAULT(UseLargePages) || - !FLAG_IS_DEFAULT(LargePageSizeInBytes))) { - log_debug(gc, heap)("Ignoring UseLargePages since large page support is up to the file system of the backing file for Java heap"); - } - } + bool special = should_use_reserve_memory_special(large, _fd_for_heap, + "Ignoring UseLargePages since large page " + "support is up to the file system of the " + "backing file for Java heap"); char* base = NULL; if (special) { @@ -327,23 +339,13 @@ if (_base != NULL) { // We tried before, but we didn't like the address delivered. release(); } - // If OS doesn't support demand paging for large page memory, we need - // to use reserve_memory_special() to reserve and pin the entire region. - // If there is a backing file directory for this space then whether - // large pages are allocated is up to the filesystem of the backing file. - // So we ignore the UseLargePages flag in this case. - bool special = large && !os::can_commit_large_page_memory(); - if (special && _fd_for_heap != -1) { - special = false; - if (UseLargePages && (!FLAG_IS_DEFAULT(UseLargePages) || - !FLAG_IS_DEFAULT(LargePageSizeInBytes))) { - log_debug(gc, heap)("Cannot allocate large pages for Java Heap when AllocateHeapAt option is set."); - } - } + bool special = should_use_reserve_memory_special(large, _fd_for_heap, + "Cannot allocate large pages for Java Heap " + "when AllocateHeapAt option is set."); char* base = NULL; log_trace(gc, heap, coops)("Trying to allocate at address " PTR_FORMAT " heap of size " SIZE_FORMAT_HEX, p2i(requested_address),