3030#include " runtime/thread.hpp"
3131#include " runtime/threadSMR.inline.hpp"
3232
33+ ShenandoahEvacuationStats::ShenandoahEvacuations* ShenandoahEvacuationStats::get_category (
34+ ShenandoahAffiliation from,
35+ ShenandoahAffiliation to) {
36+ if (from == YOUNG_GENERATION) {
37+ if (to == YOUNG_GENERATION) {
38+ return &_young;
39+ }
40+ assert (to == OLD_GENERATION, " If not evacuating to young, must be promotion to old" );
41+ return &_promotion;
42+ }
43+ assert (from == OLD_GENERATION, " If not evacuating from young, then must be from old" );
44+ return &_old;
45+ }
46+
3347ShenandoahEvacuationStats::ShenandoahEvacuationStats ()
34- : _evacuations_completed(0 ), _bytes_completed(0 ),
35- _evacuations_attempted(0 ), _bytes_attempted(0 ),
36- _use_age_table(ShenandoahGenerationalCensusAtEvac || !ShenandoahGenerationalAdaptiveTenuring),
48+ : _use_age_table(ShenandoahGenerationalCensusAtEvac || !ShenandoahGenerationalAdaptiveTenuring),
3749 _age_table(nullptr ) {
3850 if (_use_age_table) {
3951 _age_table = new AgeTable (false );
@@ -45,14 +57,17 @@ AgeTable* ShenandoahEvacuationStats::age_table() const {
4557 return _age_table;
4658}
4759
48- void ShenandoahEvacuationStats::begin_evacuation (size_t bytes) {
49- ++_evacuations_attempted;
50- _bytes_attempted += bytes;
60+ void ShenandoahEvacuationStats::begin_evacuation (size_t bytes, ShenandoahAffiliation from, ShenandoahAffiliation to) {
61+ ShenandoahEvacuations* category = get_category (from, to);
62+ category->_evacuations_attempted ++;
63+ category->_bytes_attempted += bytes;
64+
5165}
5266
53- void ShenandoahEvacuationStats::end_evacuation (size_t bytes) {
54- ++_evacuations_completed;
55- _bytes_completed += bytes;
67+ void ShenandoahEvacuationStats::end_evacuation (size_t bytes, ShenandoahAffiliation from, ShenandoahAffiliation to) {
68+ ShenandoahEvacuations* category = get_category (from, to);
69+ category->_evacuations_completed ++;
70+ category->_bytes_completed += bytes;
5671}
5772
5873void ShenandoahEvacuationStats::record_age (size_t bytes, uint age) {
@@ -63,34 +78,39 @@ void ShenandoahEvacuationStats::record_age(size_t bytes, uint age) {
6378}
6479
6580void ShenandoahEvacuationStats::accumulate (const ShenandoahEvacuationStats* other) {
66- _evacuations_completed += other->_evacuations_completed ;
67- _bytes_completed += other->_bytes_completed ;
68- _evacuations_attempted += other->_evacuations_attempted ;
69- _bytes_attempted += other-> _bytes_attempted ;
81+ _young. accumulate ( other->_young ) ;
82+ _old. accumulate ( other->_old ) ;
83+ _promotion. accumulate ( other->_promotion ) ;
84+
7085 if (_use_age_table) {
7186 _age_table->merge (other->age_table ());
7287 }
7388}
7489
7590void ShenandoahEvacuationStats::reset () {
76- _evacuations_completed = _evacuations_attempted = 0 ;
77- _bytes_completed = _bytes_attempted = 0 ;
91+ _young.reset ();
92+ _old.reset ();
93+ _promotion.reset ();
94+
7895 if (_use_age_table) {
7996 _age_table->clear ();
8097 }
8198}
8299
83- void ShenandoahEvacuationStats::print_on (outputStream* st) {
84- #ifndef PRODUCT
100+ void ShenandoahEvacuationStats::ShenandoahEvacuations::print_on (outputStream* st) const {
85101 size_t abandoned_size = _bytes_attempted - _bytes_completed;
86102 size_t abandoned_count = _evacuations_attempted - _evacuations_completed;
87- st->print_cr (" Evacuated %zu%s across %zu objects, "
88- " abandoned %zu%s across %zu objects." ,
89- byte_size_in_proper_unit (_bytes_completed), proper_unit_for_byte_size (_bytes_completed),
90- _evacuations_completed,
91- byte_size_in_proper_unit (abandoned_size), proper_unit_for_byte_size (abandoned_size),
92- abandoned_count);
93- #endif
103+ st->print_cr (" Evacuated " PROPERFMT" across %zu objects, "
104+ " abandoned " PROPERFMT " across %zu objects." ,
105+ PROPERFMTARGS (_bytes_completed), _evacuations_completed,
106+ PROPERFMTARGS (abandoned_size), abandoned_count);
107+ }
108+
109+ void ShenandoahEvacuationStats::print_on (outputStream* st) const {
110+ st->print (" Young: " ); _young.print_on (st);
111+ st->print (" Promotion: " ); _promotion.print_on (st);
112+ st->print (" Old: " ); _old.print_on (st);
113+
94114 if (_use_age_table) {
95115 _age_table->print_on (st);
96116 }
@@ -103,10 +123,10 @@ void ShenandoahEvacuationTracker::print_global_on(outputStream* st) {
103123void ShenandoahEvacuationTracker::print_evacuations_on (outputStream* st,
104124 ShenandoahEvacuationStats* workers,
105125 ShenandoahEvacuationStats* mutators) {
106- st->print (" Workers: " );
126+ st->print_cr (" Workers: " );
107127 workers->print_on (st);
108128 st->cr ();
109- st->print (" Mutators: " );
129+ st->print_cr (" Mutators: " );
110130 mutators->print_on (st);
111131 st->cr ();
112132
@@ -160,12 +180,12 @@ ShenandoahCycleStats ShenandoahEvacuationTracker::flush_cycle_to_global() {
160180 return {workers, mutators};
161181}
162182
163- void ShenandoahEvacuationTracker::begin_evacuation (Thread* thread, size_t bytes) {
164- ShenandoahThreadLocalData::begin_evacuation (thread, bytes);
183+ void ShenandoahEvacuationTracker::begin_evacuation (Thread* thread, size_t bytes, ShenandoahAffiliation from, ShenandoahAffiliation to ) {
184+ ShenandoahThreadLocalData::begin_evacuation (thread, bytes, from, to );
165185}
166186
167- void ShenandoahEvacuationTracker::end_evacuation (Thread* thread, size_t bytes) {
168- ShenandoahThreadLocalData::end_evacuation (thread, bytes);
187+ void ShenandoahEvacuationTracker::end_evacuation (Thread* thread, size_t bytes, ShenandoahAffiliation from, ShenandoahAffiliation to ) {
188+ ShenandoahThreadLocalData::end_evacuation (thread, bytes, from, to );
169189}
170190
171191void ShenandoahEvacuationTracker::record_age (Thread* thread, size_t bytes, uint age) {
0 commit comments