author | coleenp |
Fri, 04 Jan 2019 15:06:01 -0500 | |
changeset 53149 | 259c36ef27df |
parent 53035 | 0e5c83bf4ff7 |
child 53244 | 9807daeb47c4 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2141
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2141
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2141
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_MEMORY_HEAPINSPECTION_HPP |
26 |
#define SHARE_VM_MEMORY_HEAPINSPECTION_HPP |
|
27 |
||
29081
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
27677
diff
changeset
|
28 |
#include "memory/allocation.hpp" |
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
27677
diff
changeset
|
29 |
#include "oops/objArrayOop.hpp" |
c61eb4914428
8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents:
27677
diff
changeset
|
30 |
#include "oops/oop.hpp" |
15437 | 31 |
#include "oops/annotations.hpp" |
15482
470d0b0c09f1
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
13975
diff
changeset
|
32 |
#include "utilities/macros.hpp" |
7397 | 33 |
|
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
34 |
#if INCLUDE_SERVICES |
1 | 35 |
|
36 |
||
37 |
// HeapInspection |
|
38 |
||
39 |
// KlassInfoTable is a bucket hash table that |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
40 |
// maps Klass*s to extra information: |
1 | 41 |
// instance count and instance word size. |
42 |
// |
|
43 |
// A KlassInfoBucket is the head of a link list |
|
44 |
// of KlassInfoEntry's |
|
45 |
// |
|
46 |
// KlassInfoHisto is a growable array of pointers |
|
47 |
// to KlassInfoEntry's and is used to sort |
|
48 |
// the entries. |
|
49 |
||
15437 | 50 |
#define HEAP_INSPECTION_COLUMNS_DO(f) \ |
51 |
f(inst_size, InstSize, \ |
|
52 |
"Size of each object instance of the Java class") \ |
|
53 |
f(inst_count, InstCount, \ |
|
54 |
"Number of object instances of the Java class") \ |
|
55 |
f(inst_bytes, InstBytes, \ |
|
56 |
"This is usually (InstSize * InstNum). The only exception is " \ |
|
57 |
"java.lang.Class, whose InstBytes also includes the slots " \ |
|
58 |
"used to store static fields. InstBytes is not counted in " \ |
|
59 |
"ROAll, RWAll or Total") \ |
|
60 |
f(mirror_bytes, Mirror, \ |
|
61 |
"Size of the Klass::java_mirror() object") \ |
|
62 |
f(klass_bytes, KlassBytes, \ |
|
63 |
"Size of the InstanceKlass or ArrayKlass for this class. " \ |
|
64 |
"Note that this includes VTab, ITab, OopMap") \ |
|
65 |
f(secondary_supers_bytes, K_secondary_supers, \ |
|
66 |
"Number of bytes used by the Klass::secondary_supers() array") \ |
|
67 |
f(vtab_bytes, VTab, \ |
|
68 |
"Size of the embedded vtable in InstanceKlass") \ |
|
69 |
f(itab_bytes, ITab, \ |
|
70 |
"Size of the embedded itable in InstanceKlass") \ |
|
71 |
f(nonstatic_oopmap_bytes, OopMap, \ |
|
72 |
"Size of the embedded nonstatic_oop_map in InstanceKlass") \ |
|
73 |
f(methods_array_bytes, IK_methods, \ |
|
74 |
"Number of bytes used by the InstanceKlass::methods() array") \ |
|
75 |
f(method_ordering_bytes, IK_method_ordering, \ |
|
76 |
"Number of bytes used by the InstanceKlass::method_ordering() array") \ |
|
20391
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20282
diff
changeset
|
77 |
f(default_methods_array_bytes, IK_default_methods, \ |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20282
diff
changeset
|
78 |
"Number of bytes used by the InstanceKlass::default_methods() array") \ |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20282
diff
changeset
|
79 |
f(default_vtable_indices_bytes, IK_default_vtable_indices, \ |
7b146c5ebb18
8009130: Lambda: Fix access controls, loader constraints.
acorn
parents:
20282
diff
changeset
|
80 |
"Number of bytes used by the InstanceKlass::default_vtable_indices() array") \ |
15437 | 81 |
f(local_interfaces_bytes, IK_local_interfaces, \ |
82 |
"Number of bytes used by the InstanceKlass::local_interfaces() array") \ |
|
83 |
f(transitive_interfaces_bytes, IK_transitive_interfaces, \ |
|
84 |
"Number of bytes used by the InstanceKlass::transitive_interfaces() array") \ |
|
85 |
f(fields_bytes, IK_fields, \ |
|
86 |
"Number of bytes used by the InstanceKlass::fields() array") \ |
|
87 |
f(inner_classes_bytes, IK_inner_classes, \ |
|
88 |
"Number of bytes used by the InstanceKlass::inner_classes() array") \ |
|
50735
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
89 |
f(nest_members_bytes, IK_nest_members, \ |
2f2af62dfac7
8010319: Implementation of JEP 181: Nest-Based Access Control
dholmes
parents:
47216
diff
changeset
|
90 |
"Number of bytes used by the InstanceKlass::nest_members() array") \ |
15437 | 91 |
f(signers_bytes, IK_signers, \ |
92 |
"Number of bytes used by the InstanceKlass::singers() array") \ |
|
93 |
f(class_annotations_bytes, class_annotations, \ |
|
94 |
"Size of class annotations") \ |
|
15601 | 95 |
f(class_type_annotations_bytes, class_type_annotations, \ |
96 |
"Size of class type annotations") \ |
|
15437 | 97 |
f(fields_annotations_bytes, fields_annotations, \ |
98 |
"Size of field annotations") \ |
|
15601 | 99 |
f(fields_type_annotations_bytes, fields_type_annotations, \ |
100 |
"Size of field type annotations") \ |
|
15437 | 101 |
f(methods_annotations_bytes, methods_annotations, \ |
102 |
"Size of method annotations") \ |
|
103 |
f(methods_parameter_annotations_bytes, methods_parameter_annotations, \ |
|
104 |
"Size of method parameter annotations") \ |
|
15601 | 105 |
f(methods_type_annotations_bytes, methods_type_annotations, \ |
106 |
"Size of methods type annotations") \ |
|
15437 | 107 |
f(methods_default_annotations_bytes, methods_default_annotations, \ |
108 |
"Size of methods default annotations") \ |
|
109 |
f(annotations_bytes, annotations, \ |
|
110 |
"Size of all annotations") \ |
|
111 |
f(cp_bytes, Cp, \ |
|
112 |
"Size of InstanceKlass::constants()") \ |
|
113 |
f(cp_tags_bytes, CpTags, \ |
|
114 |
"Size of InstanceKlass::constants()->tags()") \ |
|
115 |
f(cp_cache_bytes, CpCache, \ |
|
116 |
"Size of InstanceKlass::constants()->cache()") \ |
|
117 |
f(cp_operands_bytes, CpOperands, \ |
|
118 |
"Size of InstanceKlass::constants()->operands()") \ |
|
119 |
f(cp_refmap_bytes, CpRefMap, \ |
|
120 |
"Size of InstanceKlass::constants()->reference_map()") \ |
|
121 |
f(cp_all_bytes, CpAll, \ |
|
122 |
"Sum of Cp + CpTags + CpCache + CpOperands + CpRefMap") \ |
|
123 |
f(method_count, MethodCount, \ |
|
124 |
"Number of methods in this class") \ |
|
125 |
f(method_bytes, MethodBytes, \ |
|
126 |
"Size of the Method object") \ |
|
127 |
f(const_method_bytes, ConstMethod, \ |
|
128 |
"Size of the ConstMethod object") \ |
|
129 |
f(method_data_bytes, MethodData, \ |
|
130 |
"Size of the MethodData object") \ |
|
131 |
f(stackmap_bytes, StackMap, \ |
|
132 |
"Size of the stackmap_data") \ |
|
133 |
f(bytecode_bytes, Bytecodes, \ |
|
134 |
"Of the MethodBytes column, how much are the space taken up by bytecodes") \ |
|
135 |
f(method_all_bytes, MethodAll, \ |
|
136 |
"Sum of MethodBytes + Constmethod + Stackmap + Methoddata") \ |
|
137 |
f(ro_bytes, ROAll, \ |
|
138 |
"Size of all class meta data that could (potentially) be placed " \ |
|
139 |
"in read-only memory. (This could change with CDS design)") \ |
|
140 |
f(rw_bytes, RWAll, \ |
|
141 |
"Size of all class meta data that must be placed in read/write " \ |
|
142 |
"memory. (This could change with CDS design) ") \ |
|
143 |
f(total_bytes, Total, \ |
|
144 |
"ROAll + RWAll. Note that this does NOT include InstBytes.") |
|
145 |
||
146 |
// Size statistics for a Klass - filled in by Klass::collect_statistics() |
|
147 |
class KlassSizeStats { |
|
148 |
public: |
|
149 |
#define COUNT_KLASS_SIZE_STATS_FIELD(field, name, help) _index_ ## field, |
|
150 |
#define DECLARE_KLASS_SIZE_STATS_FIELD(field, name, help) julong _ ## field; |
|
151 |
||
152 |
enum { |
|
153 |
HEAP_INSPECTION_COLUMNS_DO(COUNT_KLASS_SIZE_STATS_FIELD) |
|
154 |
_num_columns |
|
155 |
}; |
|
156 |
||
157 |
HEAP_INSPECTION_COLUMNS_DO(DECLARE_KLASS_SIZE_STATS_FIELD) |
|
158 |
||
35862
411842d0c882
8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
33604
diff
changeset
|
159 |
static int count(oop x); |
15437 | 160 |
|
35862
411842d0c882
8146395: Add inline qualifier in oop.hpp and fix inlining in gc files
goetz
parents:
33604
diff
changeset
|
161 |
static int count_array(objArrayOop x); |
15437 | 162 |
|
163 |
template <class T> static int count(T* x) { |
|
164 |
return (HeapWordSize * ((x) ? (x)->size() : 0)); |
|
165 |
} |
|
166 |
||
167 |
template <class T> static int count_array(T* x) { |
|
168 |
if (x == NULL) { |
|
169 |
return 0; |
|
170 |
} |
|
171 |
if (x->length() == 0) { |
|
172 |
// This is a shared array, e.g., Universe::the_empty_int_array(). Don't |
|
173 |
// count it to avoid double-counting. |
|
174 |
return 0; |
|
175 |
} |
|
176 |
return HeapWordSize * x->size(); |
|
177 |
} |
|
178 |
}; |
|
179 |
||
180 |
||
181 |
||
182 |
||
13195 | 183 |
class KlassInfoEntry: public CHeapObj<mtInternal> { |
1 | 184 |
private: |
185 |
KlassInfoEntry* _next; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
186 |
Klass* _klass; |
1 | 187 |
long _instance_count; |
188 |
size_t _instance_words; |
|
15437 | 189 |
long _index; |
29071
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
190 |
bool _do_print; // True if we should print this class when printing the class hierarchy. |
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
191 |
GrowableArray<KlassInfoEntry*>* _subclasses; |
1 | 192 |
|
193 |
public: |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
13195
diff
changeset
|
194 |
KlassInfoEntry(Klass* k, KlassInfoEntry* next) : |
51334
cc2c79d22508
8208671: Runtime, JFR, Serviceability changes to allow enabling -Wreorder
tschatzl
parents:
50735
diff
changeset
|
195 |
_next(next), _klass(k), _instance_count(0), _instance_words(0), _index(-1), |
29071
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
196 |
_do_print(false), _subclasses(NULL) |
1 | 197 |
{} |
29071
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
198 |
~KlassInfoEntry(); |
17370
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
15601
diff
changeset
|
199 |
KlassInfoEntry* next() const { return _next; } |
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
15601
diff
changeset
|
200 |
bool is_equal(const Klass* k) { return k == _klass; } |
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
15601
diff
changeset
|
201 |
Klass* klass() const { return _klass; } |
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
15601
diff
changeset
|
202 |
long count() const { return _instance_count; } |
1 | 203 |
void set_count(long ct) { _instance_count = ct; } |
17370
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
15601
diff
changeset
|
204 |
size_t words() const { return _instance_words; } |
1 | 205 |
void set_words(size_t wds) { _instance_words = wds; } |
15437 | 206 |
void set_index(long index) { _index = index; } |
17370
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
15601
diff
changeset
|
207 |
long index() const { return _index; } |
29071
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
208 |
GrowableArray<KlassInfoEntry*>* subclasses() const { return _subclasses; } |
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
209 |
void add_subclass(KlassInfoEntry* cie); |
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
210 |
void set_do_print(bool do_print) { _do_print = do_print; } |
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
211 |
bool do_print() const { return _do_print; } |
1 | 212 |
int compare(KlassInfoEntry* e1, KlassInfoEntry* e2); |
213 |
void print_on(outputStream* st) const; |
|
15437 | 214 |
const char* name() const; |
1 | 215 |
}; |
216 |
||
18704
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
217 |
class KlassInfoClosure : public StackObj { |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
218 |
public: |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
219 |
// Called for each KlassInfoEntry. |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
220 |
virtual void do_cinfo(KlassInfoEntry* cie) = 0; |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
221 |
}; |
226ce98e75e6
8015972: Refactor the sending of the object count after GC event
ehelin
parents:
18025
diff
changeset
|
222 |
|
13195 | 223 |
class KlassInfoBucket: public CHeapObj<mtInternal> { |
1 | 224 |
private: |
225 |
KlassInfoEntry* _list; |
|
226 |
KlassInfoEntry* list() { return _list; } |
|
227 |
void set_list(KlassInfoEntry* l) { _list = l; } |
|
228 |
public: |
|
17370
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
15601
diff
changeset
|
229 |
KlassInfoEntry* lookup(Klass* k); |
1 | 230 |
void initialize() { _list = NULL; } |
231 |
void empty(); |
|
232 |
void iterate(KlassInfoClosure* cic); |
|
233 |
}; |
|
234 |
||
235 |
class KlassInfoTable: public StackObj { |
|
236 |
private: |
|
18025 | 237 |
static const int _num_buckets = 20011; |
238 |
size_t _size_of_instances_in_words; |
|
1 | 239 |
|
240 |
// An aligned reference address (typically the least |
|
241 |
// address in the perm gen) used for hashing klass |
|
242 |
// objects. |
|
243 |
HeapWord* _ref; |
|
244 |
||
245 |
KlassInfoBucket* _buckets; |
|
17370
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
15601
diff
changeset
|
246 |
uint hash(const Klass* p); |
59a0620561fa
8003557: NPG: Klass* const k should be const Klass* k.
minqi
parents:
15601
diff
changeset
|
247 |
KlassInfoEntry* lookup(Klass* k); // allocates if not found! |
15437 | 248 |
|
51608 | 249 |
class AllClassesFinder; |
1 | 250 |
|
251 |
public: |
|
29071
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
252 |
KlassInfoTable(bool add_all_classes); |
1 | 253 |
~KlassInfoTable(); |
184
a2da5efb871c
6621728: Heap inspection should not crash in the face of C-heap exhaustion
ysr
parents:
1
diff
changeset
|
254 |
bool record_instance(const oop obj); |
1 | 255 |
void iterate(KlassInfoClosure* cic); |
184
a2da5efb871c
6621728: Heap inspection should not crash in the face of C-heap exhaustion
ysr
parents:
1
diff
changeset
|
256 |
bool allocation_failed() { return _buckets == NULL; } |
18025 | 257 |
size_t size_of_instances_in_words() const; |
15437 | 258 |
|
259 |
friend class KlassInfoHisto; |
|
29071
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
260 |
friend class KlassHierarchy; |
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
261 |
}; |
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
262 |
|
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
263 |
class KlassHierarchy : AllStatic { |
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
264 |
public: |
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
265 |
static void print_class_hierarchy(outputStream* st, bool print_interfaces, bool print_subclasses, |
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
266 |
char* classname); |
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
267 |
|
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
268 |
private: |
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
269 |
static void set_do_print_for_class_hierarchy(KlassInfoEntry* cie, KlassInfoTable* cit, |
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
270 |
bool print_subclasse); |
73f45d04ad7a
8054888: Runtime: Add Diagnostic Command that prints the class hierarchy
cjplummer
parents:
27677
diff
changeset
|
271 |
static void print_class(outputStream* st, KlassInfoEntry* cie, bool print_subclasses); |
1 | 272 |
}; |
273 |
||
274 |
class KlassInfoHisto : public StackObj { |
|
275 |
private: |
|
18025 | 276 |
static const int _histo_initial_size = 1000; |
15437 | 277 |
KlassInfoTable *_cit; |
1 | 278 |
GrowableArray<KlassInfoEntry*>* _elements; |
279 |
GrowableArray<KlassInfoEntry*>* elements() const { return _elements; } |
|
280 |
static int sort_helper(KlassInfoEntry** e1, KlassInfoEntry** e2); |
|
281 |
void print_elements(outputStream* st) const; |
|
15437 | 282 |
void print_class_stats(outputStream* st, bool csv_format, const char *columns); |
283 |
julong annotations_bytes(Array<AnnotationArray*>* p) const; |
|
284 |
const char *_selected_columns; |
|
285 |
bool is_selected(const char *col_name); |
|
286 |
void print_title(outputStream* st, bool csv_format, |
|
287 |
bool selected_columns_table[], int width_table[], |
|
288 |
const char *name_table[]); |
|
289 |
||
290 |
template <class T> static int count_bytes(T* x) { |
|
291 |
return (HeapWordSize * ((x) ? (x)->size() : 0)); |
|
292 |
} |
|
293 |
||
294 |
template <class T> static int count_bytes_array(T* x) { |
|
295 |
if (x == NULL) { |
|
296 |
return 0; |
|
297 |
} |
|
298 |
if (x->length() == 0) { |
|
299 |
// This is a shared array, e.g., Universe::the_empty_int_array(). Don't |
|
300 |
// count it to avoid double-counting. |
|
301 |
return 0; |
|
302 |
} |
|
303 |
return HeapWordSize * x->size(); |
|
304 |
} |
|
305 |
||
306 |
static void print_julong(outputStream* st, int width, julong n) { |
|
307 |
int num_spaces = width - julong_width(n); |
|
308 |
if (num_spaces > 0) { |
|
33604
ad1cd9269bd4
8139116: Fixes for warning "format not a string literal"
goetz
parents:
29085
diff
changeset
|
309 |
st->print("%*s", num_spaces, ""); |
15437 | 310 |
} |
311 |
st->print(JULONG_FORMAT, n); |
|
312 |
} |
|
313 |
||
314 |
static int julong_width(julong n) { |
|
315 |
if (n == 0) { |
|
316 |
return 1; |
|
317 |
} |
|
318 |
int w = 0; |
|
319 |
while (n > 0) { |
|
320 |
n /= 10; |
|
321 |
w += 1; |
|
322 |
} |
|
323 |
return w; |
|
324 |
} |
|
325 |
||
326 |
static int col_width(julong n, const char *name) { |
|
327 |
int w = julong_width(n); |
|
328 |
int min = (int)(strlen(name)); |
|
329 |
if (w < min) { |
|
330 |
w = min; |
|
331 |
} |
|
332 |
// add a leading space for separation. |
|
333 |
return w + 1; |
|
334 |
} |
|
335 |
||
1 | 336 |
public: |
35939
05df7e64ecfc
8149035: Make the full_gc_dump() calls be recorded as part of the GC
brutisso
parents:
35862
diff
changeset
|
337 |
KlassInfoHisto(KlassInfoTable* cit); |
1 | 338 |
~KlassInfoHisto(); |
339 |
void add(KlassInfoEntry* cie); |
|
15437 | 340 |
void print_histo_on(outputStream* st, bool print_class_stats, bool csv_format, const char *columns); |
1 | 341 |
void sort(); |
342 |
}; |
|
343 |
||
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
344 |
#endif // INCLUDE_SERVICES |
1 | 345 |
|
22551 | 346 |
// These declarations are needed since the declaration of KlassInfoTable and |
18025 | 347 |
// KlassInfoClosure are guarded by #if INLCUDE_SERVICES |
348 |
class KlassInfoTable; |
|
349 |
class KlassInfoClosure; |
|
350 |
||
15437 | 351 |
class HeapInspection : public StackObj { |
352 |
bool _csv_format; // "comma separated values" format for spreadsheet. |
|
353 |
bool _print_help; |
|
354 |
bool _print_class_stats; |
|
355 |
const char* _columns; |
|
1 | 356 |
public: |
15437 | 357 |
HeapInspection(bool csv_format, bool print_help, |
358 |
bool print_class_stats, const char *columns) : |
|
359 |
_csv_format(csv_format), _print_help(print_help), |
|
360 |
_print_class_stats(print_class_stats), _columns(columns) {} |
|
18025 | 361 |
void heap_inspection(outputStream* st) NOT_SERVICES_RETURN; |
27677 | 362 |
size_t populate_table(KlassInfoTable* cit, BoolObjectClosure* filter = NULL) NOT_SERVICES_RETURN_(0); |
13975
2f7431485cfa
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
13728
diff
changeset
|
363 |
static void find_instances_at_safepoint(Klass* k, GrowableArray<oop>* result) NOT_SERVICES_RETURN; |
18025 | 364 |
private: |
365 |
void iterate_over_heap(KlassInfoTable* cit, BoolObjectClosure* filter = NULL); |
|
1 | 366 |
}; |
7397 | 367 |
|
368 |
#endif // SHARE_VM_MEMORY_HEAPINSPECTION_HPP |