Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/concurrentMark.cpp @ 6011:f7a8920427a6
7145441: G1: collection set chooser-related cleanup
Summary: Cleanup of the CSet chooser class: standardize on uints for region num and indexes (instead of int, jint, etc.), make the method / field naming style more consistent, remove a lot of dead code.
Reviewed-by: johnc, brutisso
author | tonyp |
---|---|
date | Wed, 18 Apr 2012 13:39:55 -0400 |
parents | 720b6a76dd9d |
children | 8a2e5a6a19a4 |
comparison
equal
deleted
inserted
replaced
6010:720b6a76dd9d | 6011:f7a8920427a6 |
---|---|
1190 CMBitMapRO* _bm; | 1190 CMBitMapRO* _bm; |
1191 ConcurrentMark* _cm; | 1191 ConcurrentMark* _cm; |
1192 BitMap* _region_bm; | 1192 BitMap* _region_bm; |
1193 BitMap* _card_bm; | 1193 BitMap* _card_bm; |
1194 | 1194 |
1195 // Debugging | |
1196 size_t _tot_words_done; | |
1197 size_t _tot_live; | |
1198 size_t _tot_used; | |
1199 | |
1200 size_t _region_marked_bytes; | 1195 size_t _region_marked_bytes; |
1201 | 1196 |
1202 intptr_t _bottom_card_num; | 1197 intptr_t _bottom_card_num; |
1203 | 1198 |
1204 void mark_card_num_range(intptr_t start_card_num, intptr_t last_card_num) { | 1199 void mark_card_num_range(intptr_t start_card_num, intptr_t last_card_num) { |
1213 | 1208 |
1214 public: | 1209 public: |
1215 CalcLiveObjectsClosure(CMBitMapRO *bm, ConcurrentMark *cm, | 1210 CalcLiveObjectsClosure(CMBitMapRO *bm, ConcurrentMark *cm, |
1216 BitMap* region_bm, BitMap* card_bm) : | 1211 BitMap* region_bm, BitMap* card_bm) : |
1217 _bm(bm), _cm(cm), _region_bm(region_bm), _card_bm(card_bm), | 1212 _bm(bm), _cm(cm), _region_bm(region_bm), _card_bm(card_bm), |
1218 _region_marked_bytes(0), _tot_words_done(0), | 1213 _region_marked_bytes(0), _bottom_card_num(cm->heap_bottom_card_num()) { } |
1219 _tot_live(0), _tot_used(0), | |
1220 _bottom_card_num(cm->heap_bottom_card_num()) { } | |
1221 | 1214 |
1222 // It takes a region that's not empty (i.e., it has at least one | 1215 // It takes a region that's not empty (i.e., it has at least one |
1223 // live object in it and sets its corresponding bit on the region | 1216 // live object in it and sets its corresponding bit on the region |
1224 // bitmap to 1. If the region is "starts humongous" it will also set | 1217 // bitmap to 1. If the region is "starts humongous" it will also set |
1225 // to 1 the bits on the region bitmap that correspond to its | 1218 // to 1 the bits on the region bitmap that correspond to its |
1259 | 1252 |
1260 assert(start <= hr->end() && start <= nextTop && nextTop <= hr->end(), | 1253 assert(start <= hr->end() && start <= nextTop && nextTop <= hr->end(), |
1261 err_msg("Preconditions not met - " | 1254 err_msg("Preconditions not met - " |
1262 "start: "PTR_FORMAT", nextTop: "PTR_FORMAT", end: "PTR_FORMAT, | 1255 "start: "PTR_FORMAT", nextTop: "PTR_FORMAT", end: "PTR_FORMAT, |
1263 start, nextTop, hr->end())); | 1256 start, nextTop, hr->end())); |
1264 | |
1265 // Record the number of word's we'll examine. | |
1266 size_t words_done = (nextTop - start); | |
1267 | 1257 |
1268 // Find the first marked object at or after "start". | 1258 // Find the first marked object at or after "start". |
1269 start = _bm->getNextMarkedWordAddress(start, nextTop); | 1259 start = _bm->getNextMarkedWordAddress(start, nextTop); |
1270 | 1260 |
1271 size_t marked_bytes = 0; | 1261 size_t marked_bytes = 0; |
1341 | 1331 |
1342 // Set the marked bytes for the current region so that | 1332 // Set the marked bytes for the current region so that |
1343 // it can be queried by a calling verificiation routine | 1333 // it can be queried by a calling verificiation routine |
1344 _region_marked_bytes = marked_bytes; | 1334 _region_marked_bytes = marked_bytes; |
1345 | 1335 |
1346 _tot_live += hr->next_live_bytes(); | |
1347 _tot_used += hr->used(); | |
1348 _tot_words_done = words_done; | |
1349 | |
1350 return false; | 1336 return false; |
1351 } | 1337 } |
1352 | 1338 |
1353 size_t region_marked_bytes() const { return _region_marked_bytes; } | 1339 size_t region_marked_bytes() const { return _region_marked_bytes; } |
1354 | |
1355 // Debugging | |
1356 size_t tot_words_done() const { return _tot_words_done; } | |
1357 size_t tot_live() const { return _tot_live; } | |
1358 size_t tot_used() const { return _tot_used; } | |
1359 }; | 1340 }; |
1360 | 1341 |
1361 // Heap region closure used for verifying the counting data | 1342 // Heap region closure used for verifying the counting data |
1362 // that was accumulated concurrently and aggregated during | 1343 // that was accumulated concurrently and aggregated during |
1363 // the remark pause. This closure is applied to the heap | 1344 // the remark pause. This closure is applied to the heap |
1572 class FinalCountDataUpdateClosure: public HeapRegionClosure { | 1553 class FinalCountDataUpdateClosure: public HeapRegionClosure { |
1573 ConcurrentMark* _cm; | 1554 ConcurrentMark* _cm; |
1574 BitMap* _region_bm; | 1555 BitMap* _region_bm; |
1575 BitMap* _card_bm; | 1556 BitMap* _card_bm; |
1576 | 1557 |
1577 size_t _total_live_bytes; | |
1578 size_t _total_used_bytes; | |
1579 size_t _total_words_done; | |
1580 | |
1581 void set_card_bitmap_range(BitMap::idx_t start_idx, BitMap::idx_t last_idx) { | 1558 void set_card_bitmap_range(BitMap::idx_t start_idx, BitMap::idx_t last_idx) { |
1582 assert(start_idx <= last_idx, "sanity"); | 1559 assert(start_idx <= last_idx, "sanity"); |
1583 | 1560 |
1584 // Set the inclusive bit range [start_idx, last_idx]. | 1561 // Set the inclusive bit range [start_idx, last_idx]. |
1585 // For small ranges (up to 8 cards) use a simple loop; otherwise | 1562 // For small ranges (up to 8 cards) use a simple loop; otherwise |
1619 | 1596 |
1620 public: | 1597 public: |
1621 FinalCountDataUpdateClosure(ConcurrentMark* cm, | 1598 FinalCountDataUpdateClosure(ConcurrentMark* cm, |
1622 BitMap* region_bm, | 1599 BitMap* region_bm, |
1623 BitMap* card_bm) : | 1600 BitMap* card_bm) : |
1624 _cm(cm), _region_bm(region_bm), _card_bm(card_bm), | 1601 _cm(cm), _region_bm(region_bm), _card_bm(card_bm) { } |
1625 _total_words_done(0), _total_live_bytes(0), _total_used_bytes(0) { } | |
1626 | 1602 |
1627 bool doHeapRegion(HeapRegion* hr) { | 1603 bool doHeapRegion(HeapRegion* hr) { |
1628 | 1604 |
1629 if (hr->continuesHumongous()) { | 1605 if (hr->continuesHumongous()) { |
1630 // We will ignore these here and process them when their | 1606 // We will ignore these here and process them when their |
1642 HeapWord* top = hr->top(); | 1618 HeapWord* top = hr->top(); |
1643 | 1619 |
1644 assert(hr->bottom() <= start && start <= hr->end() && | 1620 assert(hr->bottom() <= start && start <= hr->end() && |
1645 hr->bottom() <= ntams && ntams <= hr->end(), "Preconditions."); | 1621 hr->bottom() <= ntams && ntams <= hr->end(), "Preconditions."); |
1646 | 1622 |
1647 size_t words_done = ntams - hr->bottom(); | |
1648 | |
1649 if (start < ntams) { | 1623 if (start < ntams) { |
1650 // Region was changed between remark and cleanup pauses | 1624 // Region was changed between remark and cleanup pauses |
1651 // We need to add (ntams - start) to the marked bytes | 1625 // We need to add (ntams - start) to the marked bytes |
1652 // for this region, and set bits for the range | 1626 // for this region, and set bits for the range |
1653 // [ card_idx(start), card_idx(ntams) ) in the card bitmap. | 1627 // [ card_idx(start), card_idx(ntams) ) in the card bitmap. |
1674 // Set the bit for the region if it contains live data | 1648 // Set the bit for the region if it contains live data |
1675 if (hr->next_marked_bytes() > 0) { | 1649 if (hr->next_marked_bytes() > 0) { |
1676 set_bit_for_region(hr); | 1650 set_bit_for_region(hr); |
1677 } | 1651 } |
1678 | 1652 |
1679 _total_words_done += words_done; | |
1680 _total_used_bytes += hr->used(); | |
1681 _total_live_bytes += hr->next_marked_bytes(); | |
1682 | |
1683 return false; | 1653 return false; |
1684 } | 1654 } |
1685 | |
1686 size_t total_words_done() const { return _total_words_done; } | |
1687 size_t total_live_bytes() const { return _total_live_bytes; } | |
1688 size_t total_used_bytes() const { return _total_used_bytes; } | |
1689 }; | 1655 }; |
1690 | 1656 |
1691 class G1ParFinalCountTask: public AbstractGangTask { | 1657 class G1ParFinalCountTask: public AbstractGangTask { |
1692 protected: | 1658 protected: |
1693 G1CollectedHeap* _g1h; | 1659 G1CollectedHeap* _g1h; |
1694 ConcurrentMark* _cm; | 1660 ConcurrentMark* _cm; |
1695 BitMap* _actual_region_bm; | 1661 BitMap* _actual_region_bm; |
1696 BitMap* _actual_card_bm; | 1662 BitMap* _actual_card_bm; |
1697 | 1663 |
1698 uint _n_workers; | 1664 uint _n_workers; |
1699 | |
1700 size_t *_live_bytes; | |
1701 size_t *_used_bytes; | |
1702 | 1665 |
1703 public: | 1666 public: |
1704 G1ParFinalCountTask(G1CollectedHeap* g1h, BitMap* region_bm, BitMap* card_bm) | 1667 G1ParFinalCountTask(G1CollectedHeap* g1h, BitMap* region_bm, BitMap* card_bm) |
1705 : AbstractGangTask("G1 final counting"), | 1668 : AbstractGangTask("G1 final counting"), |
1706 _g1h(g1h), _cm(_g1h->concurrent_mark()), | 1669 _g1h(g1h), _cm(_g1h->concurrent_mark()), |
1707 _actual_region_bm(region_bm), _actual_card_bm(card_bm), | 1670 _actual_region_bm(region_bm), _actual_card_bm(card_bm), |
1708 _n_workers(0) { | 1671 _n_workers(0) { |
1709 // Use the value already set as the number of active threads | 1672 // Use the value already set as the number of active threads |
1710 // in the call to run_task(). Needed for the allocation of | 1673 // in the call to run_task(). |
1711 // _live_bytes and _used_bytes. | |
1712 if (G1CollectedHeap::use_parallel_gc_threads()) { | 1674 if (G1CollectedHeap::use_parallel_gc_threads()) { |
1713 assert( _g1h->workers()->active_workers() > 0, | 1675 assert( _g1h->workers()->active_workers() > 0, |
1714 "Should have been previously set"); | 1676 "Should have been previously set"); |
1715 _n_workers = _g1h->workers()->active_workers(); | 1677 _n_workers = _g1h->workers()->active_workers(); |
1716 } else { | 1678 } else { |
1717 _n_workers = 1; | 1679 _n_workers = 1; |
1718 } | 1680 } |
1719 | |
1720 _live_bytes = NEW_C_HEAP_ARRAY(size_t, (size_t) _n_workers); | |
1721 _used_bytes = NEW_C_HEAP_ARRAY(size_t, (size_t) _n_workers); | |
1722 } | |
1723 | |
1724 ~G1ParFinalCountTask() { | |
1725 FREE_C_HEAP_ARRAY(size_t, _live_bytes); | |
1726 FREE_C_HEAP_ARRAY(size_t, _used_bytes); | |
1727 } | 1681 } |
1728 | 1682 |
1729 void work(uint worker_id) { | 1683 void work(uint worker_id) { |
1730 assert(worker_id < _n_workers, "invariant"); | 1684 assert(worker_id < _n_workers, "invariant"); |
1731 | 1685 |
1739 _n_workers, | 1693 _n_workers, |
1740 HeapRegion::FinalCountClaimValue); | 1694 HeapRegion::FinalCountClaimValue); |
1741 } else { | 1695 } else { |
1742 _g1h->heap_region_iterate(&final_update_cl); | 1696 _g1h->heap_region_iterate(&final_update_cl); |
1743 } | 1697 } |
1744 | |
1745 _live_bytes[worker_id] = final_update_cl.total_live_bytes(); | |
1746 _used_bytes[worker_id] = final_update_cl.total_used_bytes(); | |
1747 } | |
1748 | |
1749 size_t live_bytes() { | |
1750 size_t live_bytes = 0; | |
1751 for (uint i = 0; i < _n_workers; ++i) | |
1752 live_bytes += _live_bytes[i]; | |
1753 return live_bytes; | |
1754 } | |
1755 | |
1756 size_t used_bytes() { | |
1757 size_t used_bytes = 0; | |
1758 for (uint i = 0; i < _n_workers; ++i) | |
1759 used_bytes += _used_bytes[i]; | |
1760 return used_bytes; | |
1761 } | 1698 } |
1762 }; | 1699 }; |
1763 | 1700 |
1764 class G1ParNoteEndTask; | 1701 class G1ParNoteEndTask; |
1765 | 1702 |
1890 _cleanup_list->add_as_tail(&local_cleanup_list); | 1827 _cleanup_list->add_as_tail(&local_cleanup_list); |
1891 assert(local_cleanup_list.is_empty(), "post-condition"); | 1828 assert(local_cleanup_list.is_empty(), "post-condition"); |
1892 | 1829 |
1893 HeapRegionRemSet::finish_cleanup_task(&hrrs_cleanup_task); | 1830 HeapRegionRemSet::finish_cleanup_task(&hrrs_cleanup_task); |
1894 } | 1831 } |
1895 double end = os::elapsedTime(); | |
1896 if (G1PrintParCleanupStats) { | |
1897 gclog_or_tty->print(" Worker thread %d [%8.3f..%8.3f = %8.3f ms] " | |
1898 "claimed %u regions (tot = %8.3f ms, max = %8.3f ms).\n", | |
1899 worker_id, start, end, (end-start)*1000.0, | |
1900 g1_note_end.regions_claimed(), | |
1901 g1_note_end.claimed_region_time_sec()*1000.0, | |
1902 g1_note_end.max_region_time_sec()*1000.0); | |
1903 } | |
1904 } | 1832 } |
1905 size_t max_live_bytes() { return _max_live_bytes; } | 1833 size_t max_live_bytes() { return _max_live_bytes; } |
1906 size_t freed_bytes() { return _freed_bytes; } | 1834 size_t freed_bytes() { return _freed_bytes; } |
1907 }; | 1835 }; |
1908 | 1836 |
2009 } | 1937 } |
2010 | 1938 |
2011 guarantee(g1_par_verify_task.failures() == 0, "Unexpected accounting failures"); | 1939 guarantee(g1_par_verify_task.failures() == 0, "Unexpected accounting failures"); |
2012 } | 1940 } |
2013 | 1941 |
2014 size_t known_garbage_bytes = | |
2015 g1_par_count_task.used_bytes() - g1_par_count_task.live_bytes(); | |
2016 g1p->set_known_garbage_bytes(known_garbage_bytes); | |
2017 | |
2018 size_t start_used_bytes = g1h->used(); | 1942 size_t start_used_bytes = g1h->used(); |
2019 g1h->set_marking_complete(); | 1943 g1h->set_marking_complete(); |
2020 | 1944 |
2021 ergo_verbose4(ErgoConcCycles, | |
2022 "finish cleanup", | |
2023 ergo_format_byte("occupancy") | |
2024 ergo_format_byte("capacity") | |
2025 ergo_format_byte_perc("known garbage"), | |
2026 start_used_bytes, g1h->capacity(), | |
2027 known_garbage_bytes, | |
2028 ((double) known_garbage_bytes / (double) g1h->capacity()) * 100.0); | |
2029 | |
2030 double count_end = os::elapsedTime(); | 1945 double count_end = os::elapsedTime(); |
2031 double this_final_counting_time = (count_end - start); | 1946 double this_final_counting_time = (count_end - start); |
2032 if (G1PrintParCleanupStats) { | |
2033 gclog_or_tty->print_cr("Cleanup:"); | |
2034 gclog_or_tty->print_cr(" Finalize counting: %8.3f ms", | |
2035 this_final_counting_time*1000.0); | |
2036 } | |
2037 _total_counting_time += this_final_counting_time; | 1947 _total_counting_time += this_final_counting_time; |
2038 | 1948 |
2039 if (G1PrintRegionLivenessInfo) { | 1949 if (G1PrintRegionLivenessInfo) { |
2040 G1PrintRegionLivenessInfoClosure cl(gclog_or_tty, "Post-Marking"); | 1950 G1PrintRegionLivenessInfoClosure cl(gclog_or_tty, "Post-Marking"); |
2041 _g1h->heap_region_iterate(&cl); | 1951 _g1h->heap_region_iterate(&cl); |
2045 swapMarkBitMaps(); | 1955 swapMarkBitMaps(); |
2046 | 1956 |
2047 g1h->reset_gc_time_stamp(); | 1957 g1h->reset_gc_time_stamp(); |
2048 | 1958 |
2049 // Note end of marking in all heap regions. | 1959 // Note end of marking in all heap regions. |
2050 double note_end_start = os::elapsedTime(); | |
2051 G1ParNoteEndTask g1_par_note_end_task(g1h, &_cleanup_list); | 1960 G1ParNoteEndTask g1_par_note_end_task(g1h, &_cleanup_list); |
2052 if (G1CollectedHeap::use_parallel_gc_threads()) { | 1961 if (G1CollectedHeap::use_parallel_gc_threads()) { |
2053 g1h->set_par_threads((int)n_workers); | 1962 g1h->set_par_threads((int)n_workers); |
2054 g1h->workers()->run_task(&g1_par_note_end_task); | 1963 g1h->workers()->run_task(&g1_par_note_end_task); |
2055 g1h->set_par_threads(0); | 1964 g1h->set_par_threads(0); |
2063 if (!cleanup_list_is_empty()) { | 1972 if (!cleanup_list_is_empty()) { |
2064 // The cleanup list is not empty, so we'll have to process it | 1973 // The cleanup list is not empty, so we'll have to process it |
2065 // concurrently. Notify anyone else that might be wanting free | 1974 // concurrently. Notify anyone else that might be wanting free |
2066 // regions that there will be more free regions coming soon. | 1975 // regions that there will be more free regions coming soon. |
2067 g1h->set_free_regions_coming(); | 1976 g1h->set_free_regions_coming(); |
2068 } | |
2069 double note_end_end = os::elapsedTime(); | |
2070 if (G1PrintParCleanupStats) { | |
2071 gclog_or_tty->print_cr(" note end of marking: %8.3f ms.", | |
2072 (note_end_end - note_end_start)*1000.0); | |
2073 } | 1977 } |
2074 | 1978 |
2075 // call below, since it affects the metric by which we sort the heap | 1979 // call below, since it affects the metric by which we sort the heap |
2076 // regions. | 1980 // regions. |
2077 if (G1ScrubRemSets) { | 1981 if (G1ScrubRemSets) { |
2106 g1h->print_size_transition(gclog_or_tty, | 2010 g1h->print_size_transition(gclog_or_tty, |
2107 start_used_bytes, | 2011 start_used_bytes, |
2108 g1h->used(), | 2012 g1h->used(), |
2109 g1h->capacity()); | 2013 g1h->capacity()); |
2110 } | 2014 } |
2111 | |
2112 size_t cleaned_up_bytes = start_used_bytes - g1h->used(); | |
2113 g1p->decrease_known_garbage_bytes(cleaned_up_bytes); | |
2114 | 2015 |
2115 // Clean up will have freed any regions completely full of garbage. | 2016 // Clean up will have freed any regions completely full of garbage. |
2116 // Update the soft reference policy with the new heap occupancy. | 2017 // Update the soft reference policy with the new heap occupancy. |
2117 Universe::update_heap_info_at_gc(); | 2018 Universe::update_heap_info_at_gc(); |
2118 | 2019 |