1 /*
2 * Copyright (c) 2015, 2019, Red Hat, 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_SHENANDOAHMONITORINGSUPPORT_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHMONITORINGSUPPORT_HPP
27
28 #include "gc/shenandoah/shenandoahSharedVariables.hpp"
29 #include "memory/allocation.hpp"
30 #include "runtime/task.hpp"
31
32 class GenerationCounters;
33 class HSpaceCounters;
34 class ShenandoahHeap;
35 class CollectorCounters;
36 class ShenandoahHeapRegionCounters;
37 class ShenandoahMonitoringSupport;
38
39 class ShenandoahPeriodicCountersUpdateTask : public PeriodicTask {
40 private:
41 ShenandoahSharedFlag _do_counters_update;
42 ShenandoahSharedFlag _force_counters_update;
43 ShenandoahMonitoringSupport* const _monitoring_support;
44
45 public:
46 explicit ShenandoahPeriodicCountersUpdateTask(ShenandoahMonitoringSupport* monitoring_support) :
47 PeriodicTask(100),
48 _monitoring_support(monitoring_support) { }
49
50 void task() override;
51
52 void handle_counters_update();
53 void handle_force_counters_update();
54 void set_forced_counters_update(bool value);
55 void notify_heap_changed();
56 };
57
58 class ShenandoahMonitoringSupport : public CHeapObj<mtGC> {
59 private:
60 CollectorCounters* _partial_counters;
61 CollectorCounters* _full_counters;
62
63 GenerationCounters* _young_counters;
64 GenerationCounters* _heap_counters;
65
66 HSpaceCounters* _space_counters;
67
68 ShenandoahHeapRegionCounters* _heap_region_counters;
69 ShenandoahPeriodicCountersUpdateTask _counters_update_task;
70
71 public:
72 explicit ShenandoahMonitoringSupport(ShenandoahHeap* heap);
73 CollectorCounters* stw_collection_counters();
74 CollectorCounters* full_stw_collection_counters();
75 CollectorCounters* concurrent_collection_counters();
76 CollectorCounters* partial_collection_counters();
77
78 void notify_heap_changed();
79 void set_forced_counters_update(bool value);
80 void handle_force_counters_update();
81
82 void update_counters();
83 };
84
85 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMONITORINGSUPPORT_HPP