Mercurial > hg > graal-jvmci-8
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 10242:b0d20fa374b4
8013872: G1: HeapRegionSeq::shrink_by() has invalid assert
Summary: Refactored shrink_by() to only use region counts and not byte sizes
Reviewed-by: johnc, tschatzl
author | brutisso |
---|---|
date | Mon, 06 May 2013 21:30:34 +0200 |
parents | d58c62b7447d |
children | 194f52aa2f23 |
comparison
equal
deleted
inserted
replaced
10241:d17700c82d7d | 10242:b0d20fa374b4 |
---|---|
1841 size_t old_mem_size = _g1_storage.committed_size(); | 1841 size_t old_mem_size = _g1_storage.committed_size(); |
1842 size_t aligned_shrink_bytes = | 1842 size_t aligned_shrink_bytes = |
1843 ReservedSpace::page_align_size_down(shrink_bytes); | 1843 ReservedSpace::page_align_size_down(shrink_bytes); |
1844 aligned_shrink_bytes = align_size_down(aligned_shrink_bytes, | 1844 aligned_shrink_bytes = align_size_down(aligned_shrink_bytes, |
1845 HeapRegion::GrainBytes); | 1845 HeapRegion::GrainBytes); |
1846 uint num_regions_deleted = 0; | 1846 uint num_regions_to_remove = (uint)(shrink_bytes / HeapRegion::GrainBytes); |
1847 MemRegion mr = _hrs.shrink_by(aligned_shrink_bytes, &num_regions_deleted); | 1847 |
1848 uint num_regions_removed = _hrs.shrink_by(num_regions_to_remove); | |
1848 HeapWord* old_end = (HeapWord*) _g1_storage.high(); | 1849 HeapWord* old_end = (HeapWord*) _g1_storage.high(); |
1849 assert(mr.end() == old_end, "post-condition"); | 1850 size_t shrunk_bytes = num_regions_removed * HeapRegion::GrainBytes; |
1850 | 1851 |
1851 ergo_verbose3(ErgoHeapSizing, | 1852 ergo_verbose3(ErgoHeapSizing, |
1852 "shrink the heap", | 1853 "shrink the heap", |
1853 ergo_format_byte("requested shrinking amount") | 1854 ergo_format_byte("requested shrinking amount") |
1854 ergo_format_byte("aligned shrinking amount") | 1855 ergo_format_byte("aligned shrinking amount") |
1855 ergo_format_byte("attempted shrinking amount"), | 1856 ergo_format_byte("attempted shrinking amount"), |
1856 shrink_bytes, aligned_shrink_bytes, mr.byte_size()); | 1857 shrink_bytes, aligned_shrink_bytes, shrunk_bytes); |
1857 if (mr.byte_size() > 0) { | 1858 if (num_regions_removed > 0) { |
1859 _g1_storage.shrink_by(shrunk_bytes); | |
1860 HeapWord* new_end = (HeapWord*) _g1_storage.high(); | |
1861 | |
1858 if (_hr_printer.is_active()) { | 1862 if (_hr_printer.is_active()) { |
1859 HeapWord* curr = mr.end(); | 1863 HeapWord* curr = old_end; |
1860 while (curr > mr.start()) { | 1864 while (curr > new_end) { |
1861 HeapWord* curr_end = curr; | 1865 HeapWord* curr_end = curr; |
1862 curr -= HeapRegion::GrainWords; | 1866 curr -= HeapRegion::GrainWords; |
1863 _hr_printer.uncommit(curr, curr_end); | 1867 _hr_printer.uncommit(curr, curr_end); |
1864 } | 1868 } |
1865 assert(curr == mr.start(), "post-condition"); | 1869 } |
1866 } | 1870 |
1867 | 1871 _expansion_regions += num_regions_removed; |
1868 _g1_storage.shrink_by(mr.byte_size()); | |
1869 HeapWord* new_end = (HeapWord*) _g1_storage.high(); | |
1870 assert(mr.start() == new_end, "post-condition"); | |
1871 | |
1872 _expansion_regions += num_regions_deleted; | |
1873 update_committed_space(old_end, new_end); | 1872 update_committed_space(old_end, new_end); |
1874 HeapRegionRemSet::shrink_heap(n_regions()); | 1873 HeapRegionRemSet::shrink_heap(n_regions()); |
1875 g1_policy()->record_new_heap_size(n_regions()); | 1874 g1_policy()->record_new_heap_size(n_regions()); |
1876 } else { | 1875 } else { |
1877 ergo_verbose0(ErgoHeapSizing, | 1876 ergo_verbose0(ErgoHeapSizing, |