RFR: 8345655: Move reservation code out of ReservedSpace

Stefan Karlsson stefank at openjdk.org
Fri Dec 13 13:13:36 UTC 2024


On Fri, 13 Dec 2024 12:45:28 GMT, Johan Sjölen <jsjolen at openjdk.org> wrote:

>> 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?

My reasoning was that MemoryReserver does not have the ownership of the ReservedSpace instance, so I didn't want it to be the one clearing the members. If others feel the same way as you do, then I would prefer to add a function release_and_clear to make it clearer (:)) what's going on.

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

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


More information about the shenandoah-dev mailing list