Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/gc/epsilon/epsilonMonitoringSupport.cpp
41152 views
1
/*
2
* Copyright (c) 2017, 2018, 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
#include "precompiled.hpp"
26
#include "gc/epsilon/epsilonMonitoringSupport.hpp"
27
#include "gc/epsilon/epsilonHeap.hpp"
28
#include "gc/shared/generationCounters.hpp"
29
#include "memory/allocation.hpp"
30
#include "memory/metaspaceCounters.hpp"
31
#include "memory/resourceArea.hpp"
32
#include "runtime/perfData.hpp"
33
#include "services/memoryService.hpp"
34
35
class EpsilonSpaceCounters: public CHeapObj<mtGC> {
36
friend class VMStructs;
37
38
private:
39
PerfVariable* _capacity;
40
PerfVariable* _used;
41
char* _name_space;
42
43
public:
44
EpsilonSpaceCounters(const char* name,
45
int ordinal,
46
size_t max_size,
47
size_t initial_capacity,
48
GenerationCounters* gc) {
49
if (UsePerfData) {
50
EXCEPTION_MARK;
51
ResourceMark rm;
52
53
const char* cns = PerfDataManager::name_space(gc->name_space(), "space", ordinal);
54
55
_name_space = NEW_C_HEAP_ARRAY(char, strlen(cns)+1, mtGC);
56
strcpy(_name_space, cns);
57
58
const char* cname = PerfDataManager::counter_name(_name_space, "name");
59
PerfDataManager::create_string_constant(SUN_GC, cname, name, CHECK);
60
61
cname = PerfDataManager::counter_name(_name_space, "maxCapacity");
62
PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes, (jlong)max_size, CHECK);
63
64
cname = PerfDataManager::counter_name(_name_space, "capacity");
65
_capacity = PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, initial_capacity, CHECK);
66
67
cname = PerfDataManager::counter_name(_name_space, "used");
68
_used = PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, (jlong) 0, CHECK);
69
70
cname = PerfDataManager::counter_name(_name_space, "initCapacity");
71
PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes, initial_capacity, CHECK);
72
}
73
}
74
75
~EpsilonSpaceCounters() {
76
FREE_C_HEAP_ARRAY(char, _name_space);
77
}
78
79
inline void update_all(size_t capacity, size_t used) {
80
_capacity->set_value(capacity);
81
_used->set_value(used);
82
}
83
};
84
85
class EpsilonGenerationCounters : public GenerationCounters {
86
private:
87
EpsilonHeap* _heap;
88
public:
89
EpsilonGenerationCounters(EpsilonHeap* heap) :
90
GenerationCounters("Heap", 1, 1, 0, heap->max_capacity(), heap->capacity()),
91
_heap(heap)
92
{};
93
94
virtual void update_all() {
95
_current_size->set_value(_heap->capacity());
96
}
97
};
98
99
EpsilonMonitoringSupport::EpsilonMonitoringSupport(EpsilonHeap* heap) {
100
_heap_counters = new EpsilonGenerationCounters(heap);
101
_space_counters = new EpsilonSpaceCounters("Heap", 0, heap->max_capacity(), 0, _heap_counters);
102
}
103
104
void EpsilonMonitoringSupport::update_counters() {
105
MemoryService::track_memory_usage();
106
107
if (UsePerfData) {
108
EpsilonHeap* heap = EpsilonHeap::heap();
109
size_t used = heap->used();
110
size_t capacity = heap->capacity();
111
_heap_counters->update_all();
112
_space_counters->update_all(capacity, used);
113
MetaspaceCounters::update_performance_counters();
114
}
115
}
116
117
118