Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @ 17690:e5c0b296deb2
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 | Wed, 26 Feb 2014 15:32:51 +0100 |
parents | 5d492d192cbf |
children | cfd4aac53239 |
comparison
equal
deleted
inserted
replaced
17689:5d492d192cbf | 17690:e5c0b296deb2 |
---|---|
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 |
1781 if (_retired) | 1786 if (_retired) |
1782 return; | 1787 return; |
1783 ParGCAllocBuffer::retire(end_of_gc, retain); | 1788 ParGCAllocBuffer::retire(end_of_gc, retain); |
1784 _retired = true; | 1789 _retired = true; |
1785 } | 1790 } |
1786 | |
1787 bool is_retired() { | |
1788 return _retired; | |
1789 } | |
1790 }; | |
1791 | |
1792 class G1ParGCAllocBufferContainer { | |
1793 protected: | |
1794 static int const _priority_max = 2; | |
1795 G1ParGCAllocBuffer* _priority_buffer[_priority_max]; | |
1796 | |
1797 public: | |
1798 G1ParGCAllocBufferContainer(size_t gclab_word_size) { | |
1799 for (int pr = 0; pr < _priority_max; ++pr) { | |
1800 _priority_buffer[pr] = new G1ParGCAllocBuffer(gclab_word_size); | |
1801 } | |
1802 } | |
1803 | |
1804 ~G1ParGCAllocBufferContainer() { | |
1805 for (int pr = 0; pr < _priority_max; ++pr) { | |
1806 assert(_priority_buffer[pr]->is_retired(), "alloc buffers should all retire at this point."); | |
1807 delete _priority_buffer[pr]; | |
1808 } | |
1809 } | |
1810 | |
1811 HeapWord* allocate(size_t word_sz) { | |
1812 HeapWord* obj; | |
1813 for (int pr = 0; pr < _priority_max; ++pr) { | |
1814 obj = _priority_buffer[pr]->allocate(word_sz); | |
1815 if (obj != NULL) return obj; | |
1816 } | |
1817 return obj; | |
1818 } | |
1819 | |
1820 bool contains(void* addr) { | |
1821 for (int pr = 0; pr < _priority_max; ++pr) { | |
1822 if (_priority_buffer[pr]->contains(addr)) return true; | |
1823 } | |
1824 return false; | |
1825 } | |
1826 | |
1827 void undo_allocation(HeapWord* obj, size_t word_sz) { | |
1828 bool finish_undo; | |
1829 for (int pr = 0; pr < _priority_max; ++pr) { | |
1830 if (_priority_buffer[pr]->contains(obj)) { | |
1831 _priority_buffer[pr]->undo_allocation(obj, word_sz); | |
1832 finish_undo = true; | |
1833 } | |
1834 } | |
1835 if (!finish_undo) ShouldNotReachHere(); | |
1836 } | |
1837 | |
1838 size_t words_remaining() { | |
1839 size_t result = 0; | |
1840 for (int pr = 0; pr < _priority_max; ++pr) { | |
1841 result += _priority_buffer[pr]->words_remaining(); | |
1842 } | |
1843 return result; | |
1844 } | |
1845 | |
1846 size_t words_remaining_in_retired_buffer() { | |
1847 G1ParGCAllocBuffer* retired = _priority_buffer[0]; | |
1848 return retired->words_remaining(); | |
1849 } | |
1850 | |
1851 void flush_stats_and_retire(PLABStats* stats, bool end_of_gc, bool retain) { | |
1852 for (int pr = 0; pr < _priority_max; ++pr) { | |
1853 _priority_buffer[pr]->flush_stats_and_retire(stats, end_of_gc, retain); | |
1854 } | |
1855 } | |
1856 | |
1857 void update(bool end_of_gc, bool retain, HeapWord* buf, size_t word_sz) { | |
1858 G1ParGCAllocBuffer* retired_and_set = _priority_buffer[0]; | |
1859 retired_and_set->retire(end_of_gc, retain); | |
1860 retired_and_set->set_buf(buf); | |
1861 retired_and_set->set_word_size(word_sz); | |
1862 adjust_priority_order(); | |
1863 } | |
1864 | |
1865 private: | |
1866 void adjust_priority_order() { | |
1867 G1ParGCAllocBuffer* retired_and_set = _priority_buffer[0]; | |
1868 | |
1869 int last = _priority_max - 1; | |
1870 for (int pr = 0; pr < last; ++pr) { | |
1871 _priority_buffer[pr] = _priority_buffer[pr + 1]; | |
1872 } | |
1873 _priority_buffer[last] = retired_and_set; | |
1874 } | |
1875 }; | 1791 }; |
1876 | 1792 |
1877 class G1ParScanThreadState : public StackObj { | 1793 class G1ParScanThreadState : public StackObj { |
1878 protected: | 1794 protected: |
1879 G1CollectedHeap* _g1h; | 1795 G1CollectedHeap* _g1h; |
1880 RefToScanQueue* _refs; | 1796 RefToScanQueue* _refs; |
1881 DirtyCardQueue _dcq; | 1797 DirtyCardQueue _dcq; |
1882 G1SATBCardTableModRefBS* _ct_bs; | 1798 G1SATBCardTableModRefBS* _ct_bs; |
1883 G1RemSet* _g1_rem; | 1799 G1RemSet* _g1_rem; |
1884 | 1800 |
1885 G1ParGCAllocBufferContainer _surviving_alloc_buffer; | 1801 G1ParGCAllocBuffer _surviving_alloc_buffer; |
1886 G1ParGCAllocBufferContainer _tenured_alloc_buffer; | 1802 G1ParGCAllocBuffer _tenured_alloc_buffer; |
1887 G1ParGCAllocBufferContainer* _alloc_buffers[GCAllocPurposeCount]; | 1803 G1ParGCAllocBuffer* _alloc_buffers[GCAllocPurposeCount]; |
1888 ageTable _age_table; | 1804 ageTable _age_table; |
1889 | 1805 |
1890 G1ParScanClosure _scanner; | 1806 G1ParScanClosure _scanner; |
1891 | 1807 |
1892 size_t _alloc_buffer_waste; | 1808 size_t _alloc_buffer_waste; |
1948 } | 1864 } |
1949 | 1865 |
1950 RefToScanQueue* refs() { return _refs; } | 1866 RefToScanQueue* refs() { return _refs; } |
1951 ageTable* age_table() { return &_age_table; } | 1867 ageTable* age_table() { return &_age_table; } |
1952 | 1868 |
1953 G1ParGCAllocBufferContainer* alloc_buffer(GCAllocPurpose purpose) { | 1869 G1ParGCAllocBuffer* alloc_buffer(GCAllocPurpose purpose) { |
1954 return _alloc_buffers[purpose]; | 1870 return _alloc_buffers[purpose]; |
1955 } | 1871 } |
1956 | 1872 |
1957 size_t alloc_buffer_waste() const { return _alloc_buffer_waste; } | 1873 size_t alloc_buffer_waste() const { return _alloc_buffer_waste; } |
1958 size_t undo_waste() const { return _undo_waste; } | 1874 size_t undo_waste() const { return _undo_waste; } |
1978 | 1894 |
1979 HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) { | 1895 HeapWord* allocate_slow(GCAllocPurpose purpose, size_t word_sz) { |
1980 HeapWord* obj = NULL; | 1896 HeapWord* obj = NULL; |
1981 size_t gclab_word_size = _g1h->desired_plab_sz(purpose); | 1897 size_t gclab_word_size = _g1h->desired_plab_sz(purpose); |
1982 if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { | 1898 if (word_sz * 100 < gclab_word_size * ParallelGCBufferWastePct) { |
1983 G1ParGCAllocBufferContainer* alloc_buf = alloc_buffer(purpose); | 1899 G1ParGCAllocBuffer* alloc_buf = alloc_buffer(purpose); |
1900 add_to_alloc_buffer_waste(alloc_buf->words_remaining()); | |
1901 alloc_buf->retire(false /* end_of_gc */, false /* retain */); | |
1984 | 1902 |
1985 HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size); | 1903 HeapWord* buf = _g1h->par_allocate_during_gc(purpose, gclab_word_size); |
1986 if (buf == NULL) return NULL; // Let caller handle allocation failure. | 1904 if (buf == NULL) return NULL; // Let caller handle allocation failure. |
1987 | 1905 // Otherwise. |
1988 add_to_alloc_buffer_waste(alloc_buf->words_remaining_in_retired_buffer()); | 1906 alloc_buf->set_word_size(gclab_word_size); |
1989 alloc_buf->update(false /* end_of_gc */, false /* retain */, buf, gclab_word_size); | 1907 alloc_buf->set_buf(buf); |
1990 | 1908 |
1991 obj = alloc_buf->allocate(word_sz); | 1909 obj = alloc_buf->allocate(word_sz); |
1992 assert(obj != NULL, "buffer was definitely big enough..."); | 1910 assert(obj != NULL, "buffer was definitely big enough..."); |
1993 } else { | 1911 } else { |
1994 obj = _g1h->par_allocate_during_gc(purpose, word_sz); | 1912 obj = _g1h->par_allocate_during_gc(purpose, word_sz); |
2098 } else { | 2016 } else { |
2099 deal_with_reference((oop*)ref); | 2017 deal_with_reference((oop*)ref); |
2100 } | 2018 } |
2101 } | 2019 } |
2102 | 2020 |
2021 public: | |
2103 void trim_queue(); | 2022 void trim_queue(); |
2104 }; | 2023 }; |
2105 | 2024 |
2106 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_HPP | 2025 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_HPP |