RFR: 8310160: Make GC APIs for handling archive heap objects agnostic of GC policy [v2]

Ashutosh Mehra duke at openjdk.org
Wed Jun 21 15:26:07 UTC 2023


On Mon, 19 Jun 2023 20:06:23 GMT, Ashutosh Mehra <duke at openjdk.org> wrote:

>> This PR adds GC APIs to be implemented by all collectors for proper handling of archive heap space. Currently only G1 is updated to use these APIs which just involves renaming the existing G1 APIs.
>> In addition to that filemap.cpp is updated to replace calls to `G1CollectedHeap::heap()` with `Universe::heap()` to avoid G1 specific code as much as possible.
>> 
>> At many places in filemap.cpp heap range is requested from GC. All collectors except ZGC have contiguous heap and set `CollectedHeap::_reserved` to the heap range, so it can be easily exposed to the CDS code. This is done in this patch through `CollectedHeap::reserved` API. But for ZGC the heap can be discontiguous which makes it tricky to expose the heap range.
>> Another point to note is that most of the usage for heap range is for logging purpose, but there is one place where it is used for setting the `mapping_offset` in `FileMapInfo::write_region()` based on the heap start. So purely based on the functional requirement, we only need the heap start address, not the range.
>> 
>> To keep things simple and considering ZGC does not currently support archive heap, i refrained from tackling the issue of discontiguous heap range in this PR.
>
> Ashutosh Mehra has updated the pull request incrementally with three additional commits since the last revision:
> 
>  - Remove unnecessary assert and condition for UseG1GC
>    
>    Signed-off-by: Ashutosh Mehra <asmehra at redhat.com>
>  - Rename CollectedHeap::reserved() to CollectedHeap::reserved_range()
>    
>    Signed-off-by: Ashutosh Mehra <asmehra at redhat.com>
>  - Rename alloc_archive_space to allocate_archive_space
>    
>    Signed-off-by: Ashutosh Mehra <asmehra at redhat.com>

My whole idea behind this is to have common GC APIs that the CDS can use to manage archive heap. As long as collector internals are properly abstracted out and hidden behind the APIs, CDS wouldn't need to worry about what the individual collectors do internally.
I agree the ideal scenario would be to use object allocation APIs but considering the issues @iklam pointed out, it doesn't look like a viable approach. @fisk do you agree with this assessment? Do you have any other alternative approach in mind?

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

PR Comment: https://git.openjdk.org/jdk/pull/14520#issuecomment-1601049487


More information about the hotspot-gc-dev mailing list