author | shade |
Mon, 26 Mar 2018 16:01:23 +0200 | |
branch | epsilon-gc-branch |
changeset 56350 | 56014b46de69 |
parent 55939 | c5c3e1a5c3f0 |
child 56351 | 08b27b968b24 |
permissions | -rw-r--r-- |
55767 | 1 |
/* |
56350 | 2 |
* Copyright (c) 2017, 2018, Red Hat, Inc. All rights reserved. |
55767 | 3 |
* |
4 |
* This code is free software; you can redistribute it and/or modify it |
|
5 |
* under the terms of the GNU General Public License version 2 only, as |
|
6 |
* published by the Free Software Foundation. |
|
7 |
* |
|
8 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
9 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
10 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
11 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
12 |
* accompanied this code). |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License version |
|
15 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
16 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
17 |
* |
|
18 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
19 |
* or visit www.oracle.com if you need additional information or have any |
|
20 |
* questions. |
|
21 |
* |
|
22 |
*/ |
|
23 |
||
24 |
#include "precompiled.hpp" |
|
25 |
#include "services/memoryService.hpp" |
|
26 |
#include "gc/shared/generationCounters.hpp" |
|
27 |
#include "gc/epsilon/epsilonMonitoringSupport.hpp" |
|
55939 | 28 |
#include "gc/epsilon/epsilonHeap.hpp" |
55767 | 29 |
|
30 |
class EpsilonSpaceCounters: public CHeapObj<mtGC> { |
|
31 |
friend class VMStructs; |
|
32 |
||
33 |
private: |
|
34 |
PerfVariable* _capacity; |
|
35 |
PerfVariable* _used; |
|
36 |
char* _name_space; |
|
37 |
||
38 |
public: |
|
39 |
||
40 |
EpsilonSpaceCounters(const char* name, |
|
41 |
int ordinal, |
|
42 |
size_t max_size, |
|
43 |
size_t initial_capacity, |
|
44 |
GenerationCounters* gc) { |
|
45 |
||
46 |
if (UsePerfData) { |
|
47 |
EXCEPTION_MARK; |
|
48 |
ResourceMark rm; |
|
49 |
||
50 |
const char* cns = PerfDataManager::name_space(gc->name_space(), "space", ordinal); |
|
51 |
||
52 |
_name_space = NEW_C_HEAP_ARRAY(char, strlen(cns)+1, mtGC); |
|
53 |
strcpy(_name_space, cns); |
|
54 |
||
55 |
const char* cname = PerfDataManager::counter_name(_name_space, "name"); |
|
56 |
PerfDataManager::create_string_constant(SUN_GC, cname, name, CHECK); |
|
57 |
||
58 |
cname = PerfDataManager::counter_name(_name_space, "maxCapacity"); |
|
59 |
PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes, (jlong)max_size, CHECK); |
|
60 |
||
61 |
cname = PerfDataManager::counter_name(_name_space, "capacity"); |
|
62 |
_capacity = PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, initial_capacity, CHECK); |
|
63 |
||
64 |
cname = PerfDataManager::counter_name(_name_space, "used"); |
|
65 |
_used = PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, (jlong) 0, CHECK); |
|
66 |
||
67 |
cname = PerfDataManager::counter_name(_name_space, "initCapacity"); |
|
68 |
PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes, initial_capacity, CHECK); |
|
69 |
} |
|
70 |
} |
|
71 |
||
72 |
~EpsilonSpaceCounters() { |
|
73 |
if (_name_space != NULL) { |
|
74 |
FREE_C_HEAP_ARRAY(char, _name_space); |
|
75 |
} |
|
76 |
} |
|
77 |
||
78 |
inline void update_all(size_t capacity, size_t used) { |
|
79 |
_capacity->set_value(capacity); |
|
80 |
_used->set_value(used); |
|
81 |
} |
|
82 |
}; |
|
83 |
||
84 |
||
85 |
class EpsilonYoungGenerationCounters : public GenerationCounters { |
|
86 |
public: |
|
87 |
EpsilonYoungGenerationCounters() : |
|
88 |
GenerationCounters("Young", 0, 0, 0, (size_t)0, (size_t)0) {}; |
|
89 |
||
90 |
virtual void update_all() { |
|
91 |
// no update |
|
92 |
} |
|
93 |
}; |
|
94 |
||
95 |
class EpsilonGenerationCounters : public GenerationCounters { |
|
96 |
private: |
|
55939 | 97 |
EpsilonHeap* _heap; |
55767 | 98 |
public: |
55939 | 99 |
EpsilonGenerationCounters(EpsilonHeap* heap) : |
55767 | 100 |
GenerationCounters("Heap", 1, 1, 0, heap->max_capacity(), heap->capacity()), |
101 |
_heap(heap) |
|
102 |
{}; |
|
103 |
||
104 |
virtual void update_all() { |
|
105 |
_current_size->set_value(_heap->capacity()); |
|
106 |
} |
|
107 |
}; |
|
108 |
||
55939 | 109 |
EpsilonMonitoringSupport::EpsilonMonitoringSupport(EpsilonHeap* heap) { |
55767 | 110 |
// We report young gen as unused. |
111 |
_young_counters = new EpsilonYoungGenerationCounters(); |
|
112 |
_heap_counters = new EpsilonGenerationCounters(heap); |
|
113 |
_space_counters = new EpsilonSpaceCounters("Heap", 0, heap->max_capacity(), 0, _heap_counters); |
|
114 |
} |
|
115 |
||
116 |
void EpsilonMonitoringSupport::update_counters() { |
|
117 |
MemoryService::track_memory_usage(); |
|
118 |
||
119 |
if (UsePerfData) { |
|
55939 | 120 |
EpsilonHeap* heap = EpsilonHeap::heap(); |
55767 | 121 |
size_t used = heap->used(); |
122 |
size_t capacity = heap->capacity(); |
|
123 |
_heap_counters->update_all(); |
|
124 |
_space_counters->update_all(capacity, used); |
|
125 |
MetaspaceCounters::update_performance_counters(); |
|
126 |
CompressedClassSpaceCounters::update_performance_counters(); |
|
127 |
} |
|
55778
a977fcca316b
Fix newlines and whitespace to minimize difference against upstream
shade
parents:
55767
diff
changeset
|
128 |
} |
a977fcca316b
Fix newlines and whitespace to minimize difference against upstream
shade
parents:
55767
diff
changeset
|
129 |