1 /*
 2  * Copyright (c) 2022, Amazon, Inc. All rights reserved.
 3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 4  *
 5  * This code is free software; you can redistribute it and/or modify it
 6  * under the terms of the GNU General Public License version 2 only, as
 7  * published by the Free Software Foundation.
 8  *
 9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  *
23  */
24 
25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHEVACTRACKER_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHEVACTRACKER_HPP
27 
28 #include "gc/shared/ageTable.hpp"
29 #include "utilities/ostream.hpp"
30 
31 class ShenandoahEvacuationStats : public CHeapObj<mtGC> {
32  private:
33   size_t _evacuations_completed;
34   size_t _bytes_completed;
35   size_t _evacuations_attempted;
36   size_t _bytes_attempted;
37 
38   AgeTable _age_table;
39 
40  public:
41   ShenandoahEvacuationStats();
42   void begin_evacuation(size_t bytes);
43   void end_evacuation(size_t bytes, uint age);
44 
45   void print_on(outputStream* st);
46   void accumulate(const ShenandoahEvacuationStats* other);
47   void reset();
48 };
49 
50 struct ShenandoahCycleStats {
51   ShenandoahEvacuationStats workers;
52   ShenandoahEvacuationStats mutators;
53 };
54 
55 class ShenandoahEvacuationTracker : public CHeapObj<mtGC> {
56  private:
57   ShenandoahEvacuationStats  _workers_global;
58   ShenandoahEvacuationStats  _mutators_global;
59 
60  public:
61   void begin_evacuation(Thread* thread, size_t bytes);
62   void end_evacuation(Thread* thread, size_t bytes, uint age);
63 
64   void print_global_on(outputStream* st);
65   static void print_evacuations_on(outputStream* st, ShenandoahEvacuationStats* workers, ShenandoahEvacuationStats* mutators);
66 
67   ShenandoahCycleStats flush_cycle_to_global();
68  private:
69 };
70 
71 #endif //SHARE_GC_SHENANDOAH_SHENANDOAHEVACTRACKER_HPP