Mercurial > hg > graal-compiler
annotate src/share/vm/memory/heapInspection.hpp @ 8002:8391fdd36e1f
Merge
author | dlong |
---|---|
date | Sun, 27 Jan 2013 01:07:09 -0800 |
parents | db9981fd3124 |
children | 3c9bc17b9403 |
rev | line source |
---|---|
0 | 1 /* |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
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 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_MEMORY_HEAPINSPECTION_HPP |
26 #define SHARE_VM_MEMORY_HEAPINSPECTION_HPP | |
27 | |
28 #include "memory/allocation.inline.hpp" | |
29 #include "oops/oop.inline.hpp" | |
8001
db9981fd3124
8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents:
6854
diff
changeset
|
30 #include "utilities/macros.hpp" |
1972 | 31 |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
32 #if INCLUDE_SERVICES |
0 | 33 |
34 | |
35 // HeapInspection | |
36 | |
37 // KlassInfoTable is a bucket hash table that | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
38 // maps Klass*s to extra information: |
0 | 39 // instance count and instance word size. |
40 // | |
41 // A KlassInfoBucket is the head of a link list | |
42 // of KlassInfoEntry's | |
43 // | |
44 // KlassInfoHisto is a growable array of pointers | |
45 // to KlassInfoEntry's and is used to sort | |
46 // the entries. | |
47 | |
6197 | 48 class KlassInfoEntry: public CHeapObj<mtInternal> { |
0 | 49 private: |
50 KlassInfoEntry* _next; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
51 Klass* _klass; |
0 | 52 long _instance_count; |
53 size_t _instance_words; | |
54 | |
55 public: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
56 KlassInfoEntry(Klass* k, KlassInfoEntry* next) : |
0 | 57 _klass(k), _instance_count(0), _instance_words(0), _next(next) |
58 {} | |
59 KlassInfoEntry* next() { return _next; } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
60 bool is_equal(Klass* k) { return k == _klass; } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
61 Klass* klass() { return _klass; } |
0 | 62 long count() { return _instance_count; } |
63 void set_count(long ct) { _instance_count = ct; } | |
64 size_t words() { return _instance_words; } | |
65 void set_words(size_t wds) { _instance_words = wds; } | |
66 int compare(KlassInfoEntry* e1, KlassInfoEntry* e2); | |
67 void print_on(outputStream* st) const; | |
68 }; | |
69 | |
70 class KlassInfoClosure: public StackObj { | |
71 public: | |
72 // Called for each KlassInfoEntry. | |
73 virtual void do_cinfo(KlassInfoEntry* cie) = 0; | |
74 }; | |
75 | |
6197 | 76 class KlassInfoBucket: public CHeapObj<mtInternal> { |
0 | 77 private: |
78 KlassInfoEntry* _list; | |
79 KlassInfoEntry* list() { return _list; } | |
80 void set_list(KlassInfoEntry* l) { _list = l; } | |
81 public: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
82 KlassInfoEntry* lookup(Klass* const k); |
0 | 83 void initialize() { _list = NULL; } |
84 void empty(); | |
85 void iterate(KlassInfoClosure* cic); | |
86 }; | |
87 | |
88 class KlassInfoTable: public StackObj { | |
89 private: | |
90 int _size; | |
91 | |
92 // An aligned reference address (typically the least | |
93 // address in the perm gen) used for hashing klass | |
94 // objects. | |
95 HeapWord* _ref; | |
96 | |
97 KlassInfoBucket* _buckets; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
98 uint hash(Klass* p); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6197
diff
changeset
|
99 KlassInfoEntry* lookup(Klass* const k); |
0 | 100 |
101 public: | |
102 // Table size | |
103 enum { | |
104 cit_size = 20011 | |
105 }; | |
106 KlassInfoTable(int size, HeapWord* ref); | |
107 ~KlassInfoTable(); | |
11
3c1dbcaaab1d
6621728: Heap inspection should not crash in the face of C-heap exhaustion
ysr
parents:
0
diff
changeset
|
108 bool record_instance(const oop obj); |
0 | 109 void iterate(KlassInfoClosure* cic); |
11
3c1dbcaaab1d
6621728: Heap inspection should not crash in the face of C-heap exhaustion
ysr
parents:
0
diff
changeset
|
110 bool allocation_failed() { return _buckets == NULL; } |
0 | 111 }; |
112 | |
113 class KlassInfoHisto : public StackObj { | |
114 private: | |
115 GrowableArray<KlassInfoEntry*>* _elements; | |
116 GrowableArray<KlassInfoEntry*>* elements() const { return _elements; } | |
117 const char* _title; | |
118 const char* title() const { return _title; } | |
119 static int sort_helper(KlassInfoEntry** e1, KlassInfoEntry** e2); | |
120 void print_elements(outputStream* st) const; | |
121 public: | |
122 enum { | |
123 histo_initial_size = 1000 | |
124 }; | |
125 KlassInfoHisto(const char* title, | |
126 int estimatedCount); | |
127 ~KlassInfoHisto(); | |
128 void add(KlassInfoEntry* cie); | |
129 void print_on(outputStream* st) const; | |
130 void sort(); | |
131 }; | |
132 | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
133 #endif // INCLUDE_SERVICES |
0 | 134 |
135 class HeapInspection : public AllStatic { | |
136 public: | |
6854
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
137 static void heap_inspection(outputStream* st, bool need_prologue) NOT_SERVICES_RETURN; |
fb19af007ffc
7189254: Change makefiles for more flexibility to override defaults
jprovino
parents:
6725
diff
changeset
|
138 static void find_instances_at_safepoint(Klass* k, GrowableArray<oop>* result) NOT_SERVICES_RETURN; |
0 | 139 }; |
1972 | 140 |
141 #endif // SHARE_VM_MEMORY_HEAPINSPECTION_HPP |