RFR: 8345655: Move reservation code out of ReservedSpace

Johan Sjölen jsjolen at openjdk.org
Fri Dec 13 12:50:37 UTC 2024


On Thu, 12 Dec 2024 13:36:07 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

> 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.
> 
> See the first comment for the full description:

src/hotspot/share/memory/memoryReserver.cpp line 238:

> 236: }
> 237: 
> 238: bool MemoryReserver::release(const ReservedSpace& reserved) {

Should `release(release(R)) == release(R)` and should `release(R& r)` do `r = {}`? Then `release({})` is no-op.

In other words, instead of this:

```c++
if (rs.is_reserved()) {
  MemoryReserver::release(rs);
  rs = {};
}


we can have

```c++
MemoryReserver::release(rs);


which to me seems like a good simplification when using the API.

src/hotspot/share/memory/reservedSpace.hpp line 137:

> 135: };
> 136: 
> 137: // Class encapsulating behavior specific of memory space reserved for Java heap.

"of the", "for the"

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/22712#discussion_r1883745379
PR Review Comment: https://git.openjdk.org/jdk/pull/22712#discussion_r1883865400


More information about the shenandoah-dev mailing list