RFR: 8345655: Move reservation code out of ReservedSpace

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


On Fri, 13 Dec 2024 10:51:16 GMT, Johan Sjölen <jsjolen 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.

It seems like you've explicitly decided against this in the new API, is there a particular reason for that?

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

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


More information about the shenandoah-dev mailing list