annotate src/share/vm/memory/heapInspection.hpp @ 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 d2a62e0f25eb
children fb19af007ffc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 615
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 615
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 615
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_MEMORY_HEAPINSPECTION_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_MEMORY_HEAPINSPECTION_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "oops/oop.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31 #ifndef SERVICES_KERNEL
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // HeapInspection
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // KlassInfoTable is a bucket hash table that
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
37 // maps Klass*s to extra information:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // instance count and instance word size.
a61af66fc99e Initial load
duke
parents:
diff changeset
39 //
a61af66fc99e Initial load
duke
parents:
diff changeset
40 // A KlassInfoBucket is the head of a link list
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // of KlassInfoEntry's
a61af66fc99e Initial load
duke
parents:
diff changeset
42 //
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // KlassInfoHisto is a growable array of pointers
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // to KlassInfoEntry's and is used to sort
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // the entries.
a61af66fc99e Initial load
duke
parents:
diff changeset
46
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
47 class KlassInfoEntry: public CHeapObj<mtInternal> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
48 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
49 KlassInfoEntry* _next;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
50 Klass* _klass;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
51 long _instance_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 size_t _instance_words;
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 public:
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
55 KlassInfoEntry(Klass* k, KlassInfoEntry* next) :
0
a61af66fc99e Initial load
duke
parents:
diff changeset
56 _klass(k), _instance_count(0), _instance_words(0), _next(next)
a61af66fc99e Initial load
duke
parents:
diff changeset
57 {}
a61af66fc99e Initial load
duke
parents:
diff changeset
58 KlassInfoEntry* next() { return _next; }
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
59 bool is_equal(Klass* k) { return k == _klass; }
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
60 Klass* klass() { return _klass; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
61 long count() { return _instance_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 void set_count(long ct) { _instance_count = ct; }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 size_t words() { return _instance_words; }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 void set_words(size_t wds) { _instance_words = wds; }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 int compare(KlassInfoEntry* e1, KlassInfoEntry* e2);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 void print_on(outputStream* st) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 };
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 class KlassInfoClosure: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // Called for each KlassInfoEntry.
a61af66fc99e Initial load
duke
parents:
diff changeset
72 virtual void do_cinfo(KlassInfoEntry* cie) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 };
a61af66fc99e Initial load
duke
parents:
diff changeset
74
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 1972
diff changeset
75 class KlassInfoBucket: public CHeapObj<mtInternal> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
77 KlassInfoEntry* _list;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 KlassInfoEntry* list() { return _list; }
a61af66fc99e Initial load
duke
parents:
diff changeset
79 void set_list(KlassInfoEntry* l) { _list = l; }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 public:
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
81 KlassInfoEntry* lookup(Klass* const k);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
82 void initialize() { _list = NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 void empty();
a61af66fc99e Initial load
duke
parents:
diff changeset
84 void iterate(KlassInfoClosure* cic);
a61af66fc99e Initial load
duke
parents:
diff changeset
85 };
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 class KlassInfoTable: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
89 int _size;
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // An aligned reference address (typically the least
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // address in the perm gen) used for hashing klass
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
94 HeapWord* _ref;
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 KlassInfoBucket* _buckets;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
97 uint hash(Klass* p);
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
98 KlassInfoEntry* lookup(Klass* const k);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // Table size
a61af66fc99e Initial load
duke
parents:
diff changeset
102 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 cit_size = 20011
a61af66fc99e Initial load
duke
parents:
diff changeset
104 };
a61af66fc99e Initial load
duke
parents:
diff changeset
105 KlassInfoTable(int size, HeapWord* ref);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 ~KlassInfoTable();
11
3c1dbcaaab1d 6621728: Heap inspection should not crash in the face of C-heap exhaustion
ysr
parents: 0
diff changeset
107 bool record_instance(const oop obj);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
108 void iterate(KlassInfoClosure* cic);
11
3c1dbcaaab1d 6621728: Heap inspection should not crash in the face of C-heap exhaustion
ysr
parents: 0
diff changeset
109 bool allocation_failed() { return _buckets == NULL; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
110 };
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 class KlassInfoHisto : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
114 GrowableArray<KlassInfoEntry*>* _elements;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 GrowableArray<KlassInfoEntry*>* elements() const { return _elements; }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 const char* _title;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 const char* title() const { return _title; }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 static int sort_helper(KlassInfoEntry** e1, KlassInfoEntry** e2);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 void print_elements(outputStream* st) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
120 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
121 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 histo_initial_size = 1000
a61af66fc99e Initial load
duke
parents:
diff changeset
123 };
a61af66fc99e Initial load
duke
parents:
diff changeset
124 KlassInfoHisto(const char* title,
a61af66fc99e Initial load
duke
parents:
diff changeset
125 int estimatedCount);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 ~KlassInfoHisto();
a61af66fc99e Initial load
duke
parents:
diff changeset
127 void add(KlassInfoEntry* cie);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 void print_on(outputStream* st) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 void sort();
a61af66fc99e Initial load
duke
parents:
diff changeset
130 };
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 #endif // SERVICES_KERNEL
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 class HeapInspection : public AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 public:
615
c6c601a0f2d6 6797870: Add -XX:+{HeapDump,PrintClassHistogram}{Before,After}FullGC
ysr
parents: 196
diff changeset
136 static void heap_inspection(outputStream* st, bool need_prologue) KERNEL_RETURN;
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6197
diff changeset
137 static void find_instances_at_safepoint(Klass* k, GrowableArray<oop>* result) KERNEL_RETURN;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
138 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
139
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
140 #endif // SHARE_VM_MEMORY_HEAPINSPECTION_HPP