@@ -162,17 +162,16 @@ void ShenandoahGeneration::log_status(const char *msg) const {
162
162
size_t v_soft_max_capacity = soft_max_capacity ();
163
163
size_t v_max_capacity = max_capacity ();
164
164
size_t v_available = available ();
165
- size_t v_adjusted_avail = adjusted_available ();
165
+ size_t v_humongous_waste = get_humongous_waste ();
166
166
LogGcInfo::print (" %s: %s generation used: " SIZE_FORMAT " %s, used regions: " SIZE_FORMAT " %s, "
167
- " soft capacity: " SIZE_FORMAT " %s, max capacity: " SIZE_FORMAT " %s, available: " SIZE_FORMAT " %s, "
168
- " adjusted available: " SIZE_FORMAT " %s" ,
169
- msg, name (),
167
+ " humongous waste: " SIZE_FORMAT " %s, soft capacity: " SIZE_FORMAT " %s, max capacity: " SIZE_FORMAT " %s, "
168
+ " available: " SIZE_FORMAT " %s" , msg, name (),
170
169
byte_size_in_proper_unit (v_used), proper_unit_for_byte_size (v_used),
171
170
byte_size_in_proper_unit (v_used_regions), proper_unit_for_byte_size (v_used_regions),
171
+ byte_size_in_proper_unit (v_humongous_waste), proper_unit_for_byte_size (v_humongous_waste),
172
172
byte_size_in_proper_unit (v_soft_max_capacity), proper_unit_for_byte_size (v_soft_max_capacity),
173
173
byte_size_in_proper_unit (v_max_capacity), proper_unit_for_byte_size (v_max_capacity),
174
- byte_size_in_proper_unit (v_available), proper_unit_for_byte_size (v_available),
175
- byte_size_in_proper_unit (v_adjusted_avail), proper_unit_for_byte_size (v_adjusted_avail));
174
+ byte_size_in_proper_unit (v_available), proper_unit_for_byte_size (v_available));
176
175
}
177
176
178
177
void ShenandoahGeneration::reset_mark_bitmap () {
@@ -893,7 +892,7 @@ ShenandoahGeneration::ShenandoahGeneration(ShenandoahGenerationType type,
893
892
_task_queues(new ShenandoahObjToScanQueueSet(max_workers)),
894
893
_ref_processor(new ShenandoahReferenceProcessor(MAX2(max_workers, 1U ))),
895
894
_collection_thread_time_s(0.0 ),
896
- _affiliated_region_count(0 ), _used(0 ), _bytes_allocated_since_gc_start(0 ),
895
+ _affiliated_region_count(0 ), _humongous_waste( 0 ), _used(0 ), _bytes_allocated_since_gc_start(0 ),
897
896
_max_capacity(max_capacity), _soft_max_capacity(soft_max_capacity),
898
897
_adjusted_capacity(soft_max_capacity), _heuristics(nullptr ) {
899
898
_is_marking_complete.set ();
@@ -957,13 +956,15 @@ size_t ShenandoahGeneration::decrement_affiliated_region_count() {
957
956
}
958
957
959
958
void ShenandoahGeneration::establish_usage (size_t num_regions, size_t num_bytes, size_t humongous_waste) {
959
+ assert (ShenandoahHeap::heap ()->mode ()->is_generational (), " Only generational mode accounts for generational usage" );
960
960
assert (ShenandoahSafepoint::is_at_shenandoah_safepoint (), " must be at a safepoint" );
961
961
_affiliated_region_count = num_regions;
962
962
_used = num_bytes;
963
- // future improvement: _humongous_waste = humongous_waste;
963
+ _humongous_waste = humongous_waste;
964
964
}
965
965
966
966
void ShenandoahGeneration::clear_used () {
967
+ assert (ShenandoahHeap::heap ()->mode ()->is_generational (), " Only generational mode accounts for generational usage" );
967
968
assert (ShenandoahSafepoint::is_at_shenandoah_safepoint (), " must be at a safepoint" );
968
969
// Do this atomically to assure visibility to other threads, even though these other threads may be idle "right now"..
969
970
Atomic::store (&_used, (size_t )0 );
@@ -978,6 +979,23 @@ void ShenandoahGeneration::decrease_used(size_t bytes) {
978
979
Atomic::sub (&_used, bytes);
979
980
}
980
981
982
+ void ShenandoahGeneration::increase_humongous_waste (size_t bytes) {
983
+ if (bytes > 0 ) {
984
+ shenandoah_assert_heaplocked_or_fullgc_safepoint ();
985
+ _humongous_waste += bytes;
986
+ }
987
+ }
988
+
989
+ void ShenandoahGeneration::decrease_humongous_waste (size_t bytes) {
990
+ if (bytes > 0 ) {
991
+ shenandoah_assert_heaplocked_or_fullgc_safepoint ();
992
+ assert (_humongous_waste >= bytes, " Waste cannot be negative" );
993
+ assert (ShenandoahHeap::heap ()->is_full_gc_in_progress () || (_humongous_waste >= bytes),
994
+ " Waste (" SIZE_FORMAT " ) cannot be negative (after subtracting " SIZE_FORMAT " )" , _humongous_waste, bytes);
995
+ _humongous_waste -= bytes;
996
+ }
997
+ }
998
+
981
999
size_t ShenandoahGeneration::used_regions () const {
982
1000
return _affiliated_region_count;
983
1001
}
@@ -997,19 +1015,14 @@ size_t ShenandoahGeneration::used_regions_size() const {
997
1015
}
998
1016
999
1017
size_t ShenandoahGeneration::available () const {
1000
- size_t in_use = used ();
1018
+ size_t in_use = used () + get_humongous_waste () ;
1001
1019
size_t soft_capacity = soft_max_capacity ();
1002
1020
return in_use > soft_capacity ? 0 : soft_capacity - in_use;
1003
1021
}
1004
1022
1005
1023
size_t ShenandoahGeneration::adjust_available (intptr_t adjustment) {
1006
- // TODO: ysr: remove this check & warning
1007
- if (adjustment % ShenandoahHeapRegion::region_size_bytes () != 0 ) {
1008
- log_warning (gc)(" Adjustment (" INTPTR_FORMAT " ) should be a multiple of region size (" SIZE_FORMAT " )" ,
1009
- adjustment, ShenandoahHeapRegion::region_size_bytes ());
1010
- }
1011
1024
assert (adjustment % ShenandoahHeapRegion::region_size_bytes () == 0 ,
1012
- " Adjustment to generation size must be multiple of region size" );
1025
+ " Adjustment to generation size must be multiple of region size" );
1013
1026
_adjusted_capacity = soft_max_capacity () + adjustment;
1014
1027
return _adjusted_capacity;
1015
1028
}
@@ -1020,7 +1033,7 @@ size_t ShenandoahGeneration::unadjust_available() {
1020
1033
}
1021
1034
1022
1035
size_t ShenandoahGeneration::adjusted_available () const {
1023
- size_t in_use = used ();
1036
+ size_t in_use = used () + get_humongous_waste () ;
1024
1037
size_t capacity = _adjusted_capacity;
1025
1038
return in_use > capacity ? 0 : capacity - in_use;
1026
1039
}
0 commit comments