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. Future refactorings to unify the root processing at a different level of abstraction can hopefully be done using the new G1 root processor class.