Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @ 14488:60fd6d24f49f
8034948: Back out JDK-6976350 since it does not fix any issue
Summary: Revert JDK-6976350 because it does not improve PLAB fragmentation. To the contrary, it tends to increase the amount of wasted space with many threads.
Reviewed-by: brutisso
author | tschatzl |
---|---|
date | Mon, 24 Feb 2014 10:45:15 +0100 |
parents | 97300b6165f8 |
children | d8041d695d19 |
comparison
equal
deleted
inserted
replaced
14487:97300b6165f8 | 14488:60fd6d24f49f |
---|---|
603 // Allocate blocks during garbage collection. Will ensure an | 603 // Allocate blocks during garbage collection. Will ensure an |
604 // allocation region, either by picking one or expanding the | 604 // allocation region, either by picking one or expanding the |
605 // heap, and then allocate a block of the given size. The block | 605 // heap, and then allocate a block of the given size. The block |
606 // may not be a humongous - it must fit into a single heap region. | 606 // may not be a humongous - it must fit into a single heap region. |
607 HeapWord* par_allocate_during_gc(GCAllocPurpose purpose, size_t word_size); | 607 HeapWord* par_allocate_during_gc(GCAllocPurpose purpose, size_t word_size); |
608 | |
609 HeapWord* allocate_during_gc_slow(GCAllocPurpose purpose, | |
610 HeapRegion* alloc_region, | |
611 bool par, | |
612 size_t word_size); | |
608 | 613 |
609 // Ensure that no further allocations can happen in "r", bearing in mind | 614 // Ensure that no further allocations can happen in "r", bearing in mind |
610 // that parallel threads might be attempting allocations. | 615 // that parallel threads might be attempting allocations. |
611 void par_allocate_remaining_space(HeapRegion* r); | 616 void par_allocate_remaining_space(HeapRegion* r); |
612 | 617 |
1769 if (_retired) | 1774 if (_retired) |
1770 return; | 1775 return; |
1771 ParGCAllocBuffer::retire(end_of_gc, retain); | 1776 ParGCAllocBuffer::retire(end_of_gc, retain); |
1772 _retired = true; | 1777 _retired = true; |
1773 } | 1778 } |
1774 | |
1775 bool is_retired() { | |
1776 return _retired; | |
1777 } | |
1778 }; | |
1779 | |
1780 class G1ParGCAllocBufferContainer { | |
1781 protected: | |
1782 static int const _priority_max = 2; | |
1783 G1ParGCAllocBuffer* _priority_buffer[_priority_max]; | |
1784 | |
1785 public: | |
1786 G1ParGCAllocBufferContainer(size_t gclab_word_size) { | |
1787 for (int pr = 0; pr < _priority_max; ++pr) { | |
1788 _priority_buffer[pr] = new G1ParGCAllocBuffer(gclab_word_size); | |
1789 } | |
1790 } | |
1791 | |
1792 ~G1ParGCAllocBufferContainer() { | |
1793 for (int pr = 0; pr < _priority_max; ++pr) { | |
1794 assert(_priority_buffer[pr]->is_retired(), "alloc buffers should all retire at this point."); | |
1795 delete _priority_buffer[pr]; | |
1796 } | |
1797 } | |
1798 | |
1799 HeapWord* allocate(size_t word_sz) { | |
1800 HeapWord* obj; | |
1801 for (int pr = 0; pr < _priority_max; ++pr) { | |
1802 obj = _priority_buffer[pr]->allocate(word_sz); | |
1803 if (obj != NULL) return obj; | |
1804 } | |
1805 return obj; | |
1806 } | |
1807 | |
1808 bool contains(void* addr) { | |
1809 for (int pr = 0; pr < _priority_max; ++pr) { | |
1810 if (_priority_buffer[pr]->contains(addr)) return true; | |
1811 } | |
1812 return false; | |
1813 } | |
1814 | |
1815 void undo_allocation(HeapWord* obj, size_t word_sz) { | |
1816 bool finish_undo; | |
1817 for (int pr = 0; pr < _priority_max; ++pr) { | |
1818 if (_priority_buffer[pr]->contains(obj)) { | |
1819 _priority_buffer[pr]->undo_allocation(obj, word_sz); | |
1820 finish_undo = true; | |
1821 } | |
1822 } | |
1823 if (!finish_undo) ShouldNotReachHere(); | |
1824 } | |
1825 | |
1826 size_t words_remaining() { | |
1827 size_t result = 0; | |
1828 for (int pr = 0; pr < _priority_max; ++pr) { | |
1829 result += _priority_buffer[pr]->words_remaining(); | |
1830 } | |
1831 return result; | |
1832 } | |
1833 | |
1834 size_t words_remaining_in_retired_buffer() { | |
1835 G1ParGCAllocBuffer* retired = _priority_buffer[0]; | |
1836 return retired->words_remaining(); | |
1837 } | |
1838 | |
1839 void flush_stats_and_retire(PLABStats* stats, bool end_of_gc, bool retain) { | |
1840 for (int pr = 0; pr < _priority_max; ++pr) { | |
1841 _priority_buffer[pr]->flush_stats_and_retire(stats, end_of_gc, retain); | |
1842 } | |
1843 } | |
1844 | |
1845 void update(bool end_of_gc, bool retain, HeapWord* buf, size_t word_sz) { | |
1846 G1ParGCAllocBuffer* retired_and_set = _priority_buffer[0]; | |
1847 retired_and_set->retire(end_of_gc, retain); | |
1848 retired_and_set->set_buf(buf); | |
1849 retired_and_set->set_word_size(word_sz); | |
1850 adjust_priority_order(); | |
1851 } | |
1852 | |
1853 private: | |
1854 void adjust_priority_order() { | |
1855 G1ParGCAllocBuffer* retired_and_set = _priority_buffer[0]; | |
1856 | |
1857 int last = _priority_max - 1; | |
1858 for (int pr = 0; pr < last; ++pr) { | |
1859 _priority_buffer[pr] = _priority_buffer[pr + 1]; | |
1860 } | |
1861 _priority_buffer[last] = retired_and_set; | |
1862 } | |
1863 }; | 1779 }; |
1864 | 1780 |
1865 class G1ParScanThreadState : public StackObj { | 1781 class G1ParScanThreadState : public StackObj { |
1866 protected: | 1782 protected: |
1867 G1CollectedHeap* _g1h; | 1783 G1CollectedHeap* _g1h; |
1868 RefToScanQueue* _refs; | 1784 RefToScanQueue* _refs; |
1869 DirtyCardQueue _dcq; | 1785 DirtyCardQueue _dcq; |
1870 G1SATBCardTableModRefBS* _ct_bs; | 1786 G1SATBCardTableModRefBS* _ct_bs; |
1871 G1RemSet* _g1_rem; | 1787 G1RemSet* _g1_rem; |
1872 | 1788 |
1873 G1ParGCAllocBufferContainer _surviving_alloc_buffer; | 1789 G1ParGCAllocBuffer _surviving_alloc_buffer; |
1874 G1ParGCAllocBufferContainer _tenured_alloc_buffer; | 1790 G1ParGCAllocBuffer _tenured_alloc_buffer; |
1875 G1ParGCAllocBufferContainer* _alloc_buffers[GCAllocPurposeCount]; | 1791 G1ParGCAllocBuffer* _alloc_buffers[GCAllocPurposeCount]; |
1876 ageTable _age_table; | 1792 ageTable _age_table; |
1877 | 1793 |
1878 G1ParScanClosure _scanner; | 1794 G1ParScanClosure _scanner; |
1879 | 1795 |
1880 size_t _alloc_buffer_waste; | 1796 size_t _alloc_buffer_waste; |
1936 } | 1852 } |
1937 | 1853 |
1938 RefToScanQueue* refs() { return _refs; } | 1854 RefToScanQueue* refs() { return _refs; } |
1939 ageTable* age_table() { return &_age_table; } | 1855 ageTable* age_table() { return &_age_table; } |
1940 | 1856 |
1941 G1ParGCAllocBufferContainer* alloc_buffer(GCAllocPurpose purpose) { | 1857 G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) { |
1942 return _alloc_buffers[purpose]; | 1858 return _alloc_buffers[purpose]; |
1943 } | 1859 } |
1944 | 1860 |
1945 size_t alloc_buffer_waste() const { return _alloc_buffer_waste; } | 1861 size_t alloc_buffer_waste() const { return _alloc_buffer_waste; } |
1946 size_t undo_waste() const { return _undo_waste; } | 1862 size_t undo_waste() const { return _undo_waste; } |
1966 | 1882 |
1967 HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) { | 1883 HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) { |
1968 HeapWord* obj = NULL; | 1884 HeapWord* obj = NULL; |
1969 size_t gclab_word_size = _g1h->desired_plab_sz(purpose); | 1885 size_t gclab_word_size = _g1h->desired_plab_sz(purpose); |
1970 if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { | 1886 if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { |
1971 G1ParGCAllocBufferContainer* alloc_buf = alloc_buffer(purpose); | 1887 G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose); |
1888 add_to_alloc_buffer_waste(alloc_buf->words_remaining()); | |
1889 alloc_buf->retire(false /* end_of_gc */, false /* retain */); | |
1972 | 1890 |
1973 HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size); | 1891 HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size); |
1974 if (buf == NULL) return NULL; // Let caller handle allocation failure. | 1892 if (buf == NULL) return NULL; // Let caller handle allocation failure. |
1975 | 1893 // Otherwise. |
1976 add_to_alloc_buffer_waste(alloc_buf->words_remaining_in_retired_buffer()); | 1894 alloc_buf->set_word_size(gclab_word_size); |
1977 alloc_buf->update(false /* end_of_gc */, false /* retain */, buf, gclab_word_size); | 1895 alloc_buf->set_buf(buf); |
1978 | 1896 |
1979 obj = alloc_buf->allocate(word_sz); | 1897 obj = alloc_buf->allocate(word_sz); |
1980 assert(obj != NULL, "buffer was definitely big enough..."); | 1898 assert(obj != NULL, "buffer was definitely big enough..."); |
1981 } else { | 1899 } else { |
1982 obj = _g1h->par_allocate_during_gc(purpose, word_sz); | 1900 obj = _g1h->par_allocate_during_gc(purpose, word_sz); |
2086 } else { | 2004 } else { |
2087 deal_with_reference((oop*)ref); | 2005 deal_with_reference((oop*)ref); |
2088 } | 2006 } |
2089 } | 2007 } |
2090 | 2008 |
2009 public: | |
2091 void trim_queue(); | 2010 void trim_queue(); |
2092 }; | 2011 }; |
2093 | 2012 |
2094 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_HPP | 2013 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_HPP |