@@ -1006,8 +1006,8 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
1006
1006
in_new_region = r->is_empty ();
1007
1007
1008
1008
if (in_new_region) {
1009
- log_debug (gc)(" Using new region (" SIZE_FORMAT " ) for %s (" PTR_FORMAT " )." ,
1010
- r->index (), ShenandoahAllocRequest::alloc_type_to_string (req.type ()), p2i (&req));
1009
+ log_debug (gc, free )(" Using new region (" SIZE_FORMAT " ) for %s (" PTR_FORMAT " )." ,
1010
+ r->index (), ShenandoahAllocRequest::alloc_type_to_string (req.type ()), p2i (&req));
1011
1011
assert (!r->is_affiliated (), " New region " SIZE_FORMAT " should be unaffiliated" , r->index ());
1012
1012
r->set_affiliation (req.affiliation ());
1013
1013
if (r->is_old ()) {
@@ -1027,8 +1027,8 @@ HeapWord* ShenandoahFreeSet::try_allocate_in(ShenandoahHeapRegion* r, Shenandoah
1027
1027
assert (ctx->top_at_mark_start (r) == r->bottom (), " Newly established allocation region starts with TAMS equal to bottom" );
1028
1028
assert (ctx->is_bitmap_range_within_region_clear (ctx->top_bitmap (r), r->end ()), " Bitmap above top_bitmap() must be clear" );
1029
1029
#endif
1030
- log_debug (gc)(" Using new region (" SIZE_FORMAT " ) for %s (" PTR_FORMAT " )." ,
1031
- r->index (), ShenandoahAllocRequest::alloc_type_to_string (req.type ()), p2i (&req));
1030
+ log_debug (gc, free )(" Using new region (" SIZE_FORMAT " ) for %s (" PTR_FORMAT " )." ,
1031
+ r->index (), ShenandoahAllocRequest::alloc_type_to_string (req.type ()), p2i (&req));
1032
1032
} else {
1033
1033
assert (r->is_affiliated (), " Region " SIZE_FORMAT " that is not new should be affiliated" , r->index ());
1034
1034
if (r->affiliation () != req.affiliation ()) {
@@ -1460,23 +1460,23 @@ void ShenandoahFreeSet::find_regions_with_alloc_capacity(size_t &young_cset_regi
1460
1460
}
1461
1461
}
1462
1462
}
1463
- log_debug (gc)(" At end of prep_to_rebuild, mutator_leftmost: " SIZE_FORMAT
1464
- " , mutator_rightmost: " SIZE_FORMAT
1465
- " , mutator_leftmost_empty: " SIZE_FORMAT
1466
- " , mutator_rightmost_empty: " SIZE_FORMAT
1467
- " , mutator_regions: " SIZE_FORMAT
1468
- " , mutator_used: " SIZE_FORMAT,
1469
- mutator_leftmost, mutator_rightmost, mutator_leftmost_empty, mutator_rightmost_empty,
1470
- mutator_regions, mutator_used);
1471
-
1472
- log_debug (gc)(" old_collector_leftmost: " SIZE_FORMAT
1473
- " , old_collector_rightmost: " SIZE_FORMAT
1474
- " , old_collector_leftmost_empty: " SIZE_FORMAT
1475
- " , old_collector_rightmost_empty: " SIZE_FORMAT
1476
- " , old_collector_regions: " SIZE_FORMAT
1477
- " , old_collector_used: " SIZE_FORMAT,
1478
- old_collector_leftmost, old_collector_rightmost, old_collector_leftmost_empty, old_collector_rightmost_empty,
1479
- old_collector_regions, old_collector_used);
1463
+ log_debug (gc, free )(" At end of prep_to_rebuild, mutator_leftmost: " SIZE_FORMAT
1464
+ " , mutator_rightmost: " SIZE_FORMAT
1465
+ " , mutator_leftmost_empty: " SIZE_FORMAT
1466
+ " , mutator_rightmost_empty: " SIZE_FORMAT
1467
+ " , mutator_regions: " SIZE_FORMAT
1468
+ " , mutator_used: " SIZE_FORMAT,
1469
+ mutator_leftmost, mutator_rightmost, mutator_leftmost_empty, mutator_rightmost_empty,
1470
+ mutator_regions, mutator_used);
1471
+
1472
+ log_debug (gc, free )(" old_collector_leftmost: " SIZE_FORMAT
1473
+ " , old_collector_rightmost: " SIZE_FORMAT
1474
+ " , old_collector_leftmost_empty: " SIZE_FORMAT
1475
+ " , old_collector_rightmost_empty: " SIZE_FORMAT
1476
+ " , old_collector_regions: " SIZE_FORMAT
1477
+ " , old_collector_used: " SIZE_FORMAT,
1478
+ old_collector_leftmost, old_collector_rightmost, old_collector_leftmost_empty, old_collector_rightmost_empty,
1479
+ old_collector_regions, old_collector_used);
1480
1480
1481
1481
idx_t rightmost_idx = (mutator_leftmost == max_regions)? -1 : (idx_t ) mutator_rightmost;
1482
1482
idx_t rightmost_empty_idx = (mutator_leftmost_empty == max_regions)? -1 : (idx_t ) mutator_rightmost_empty;
@@ -1486,12 +1486,12 @@ void ShenandoahFreeSet::find_regions_with_alloc_capacity(size_t &young_cset_regi
1486
1486
rightmost_empty_idx = (old_collector_leftmost_empty == max_regions)? -1 : (idx_t ) old_collector_rightmost_empty;
1487
1487
_partitions.establish_old_collector_intervals (old_collector_leftmost, rightmost_idx, old_collector_leftmost_empty,
1488
1488
rightmost_empty_idx, old_collector_regions, old_collector_used);
1489
- log_debug (gc)(" After find_regions_with_alloc_capacity(), Mutator range [" SSIZE_FORMAT " , " SSIZE_FORMAT " ],"
1490
- " Old Collector range [" SSIZE_FORMAT " , " SSIZE_FORMAT " ]" ,
1491
- _partitions.leftmost (ShenandoahFreeSetPartitionId::Mutator),
1492
- _partitions.rightmost (ShenandoahFreeSetPartitionId::Mutator),
1493
- _partitions.leftmost (ShenandoahFreeSetPartitionId::OldCollector),
1494
- _partitions.rightmost (ShenandoahFreeSetPartitionId::OldCollector));
1489
+ log_debug (gc, free )(" After find_regions_with_alloc_capacity(), Mutator range [%zd, %zd ],"
1490
+ " Old Collector range [%zd, %zd ]" ,
1491
+ _partitions.leftmost (ShenandoahFreeSetPartitionId::Mutator),
1492
+ _partitions.rightmost (ShenandoahFreeSetPartitionId::Mutator),
1493
+ _partitions.leftmost (ShenandoahFreeSetPartitionId::OldCollector),
1494
+ _partitions.rightmost (ShenandoahFreeSetPartitionId::OldCollector));
1495
1495
}
1496
1496
1497
1497
// Returns number of regions transferred, adds transferred bytes to var argument bytes_transferred
@@ -1502,7 +1502,6 @@ size_t ShenandoahFreeSet::transfer_empty_regions_from_collector_set_to_mutator_s
1502
1502
const size_t region_size_bytes = ShenandoahHeapRegion::region_size_bytes ();
1503
1503
size_t transferred_regions = 0 ;
1504
1504
ShenandoahLeftRightIterator iterator (&_partitions, which_collector, true );
1505
- idx_t rightmost = _partitions.rightmost_empty (which_collector);
1506
1505
for (idx_t idx = iterator.current (); transferred_regions < max_xfer_regions && iterator.has_next (); idx = iterator.next ()) {
1507
1506
// Note: can_allocate_from() denotes that region is entirely empty
1508
1507
if (can_allocate_from (idx)) {
@@ -1748,13 +1747,13 @@ void ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old
1748
1747
// OLD regions that have available memory are already in the old_collector free set.
1749
1748
_partitions.move_from_partition_to_partition (idx, ShenandoahFreeSetPartitionId::Mutator,
1750
1749
ShenandoahFreeSetPartitionId::OldCollector, ac);
1751
- log_debug (gc)(" Shifting region " SIZE_FORMAT " from mutator_free to old_collector_free" , idx);
1752
- log_debug (gc)(" Shifted Mutator range [" SSIZE_FORMAT " , " SSIZE_FORMAT " ],"
1753
- " Old Collector range [" SSIZE_FORMAT " , " SSIZE_FORMAT " ]" ,
1754
- _partitions.leftmost (ShenandoahFreeSetPartitionId::Mutator),
1755
- _partitions.rightmost (ShenandoahFreeSetPartitionId::Mutator),
1756
- _partitions.leftmost (ShenandoahFreeSetPartitionId::OldCollector),
1757
- _partitions.rightmost (ShenandoahFreeSetPartitionId::OldCollector));
1750
+ log_trace (gc, free )(" Shifting region " SIZE_FORMAT " from mutator_free to old_collector_free" , idx);
1751
+ log_trace (gc, free )(" Shifted Mutator range [%zd, %zd ],"
1752
+ " Old Collector range [%zd, %zd ]" ,
1753
+ _partitions.leftmost (ShenandoahFreeSetPartitionId::Mutator),
1754
+ _partitions.rightmost (ShenandoahFreeSetPartitionId::Mutator),
1755
+ _partitions.leftmost (ShenandoahFreeSetPartitionId::OldCollector),
1756
+ _partitions.rightmost (ShenandoahFreeSetPartitionId::OldCollector));
1758
1757
old_region_count++;
1759
1758
continue ;
1760
1759
}
@@ -1771,13 +1770,13 @@ void ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old
1771
1770
// collection set, and they are easily evacuated because they have low density of live objects.
1772
1771
_partitions.move_from_partition_to_partition (idx, ShenandoahFreeSetPartitionId::Mutator,
1773
1772
ShenandoahFreeSetPartitionId::Collector, ac);
1774
- log_debug (gc)(" Shifting region " SIZE_FORMAT " from mutator_free to collector_free" , idx);
1775
- log_debug (gc)(" Shifted Mutator range [" SSIZE_FORMAT " , " SSIZE_FORMAT " ],"
1776
- " Collector range [ " SSIZE_FORMAT " , " SSIZE_FORMAT " ]" ,
1777
- _partitions.leftmost (ShenandoahFreeSetPartitionId::Mutator),
1778
- _partitions.rightmost (ShenandoahFreeSetPartitionId::Mutator),
1779
- _partitions.leftmost (ShenandoahFreeSetPartitionId::Collector),
1780
- _partitions.rightmost (ShenandoahFreeSetPartitionId::Collector));
1773
+ log_trace (gc, free )(" Shifting region " SIZE_FORMAT " from mutator_free to collector_free" , idx);
1774
+ log_trace (gc, free )(" Shifted Mutator range [%zd, %zd ],"
1775
+ " Collector range [%zd, %zd ]" ,
1776
+ _partitions.leftmost (ShenandoahFreeSetPartitionId::Mutator),
1777
+ _partitions.rightmost (ShenandoahFreeSetPartitionId::Mutator),
1778
+ _partitions.leftmost (ShenandoahFreeSetPartitionId::Collector),
1779
+ _partitions.rightmost (ShenandoahFreeSetPartitionId::Collector));
1781
1780
}
1782
1781
}
1783
1782
@@ -1789,8 +1788,8 @@ void ShenandoahFreeSet::reserve_regions(size_t to_reserve, size_t to_reserve_old
1789
1788
}
1790
1789
size_t reserve = _partitions.available_in (ShenandoahFreeSetPartitionId::Collector);
1791
1790
if (reserve < to_reserve) {
1792
- log_debug (gc)(" Wanted " PROPERFMT " for young reserve, but only reserved: " PROPERFMT,
1793
- PROPERFMTARGS (to_reserve), PROPERFMTARGS (reserve));
1791
+ log_info (gc, free )(" Wanted " PROPERFMT " for young reserve, but only reserved: " PROPERFMT,
1792
+ PROPERFMTARGS (to_reserve), PROPERFMTARGS (reserve));
1794
1793
}
1795
1794
}
1796
1795
}
@@ -1841,34 +1840,41 @@ void ShenandoahFreeSet::log_status() {
1841
1840
1842
1841
#ifdef ASSERT
1843
1842
// Dump of the FreeSet details is only enabled if assertions are enabled
1844
- if (LogTarget (Debug, gc, free)::is_enabled ()) {
1843
+ LogTarget (Debug, gc, free) debug_free;
1844
+ if (debug_free.is_enabled ()) {
1845
1845
#define BUFFER_SIZE 80
1846
+ LogStream ls (debug_free);
1846
1847
1847
1848
char buffer[BUFFER_SIZE];
1848
1849
for (uint i = 0 ; i < BUFFER_SIZE; i++) {
1849
1850
buffer[i] = ' \0 ' ;
1850
1851
}
1851
1852
1852
- log_debug (gc)(" FreeSet map legend:"
1853
- " M:mutator_free C:collector_free O:old_collector_free"
1854
- " H:humongous ~:retired old _:retired young" );
1855
- log_debug (gc)(" mutator free range [" SIZE_FORMAT " .." SIZE_FORMAT " ] allocating from %s, "
1856
- " collector free range [" SIZE_FORMAT " .." SIZE_FORMAT " ], "
1857
- " old collector free range [" SIZE_FORMAT " .." SIZE_FORMAT " ] allocates from %s" ,
1858
- _partitions.leftmost (ShenandoahFreeSetPartitionId::Mutator),
1859
- _partitions.rightmost (ShenandoahFreeSetPartitionId::Mutator),
1860
- _partitions.alloc_from_left_bias (ShenandoahFreeSetPartitionId::Mutator)? " left to right" : " right to left" ,
1861
- _partitions.leftmost (ShenandoahFreeSetPartitionId::Collector),
1862
- _partitions.rightmost (ShenandoahFreeSetPartitionId::Collector),
1863
- _partitions.leftmost (ShenandoahFreeSetPartitionId::OldCollector),
1864
- _partitions.rightmost (ShenandoahFreeSetPartitionId::OldCollector),
1865
- _partitions.alloc_from_left_bias (ShenandoahFreeSetPartitionId::OldCollector)? " left to right" : " right to left" );
1853
+ ls.cr ();
1854
+ ls.print_cr (" Mutator free range [%zd..%zd] allocating from %s" ,
1855
+ _partitions.leftmost (ShenandoahFreeSetPartitionId::Mutator),
1856
+ _partitions.rightmost (ShenandoahFreeSetPartitionId::Mutator),
1857
+ _partitions.alloc_from_left_bias (ShenandoahFreeSetPartitionId::Mutator)? " left to right" : " right to left" );
1858
+
1859
+ ls.print_cr (" Collector free range [%zd..%zd] allocating from %s" ,
1860
+ _partitions.leftmost (ShenandoahFreeSetPartitionId::Collector),
1861
+ _partitions.rightmost (ShenandoahFreeSetPartitionId::Collector),
1862
+ _partitions.alloc_from_left_bias (ShenandoahFreeSetPartitionId::Collector)? " left to right" : " right to left" );
1863
+
1864
+ ls.print_cr (" Old collector free range [%zd..%zd] allocates from %s" ,
1865
+ _partitions.leftmost (ShenandoahFreeSetPartitionId::OldCollector),
1866
+ _partitions.rightmost (ShenandoahFreeSetPartitionId::OldCollector),
1867
+ _partitions.alloc_from_left_bias (ShenandoahFreeSetPartitionId::OldCollector)? " left to right" : " right to left" );
1868
+ ls.cr ();
1869
+ ls.print_cr (" FreeSet map legend:" );
1870
+ ls.print_cr (" M/m:mutator, C/c:collector O/o:old_collector (Empty/Occupied)" );
1871
+ ls.print_cr (" H/h:humongous, X/x:no alloc capacity, ~/_:retired (Old/Young)" );
1866
1872
1867
1873
for (uint i = 0 ; i < _heap->num_regions (); i++) {
1868
1874
ShenandoahHeapRegion *r = _heap->get_region (i);
1869
1875
uint idx = i % 64 ;
1870
1876
if ((i != 0 ) && (idx == 0 )) {
1871
- log_debug (gc) (" %6u: %s" , i-64 , buffer);
1877
+ ls. print_cr (" %6u: %s" , i-64 , buffer);
1872
1878
}
1873
1879
if (_partitions.in_free_set (ShenandoahFreeSetPartitionId::Mutator, i)) {
1874
1880
size_t capacity = alloc_capacity (r);
@@ -1882,17 +1888,11 @@ void ShenandoahFreeSet::log_status() {
1882
1888
size_t capacity = alloc_capacity (r);
1883
1889
buffer[idx] = (capacity == ShenandoahHeapRegion::region_size_bytes ()) ? ' O' : ' o' ;
1884
1890
} else if (r->is_humongous ()) {
1885
- if (r->is_old ()) {
1886
- buffer[idx] = ' H' ;
1887
- } else {
1888
- buffer[idx] = ' h' ;
1889
- }
1891
+ buffer[idx] = (r->is_old () ? ' H' : ' h' );
1892
+ } else if (alloc_capacity (r) == 0 ) {
1893
+ buffer[idx] = (r->is_old () ? ' X' : ' x' );
1890
1894
} else {
1891
- if (r->is_old ()) {
1892
- buffer[idx] = ' ~' ;
1893
- } else {
1894
- buffer[idx] = ' _' ;
1895
- }
1895
+ buffer[idx] = (r->is_old () ? ' ~' : ' _' );
1896
1896
}
1897
1897
}
1898
1898
uint remnant = _heap->num_regions () % 64 ;
@@ -1901,7 +1901,7 @@ void ShenandoahFreeSet::log_status() {
1901
1901
} else {
1902
1902
remnant = 64 ;
1903
1903
}
1904
- log_debug (gc) (" %6u: %s" , (uint ) (_heap->num_regions () - remnant), buffer);
1904
+ ls. print_cr (" %6u: %s" , (uint ) (_heap->num_regions () - remnant), buffer);
1905
1905
}
1906
1906
#endif
1907
1907
0 commit comments