I tried to use the HeapRegionRemSetIterator class directly during testing and I was getting inconsistent results from it. In particular, the card indexes it'd return would be out-of-bounds. The reason for this is that there is an inconsistency between the remembered sets and the sparse rem set iterator with respect to what each thinks the "base" of the indexes, used to represent cards in the rem sets, is. The rem sets assume that index 0 corresponds to address 0, whereas the sparse rem set iterator assumes that index 0 corresponds to the bottom fo the heap. The way we haven't come across this before is that we initialize the iterators that we use in the G1CollectedHeap constructor and at that point not all the heap data structures are initialized. So, it looks as if the iterator constructors pick up a value of 0 for the bottom of the heap (accidentally!) and do the right thing.
|