1 /*
 2  * Copyright Amazon.com Inc. or its affiliates. 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   bool      _use_age_table;
39   AgeTable* _age_table;
40 
41  public:
42   ShenandoahEvacuationStats(bool generational);
43 
44   AgeTable* age_table() const;
45 
46   void begin_evacuation(size_t bytes);
47   void end_evacuation(size_t bytes);
48   void record_age(size_t bytes, uint age);
49 
50   void print_on(outputStream* st);
51   void accumulate(const ShenandoahEvacuationStats* other);
52   void reset();
53 };
54 
55 struct ShenandoahCycleStats {
56   ShenandoahEvacuationStats workers;
57   ShenandoahEvacuationStats mutators;
58 };
59 
60 class ShenandoahEvacuationTracker : public CHeapObj<mtGC> {
61 private:
62   bool _generational;
63 
64   ShenandoahEvacuationStats _workers_global;
65   ShenandoahEvacuationStats _mutators_global;
66 
67 public:
68   ShenandoahEvacuationTracker(bool generational) :
69    _generational(generational),
70    _workers_global(generational),
71    _mutators_global(generational) {}
72 
73   void begin_evacuation(Thread* thread, size_t bytes);
74   void end_evacuation(Thread* thread, size_t bytes);
75   void record_age(Thread* thread, size_t bytes, uint age);
76 
77   void print_global_on(outputStream* st);
78   void print_evacuations_on(outputStream* st,
79                                    ShenandoahEvacuationStats* workers,
80                                    ShenandoahEvacuationStats* mutators);
81 
82   ShenandoahCycleStats flush_cycle_to_global();
83 };
84 
85 #endif //SHARE_GC_SHENANDOAH_SHENANDOAHEVACTRACKER_HPP