G1 maintains a numbering of all young regions in the collection set in order to record the amount of bytes copied from each young region in a convenient fashion.
This done by having a _young_index_in_cset member in each HeapRegion which is -1 for non-young and >= 0 for young regions.
The responsibility for setting this value should be moved to G1CollectionSet, where it's easier to verify that the indices are set in the correct manner for survivor and eden regions instead of relying on YoungList and its state changes to ensure that the indices are correct.
This done by having a _young_index_in_cset member in each HeapRegion which is -1 for non-young and >= 0 for young regions.
The responsibility for setting this value should be moved to G1CollectionSet, where it's easier to verify that the indices are set in the correct manner for survivor and eden regions instead of relying on YoungList and its state changes to ensure that the indices are correct.