comparison src/share/vm/gc_implementation/g1/concurrentMark.cpp @ 17736:58fc1b1523dc

8034079: G1: Refactor the HeapRegionSet hierarchy Reviewed-by: tschatzl, pliden
author brutisso
date Fri, 14 Mar 2014 10:15:46 +0100
parents cb7ec2423207
children f53edbc2b728
comparison
equal deleted inserted replaced
17735:8f28240318a2 17736:58fc1b1523dc
1807 int _worker_num; 1807 int _worker_num;
1808 size_t _max_live_bytes; 1808 size_t _max_live_bytes;
1809 uint _regions_claimed; 1809 uint _regions_claimed;
1810 size_t _freed_bytes; 1810 size_t _freed_bytes;
1811 FreeRegionList* _local_cleanup_list; 1811 FreeRegionList* _local_cleanup_list;
1812 OldRegionSet* _old_proxy_set; 1812 HeapRegionSetCount _old_regions_removed;
1813 HumongousRegionSet* _humongous_proxy_set; 1813 HeapRegionSetCount _humongous_regions_removed;
1814 HRRSCleanupTask* _hrrs_cleanup_task; 1814 HRRSCleanupTask* _hrrs_cleanup_task;
1815 double _claimed_region_time; 1815 double _claimed_region_time;
1816 double _max_region_time; 1816 double _max_region_time;
1817 1817
1818 public: 1818 public:
1819 G1NoteEndOfConcMarkClosure(G1CollectedHeap* g1, 1819 G1NoteEndOfConcMarkClosure(G1CollectedHeap* g1,
1820 int worker_num, 1820 int worker_num,
1821 FreeRegionList* local_cleanup_list, 1821 FreeRegionList* local_cleanup_list,
1822 OldRegionSet* old_proxy_set,
1823 HumongousRegionSet* humongous_proxy_set,
1824 HRRSCleanupTask* hrrs_cleanup_task) : 1822 HRRSCleanupTask* hrrs_cleanup_task) :
1825 _g1(g1), _worker_num(worker_num), 1823 _g1(g1), _worker_num(worker_num),
1826 _max_live_bytes(0), _regions_claimed(0), 1824 _max_live_bytes(0), _regions_claimed(0),
1827 _freed_bytes(0), 1825 _freed_bytes(0),
1828 _claimed_region_time(0.0), _max_region_time(0.0), 1826 _claimed_region_time(0.0), _max_region_time(0.0),
1829 _local_cleanup_list(local_cleanup_list), 1827 _local_cleanup_list(local_cleanup_list),
1830 _old_proxy_set(old_proxy_set), 1828 _old_regions_removed(),
1831 _humongous_proxy_set(humongous_proxy_set), 1829 _humongous_regions_removed(),
1832 _hrrs_cleanup_task(hrrs_cleanup_task) { } 1830 _hrrs_cleanup_task(hrrs_cleanup_task) { }
1833 1831
1834 size_t freed_bytes() { return _freed_bytes; } 1832 size_t freed_bytes() { return _freed_bytes; }
1833 const HeapRegionSetCount& old_regions_removed() { return _old_regions_removed; }
1834 const HeapRegionSetCount& humongous_regions_removed() { return _humongous_regions_removed; }
1835 1835
1836 bool doHeapRegion(HeapRegion *hr) { 1836 bool doHeapRegion(HeapRegion *hr) {
1837 if (hr->continuesHumongous()) { 1837 if (hr->continuesHumongous()) {
1838 return false; 1838 return false;
1839 } 1839 }
1842 _g1->reset_gc_time_stamps(hr); 1842 _g1->reset_gc_time_stamps(hr);
1843 double start = os::elapsedTime(); 1843 double start = os::elapsedTime();
1844 _regions_claimed++; 1844 _regions_claimed++;
1845 hr->note_end_of_marking(); 1845 hr->note_end_of_marking();
1846 _max_live_bytes += hr->max_live_bytes(); 1846 _max_live_bytes += hr->max_live_bytes();
1847 _g1->free_region_if_empty(hr, 1847
1848 &_freed_bytes, 1848 if (hr->used() > 0 && hr->max_live_bytes() == 0 && !hr->is_young()) {
1849 _local_cleanup_list, 1849 _freed_bytes += hr->used();
1850 _old_proxy_set, 1850 hr->set_containing_set(NULL);
1851 _humongous_proxy_set, 1851 if (hr->isHumongous()) {
1852 _hrrs_cleanup_task, 1852 assert(hr->startsHumongous(), "we should only see starts humongous");
1853 true /* par */); 1853 _humongous_regions_removed.increment(1u, hr->capacity());
1854 _g1->free_humongous_region(hr, _local_cleanup_list, true);
1855 } else {
1856 _old_regions_removed.increment(1u, hr->capacity());
1857 _g1->free_region(hr, _local_cleanup_list, true);
1858 }
1859 } else {
1860 hr->rem_set()->do_cleanup_work(_hrrs_cleanup_task);
1861 }
1862
1854 double region_time = (os::elapsedTime() - start); 1863 double region_time = (os::elapsedTime() - start);
1855 _claimed_region_time += region_time; 1864 _claimed_region_time += region_time;
1856 if (region_time > _max_region_time) { 1865 if (region_time > _max_region_time) {
1857 _max_region_time = region_time; 1866 _max_region_time = region_time;
1858 } 1867 }
1881 _max_live_bytes(0), _freed_bytes(0), _cleanup_list(cleanup_list) { } 1890 _max_live_bytes(0), _freed_bytes(0), _cleanup_list(cleanup_list) { }
1882 1891
1883 void work(uint worker_id) { 1892 void work(uint worker_id) {
1884 double start = os::elapsedTime(); 1893 double start = os::elapsedTime();
1885 FreeRegionList local_cleanup_list("Local Cleanup List"); 1894 FreeRegionList local_cleanup_list("Local Cleanup List");
1886 OldRegionSet old_proxy_set("Local Cleanup Old Proxy Set");
1887 HumongousRegionSet humongous_proxy_set("Local Cleanup Humongous Proxy Set");
1888 HRRSCleanupTask hrrs_cleanup_task; 1895 HRRSCleanupTask hrrs_cleanup_task;
1889 G1NoteEndOfConcMarkClosure g1_note_end(_g1h, worker_id, &local_cleanup_list, 1896 G1NoteEndOfConcMarkClosure g1_note_end(_g1h, worker_id, &local_cleanup_list,
1890 &old_proxy_set,
1891 &humongous_proxy_set,
1892 &hrrs_cleanup_task); 1897 &hrrs_cleanup_task);
1893 if (G1CollectedHeap::use_parallel_gc_threads()) { 1898 if (G1CollectedHeap::use_parallel_gc_threads()) {
1894 _g1h->heap_region_par_iterate_chunked(&g1_note_end, worker_id, 1899 _g1h->heap_region_par_iterate_chunked(&g1_note_end, worker_id,
1895 _g1h->workers()->active_workers(), 1900 _g1h->workers()->active_workers(),
1896 HeapRegion::NoteEndClaimValue); 1901 HeapRegion::NoteEndClaimValue);
1898 _g1h->heap_region_iterate(&g1_note_end); 1903 _g1h->heap_region_iterate(&g1_note_end);
1899 } 1904 }
1900 assert(g1_note_end.complete(), "Shouldn't have yielded!"); 1905 assert(g1_note_end.complete(), "Shouldn't have yielded!");
1901 1906
1902 // Now update the lists 1907 // Now update the lists
1903 _g1h->update_sets_after_freeing_regions(g1_note_end.freed_bytes(), 1908 _g1h->remove_from_old_sets(g1_note_end.old_regions_removed(), g1_note_end.humongous_regions_removed());
1904 NULL /* free_list */,
1905 &old_proxy_set,
1906 &humongous_proxy_set,
1907 true /* par */);
1908 { 1909 {
1909 MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag); 1910 MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
1911 _g1h->decrement_summary_bytes(g1_note_end.freed_bytes());
1910 _max_live_bytes += g1_note_end.max_live_bytes(); 1912 _max_live_bytes += g1_note_end.max_live_bytes();
1911 _freed_bytes += g1_note_end.freed_bytes(); 1913 _freed_bytes += g1_note_end.freed_bytes();
1912 1914
1913 // If we iterate over the global cleanup list at the end of 1915 // If we iterate over the global cleanup list at the end of
1914 // cleanup to do this printing we will not guarantee to only 1916 // cleanup to do this printing we will not guarantee to only
1918 // printing here, before we append the new regions to the global 1920 // printing here, before we append the new regions to the global
1919 // cleanup list. 1921 // cleanup list.
1920 1922
1921 G1HRPrinter* hr_printer = _g1h->hr_printer(); 1923 G1HRPrinter* hr_printer = _g1h->hr_printer();
1922 if (hr_printer->is_active()) { 1924 if (hr_printer->is_active()) {
1923 HeapRegionLinkedListIterator iter(&local_cleanup_list); 1925 FreeRegionListIterator iter(&local_cleanup_list);
1924 while (iter.more_available()) { 1926 while (iter.more_available()) {
1925 HeapRegion* hr = iter.get_next(); 1927 HeapRegion* hr = iter.get_next();
1926 hr_printer->cleanup(hr); 1928 hr_printer->cleanup(hr);
1927 } 1929 }
1928 } 1930 }
1969 if (has_aborted()) { 1971 if (has_aborted()) {
1970 g1h->set_marking_complete(); // So bitmap clearing isn't confused 1972 g1h->set_marking_complete(); // So bitmap clearing isn't confused
1971 return; 1973 return;
1972 } 1974 }
1973 1975
1974 HRSPhaseSetter x(HRSPhaseCleanup);
1975 g1h->verify_region_sets_optional(); 1976 g1h->verify_region_sets_optional();
1976 1977
1977 if (VerifyDuringGC) { 1978 if (VerifyDuringGC) {
1978 HandleMark hm; // handle scope 1979 HandleMark hm; // handle scope
1979 Universe::heap()->prepare_for_verify(); 1980 Universe::heap()->prepare_for_verify();
2142 void ConcurrentMark::completeCleanup() { 2143 void ConcurrentMark::completeCleanup() {
2143 if (has_aborted()) return; 2144 if (has_aborted()) return;
2144 2145
2145 G1CollectedHeap* g1h = G1CollectedHeap::heap(); 2146 G1CollectedHeap* g1h = G1CollectedHeap::heap();
2146 2147
2147 _cleanup_list.verify_optional(); 2148 _cleanup_list.verify_list();
2148 FreeRegionList tmp_free_list("Tmp Free List"); 2149 FreeRegionList tmp_free_list("Tmp Free List");
2149 2150
2150 if (G1ConcRegionFreeingVerbose) { 2151 if (G1ConcRegionFreeingVerbose) {
2151 gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : " 2152 gclog_or_tty->print_cr("G1ConcRegionFreeing [complete cleanup] : "
2152 "cleanup list has %u entries", 2153 "cleanup list has %u entries",