1/*
2 * Copyright (c) 2017, 2019, Oracle and/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#ifndef SHARE_GC_Z_ZSERVICEABILITY_HPP
25#define SHARE_GC_Z_ZSERVICEABILITY_HPP
26
27#include "gc/shared/collectorCounters.hpp"
28#include "gc/shared/gcVMOperations.hpp"
29#include "memory/allocation.hpp"
30#include "services/memoryManager.hpp"
31#include "services/memoryPool.hpp"
32#include "services/memoryService.hpp"
33
34class ZServiceabilityCounters;
35
36class ZServiceabilityMemoryPool : public CollectedMemoryPool {
37public:
38 ZServiceabilityMemoryPool(size_t min_capacity, size_t max_capacity);
39
40 virtual size_t used_in_bytes();
41 virtual MemoryUsage get_memory_usage();
42};
43
44class ZServiceabilityMemoryManager : public GCMemoryManager {
45public:
46 ZServiceabilityMemoryManager(ZServiceabilityMemoryPool* pool);
47};
48
49class ZServiceability {
50private:
51 const size_t _min_capacity;
52 const size_t _max_capacity;
53 ZServiceabilityMemoryPool _memory_pool;
54 ZServiceabilityMemoryManager _memory_manager;
55 ZServiceabilityCounters* _counters;
56
57public:
58 ZServiceability(size_t min_capacity, size_t max_capacity);
59
60 void initialize();
61
62 MemoryPool* memory_pool();
63 GCMemoryManager* memory_manager();
64 ZServiceabilityCounters* counters();
65};
66
67class ZServiceabilityMemoryUsageTracker {
68public:
69 ~ZServiceabilityMemoryUsageTracker();
70};
71
72class ZServiceabilityManagerStatsTracer {
73private:
74 TraceMemoryManagerStats _stats;
75
76public:
77 ZServiceabilityManagerStatsTracer(bool is_gc_begin, bool is_gc_end);
78};
79
80class ZServiceabilityCountersTracer {
81private:
82 TraceCollectorStats _stats;
83
84public:
85 ZServiceabilityCountersTracer();
86 ~ZServiceabilityCountersTracer();
87};
88
89template <bool IsGCStart, bool IsGCEnd>
90class ZServiceabilityTracer : public StackObj {
91private:
92 SvcGCMarker _svc_gc_marker;
93 ZServiceabilityMemoryUsageTracker _memory_usage_tracker;
94 ZServiceabilityManagerStatsTracer _manager_stats_tracer;
95 ZServiceabilityCountersTracer _counters_tracer;
96
97public:
98 ZServiceabilityTracer() :
99 _svc_gc_marker(SvcGCMarker::CONCURRENT),
100 _memory_usage_tracker(),
101 _manager_stats_tracer(IsGCStart, IsGCEnd),
102 _counters_tracer() {}
103};
104
105typedef ZServiceabilityTracer<true, false> ZServiceabilityMarkStartTracer;
106typedef ZServiceabilityTracer<false, false> ZServiceabilityMarkEndTracer;
107typedef ZServiceabilityTracer<false, true> ZServiceabilityRelocateStartTracer;
108
109#endif // SHARE_GC_Z_ZSERVICEABILITY_HPP
110