This CR covers a collection of small fixes, some code cleanup / removal, some minor refactoring, and some small formatting fixes. This is prelude to replacing the closure-based heap region iterations with an iterator-based scheme. These fixes include (in no particular order): * Changed some of the iterations (in particular, all parallel iterations) to skip continues humongous regions. This will ultimately make the parallel iterator easier to write. In some cases, I had to put logic in the body of the iteration to handle humongous regions specially (e.g., when resetting GC time stamps). * Introduced G1CollectedHeap::reset_gc_time_stamps(HeapRegion* hr) which resets the GC time stamp of the given region, as well as any associated continues humongous regions if hr is starts humongous. * Introduced and call (non-product) check_gc_time_stamps() method that ensures the GC time stamps of all regions have been correctly reset. (If this sounds a bit paranoid: the GC time stamps getting out of sync can result in really subtle and hard-to-reproduce/detect bugs.) * Factored out two heap region iterations into separate methods: clear_rsets_post_compaction() (the iteration with PostMCRemSetClearClosure) and print_hrs_post_compaction() (the iteration with PostCompactionPrinterClosure). * Introduced G1CollectedHeap::start_region_for_worker() which calculates which region each parallel worker should start from during parallel iterations. * In G1MarkSweep, we currently use a closure to find the first region in the heap. This is a bit unnecessary. I replaced it with getting region 0 directly. * Re-implemeneted the HeapRegion::next_compaction_space() not to use an iterator. Iterators actually wrap around which is not appropriate here. * Remove G1CollectedHeap::heap_region_iterate_from() as it's not used any more. * I removed the FILTERINTOCSCLOSURE_DOHISTOGRAMCOUNT and FILTEROUTOFREGIONCLOSURE_DOHISTOGRAMCOUNT switches, along with any associated fields and variables, as they are not used any more. * verify_dirty_young_regions() does not call dirty_dirty_young_list() on first_survivor_region() any more as it's unnecessary: the list starting from first_region() actually includes the survivors. * Removed the G1RSCountHisto develop parameter and associate closures. * Updated the HS_FORMAT macros to also show whether a region is humongous (HS / HC), old (O), or free (F) instead of only showing whether it's eden or survivor (the abbreviations are the same as what we use for our per-region output). * Introduced two convenience methods on HeapRegion: - region_num() returns the number of distinct regions that are covered by the region (1 if non-humongous, >= 1 if humongous); I also updated the HeapRegionSet classes to use this method instead of essentially replicating the functionality - last_hc_index() returns the index+1 of the last continues humongous region associated with the target starts humongous region * Split up a very long single line "Heap Regions: (Y=young(eden), SU=young(survivor), ..." into multiple ones. And some additional refactoring to make the iterator loops shorter: * We have a lot of switch statements on the VerifyOption embedded in the code. I abstracted them away in dedicated methods on G1CollectedHeap. * Introduced the CSetChooserParUpdater class which is used to add regions to the CollectionSetChooser array, either in parallel or (for completeness) serially. Currently, the code for the latter is embedded in the ParKnownGarbageHRClosure class and it's good to abstract it away.
|