RFR (M) 8075210: Refactor strong root processing in order to allow G1 to evolve separately from GenCollectedHeap

Mikael Gerdin mikael.gerdin at oracle.com
Mon Mar 16 13:37:22 UTC 2015

Hi all!

Currently SharedHeap::process_strong_roots is called both by the 
GenCollectedHeap based collectors (CMS, Serial) and G1.

Since G1 needs special cases for several pieces of the root processing 
SharedHeap needs to allow for that while attempting to maintain some 
layer of abstraction. This makes the SharedHeap code unnecessarily 
complex and makes it very difficult to reason about which combination of 
parameters are valid and possible.

As a first step to improve the code I suggest that we copy the root 
processing code to a separate class for G1 and move the SharedHeap root 
processing to GenCollectedHeap. For now I think it's worth it to 
introduce slightly more duplication of the root processing code in order 
to reduce the complexity of the shared code path.

Overall the change is consists of
  15 files changed, 597 insertions(+), 551 deletions(-)
Where the insertions include two new copies of the GPL license header.

An additional goal for this change is to make it easier to get rid of 
SharedHeap altogether at some future point, there's really no point in 
having a shared abstract base class between G1 and GenCollectedHeap.

If we want to we can also modify G1RootProcessor at some future point to 
allow it to be used for all root processing, including ParallelGC and 
JVMTI. For example the generic root processor could be implemented as 
some kind of class template, where function objects are passed as 
template parameters to control claiming of tasks and which roots to visit.

In order to make it easier to review I've split up the change into 3 phases:
1. Copy SharedHeap::process_roots and G1CollectedHeap::g1_process_roots 
to G1RootProcessor::process_roots and convert G1's evacuation code to 
use G1RootProcessor.
2. Convert the rest of G1 (verification and G1MarkSweep) to use 
G1RootProcessor. Split G1RootProcessor::process_roots in order to allow 
for the different needs of different callers.
3. Move SharedHeap::process_roots to GenCollectedHeap since it's now the 
only caller of the code. Get rid of the ScanOption operator| since we 
never or them any longer.



Full webrev:



More information about the hotspot-gc-dev mailing list