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();
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
63 ShenandoahEvacuationStats _workers_global;
64 ShenandoahEvacuationStats _mutators_global;
65
66 public:
67 ShenandoahEvacuationTracker() = default;
68
69 void begin_evacuation(Thread* thread, size_t bytes);
70 void end_evacuation(Thread* thread, size_t bytes);
71 void record_age(Thread* thread, size_t bytes, uint age);
72
73 void print_global_on(outputStream* st);
74 void print_evacuations_on(outputStream* st,
75 ShenandoahEvacuationStats* workers,
76 ShenandoahEvacuationStats* mutators);
77
78 ShenandoahCycleStats flush_cycle_to_global();
79 };
80
81 #endif //SHARE_GC_SHENANDOAH_SHENANDOAHEVACTRACKER_HPP