Mercurial > hg > graal-jvmci-8
comparison src/share/vm/memory/metaspaceCounters.cpp @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | |
children | 5d2156bcb78b |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
1 /* | |
2 * Copyright (c) 2012 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 | |
25 #include "precompiled.hpp" | |
26 #include "memory/metaspaceCounters.hpp" | |
27 #include "memory/resourceArea.hpp" | |
28 | |
29 #define METASPACE_NAME "perm" | |
30 | |
31 MetaspaceCounters* MetaspaceCounters::_metaspace_counters = NULL; | |
32 | |
33 MetaspaceCounters::MetaspaceCounters() { | |
34 if (UsePerfData) { | |
35 size_t min_capacity = MetaspaceAux::min_chunk_size(); | |
36 size_t max_capacity = MetaspaceAux::reserved_in_bytes(); | |
37 size_t curr_capacity = MetaspaceAux::capacity_in_bytes(); | |
38 size_t used = MetaspaceAux::used_in_bytes(); | |
39 | |
40 initialize(min_capacity, max_capacity, curr_capacity, used); | |
41 } | |
42 } | |
43 | |
44 void MetaspaceCounters::initialize(size_t min_capacity, | |
45 size_t max_capacity, | |
46 size_t curr_capacity, | |
47 size_t used) { | |
48 | |
49 if (UsePerfData) { | |
50 EXCEPTION_MARK; | |
51 ResourceMark rm; | |
52 | |
53 // Create a name that will be recognized by jstat tools as | |
54 // the perm gen. Change this to a Metaspace name when the | |
55 // tools are fixed. | |
56 // name to recognize "sun.gc.generation.2.*" | |
57 | |
58 const char* name = METASPACE_NAME; | |
59 const int ordinal = 2; | |
60 const int spaces = 1; | |
61 | |
62 const char* cns = PerfDataManager::name_space("generation", ordinal); | |
63 | |
64 _name_space = NEW_C_HEAP_ARRAY(char, strlen(cns)+1, mtClass); | |
65 strcpy(_name_space, cns); | |
66 | |
67 const char* cname = PerfDataManager::counter_name(_name_space, "name"); | |
68 PerfDataManager::create_string_constant(SUN_GC, cname, name, CHECK); | |
69 | |
70 // End of perm gen like name creation | |
71 | |
72 cname = PerfDataManager::counter_name(_name_space, "spaces"); | |
73 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None, | |
74 spaces, CHECK); | |
75 | |
76 cname = PerfDataManager::counter_name(_name_space, "minCapacity"); | |
77 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes, | |
78 min_capacity, CHECK); | |
79 | |
80 cname = PerfDataManager::counter_name(_name_space, "maxCapacity"); | |
81 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes, | |
82 max_capacity, CHECK); | |
83 | |
84 cname = PerfDataManager::counter_name(_name_space, "capacity"); | |
85 _current_size = | |
86 PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes, | |
87 curr_capacity, CHECK); | |
88 | |
89 // SpaceCounter like counters | |
90 // name to recognize "sun.gc.generation.2.space.0.*" | |
91 { | |
92 const int space_ordinal = 0; | |
93 const char* cns = PerfDataManager::name_space(_name_space, "space", | |
94 space_ordinal); | |
95 | |
96 char* space_name_space = NEW_C_HEAP_ARRAY(char, strlen(cns)+1, mtClass); | |
97 strcpy(space_name_space, cns); | |
98 | |
99 const char* cname = PerfDataManager::counter_name(space_name_space, "name"); | |
100 PerfDataManager::create_string_constant(SUN_GC, cname, name, CHECK); | |
101 | |
102 cname = PerfDataManager::counter_name(space_name_space, "maxCapacity"); | |
103 _max_capacity = PerfDataManager::create_variable(SUN_GC, cname, | |
104 PerfData::U_Bytes, | |
105 (jlong)max_capacity, CHECK); | |
106 | |
107 cname = PerfDataManager::counter_name(space_name_space, "capacity"); | |
108 _capacity = PerfDataManager::create_variable(SUN_GC, cname, | |
109 PerfData::U_Bytes, | |
110 curr_capacity, CHECK); | |
111 | |
112 cname = PerfDataManager::counter_name(space_name_space, "used"); | |
113 _used = PerfDataManager::create_variable(SUN_GC, | |
114 cname, | |
115 PerfData::U_Bytes, | |
116 used, | |
117 CHECK); | |
118 | |
119 cname = PerfDataManager::counter_name(space_name_space, "initCapacity"); | |
120 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes, | |
121 min_capacity, CHECK); | |
122 } | |
123 } | |
124 } | |
125 | |
126 void MetaspaceCounters::update_capacity() { | |
127 assert(UsePerfData, "Should not be called unless being used"); | |
128 size_t capacity_in_bytes = MetaspaceAux::capacity_in_bytes(); | |
129 _capacity->set_value(capacity_in_bytes); | |
130 } | |
131 | |
132 void MetaspaceCounters::update_used() { | |
133 assert(UsePerfData, "Should not be called unless being used"); | |
134 size_t used_in_bytes = MetaspaceAux::used_in_bytes(); | |
135 _used->set_value(used_in_bytes); | |
136 } | |
137 | |
138 void MetaspaceCounters::update_max_capacity() { | |
139 assert(UsePerfData, "Should not be called unless being used"); | |
140 size_t reserved_in_bytes = MetaspaceAux::reserved_in_bytes(); | |
141 _max_capacity->set_value(reserved_in_bytes); | |
142 } | |
143 | |
144 void MetaspaceCounters::update_all() { | |
145 if (UsePerfData) { | |
146 update_used(); | |
147 update_capacity(); | |
148 update_max_capacity(); | |
149 _current_size->set_value(MetaspaceAux::reserved_in_bytes()); | |
150 } | |
151 } | |
152 | |
153 void MetaspaceCounters::initialize_performance_counters() { | |
154 if (UsePerfData) { | |
155 _metaspace_counters = new MetaspaceCounters(); | |
156 } | |
157 } | |
158 | |
159 void MetaspaceCounters::update_performance_counters() { | |
160 if (UsePerfData) { | |
161 _metaspace_counters->update_all(); | |
162 } | |
163 } | |
164 |