JDK-8345655 : Move reservation code out of ReservedSpace
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-12-06
  • Updated: 2025-08-29
  • Resolved: 2024-12-18
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 25
25 b03Fixed
Related Reports
Causes :  
Relates :  
Description
The ReservedSpace class and its friends has a dual functionality of describing a reserved memory region AND it also reserves memory. I would like to split this so that the ReservedSpace classes only acts as data carrier about reserved memory and then have a more explicit API for reserving memory and baking a ReservedSpace given the outcome of the reservation.

The dual functionality of ReservedSpace makes the code hard to read and it is hard to see / realize that the constructors reserve memory. However, this is not the only reason to try to take a step back and clean up ReservedSpace. So while doing a restructure here I think we should clean up things like::

1) Move the noaccess_prefix and related code out from ReservedSpace into ReservedHeapSpace.
2) Move _fd_for_heap out out of ReservedSpace.
3) Clearer requirements and asserts w.r.t. the input arguments size, alignment, and page_size.

Current prototype:
https://github.com/stefank/jdk/tree/refs/heads/reserved_space_rewrite
Comments
Somehow the needed header ‎src/hotspot/os/aix/os_aix.hpp was implicitly loaded to virtualspace.cpp, so I forgot to explicitly load it.
19-12-2024

> JDK-8334371: [AIX] Beginning with AIX 7.3 TL1 mmap() supports 64K memory pages [~jkern] can you please comment ?
19-12-2024

The root cause of that AIX issues seems to be that the following change added AIX code to shared code, but didn't add an include to AIX: JDK-8334371: [AIX] Beginning with AIX 7.3 TL1 mmap() supports 64K memory pages and then it wasn't apparent that an AIX include was needed when I moved the code to another file.
19-12-2024

After this change, the AIX fastdebug build fails with this error : /priv/jenkins/client-home/workspace/openjdk-jdk-dev-aix_ppc64-dbg/jdk/src/hotspot/share/memory/memoryReserver.cpp:513:26: error: incomplete type 'os::Aix' named in nested name specifier AIX_ONLY(&& (os::Aix::supports_64K_mmap_pages() || os::vm_page_size() == 4*K))) { ~~~~^~~~~ /priv/jenkins/client-home/workspace/openjdk-jdk-dev-aix_ppc64-dbg/jdk/src/hotspot/share/utilities/macros.hpp:399:24: note: expanded from macro 'AIX_ONLY' #define AIX_ONLY(code) code ^~~~ /priv/jenkins/client-home/workspace/openjdk-jdk-dev-aix_ppc64-dbg/jdk/src/hotspot/share/runtime/os.hpp:1024:9: note: forward declaration of 'os::Aix' class Aix; (for some reason the AIX opt build still works); maybe the includes in memoryReserver.cpp need adjustment ? I created JDK-8346605 .
19-12-2024

Changeset: 73b5dbae Branch: master Author: Stefan Karlsson <stefank@openjdk.org> Date: 2024-12-18 10:19:13 +0000 URL: https://git.openjdk.org/jdk/commit/73b5dbaec340b3e8c958d63f510df92ec621c04e
18-12-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/22712 Date: 2024-12-12 13:36:07 +0000
12-12-2024