Print this page
Split |
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/vm/memory/heapInspection.hpp
+++ new/src/share/vm/memory/heapInspection.hpp
1 1 /*
2 2 * Copyright 2002-2006 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation.
8 8 *
9 9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 12 * version 2 for more details (a copy is included in the LICENSE file that
13 13 * accompanied this code).
14 14 *
15 15 * You should have received a copy of the GNU General Public License version
16 16 * 2 along with this work; if not, write to the Free Software Foundation,
17 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 18 *
19 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 21 * have any questions.
22 22 *
23 23 */
24 24
25 25 #ifndef SERVICES_KERNEL
26 26
27 27
28 28 // HeapInspection
29 29
30 30 // KlassInfoTable is a bucket hash table that
31 31 // maps klassOops to extra information:
32 32 // instance count and instance word size.
33 33 //
34 34 // A KlassInfoBucket is the head of a link list
35 35 // of KlassInfoEntry's
36 36 //
37 37 // KlassInfoHisto is a growable array of pointers
38 38 // to KlassInfoEntry's and is used to sort
39 39 // the entries.
40 40
41 41 class KlassInfoEntry: public CHeapObj {
42 42 private:
43 43 KlassInfoEntry* _next;
44 44 klassOop _klass;
45 45 long _instance_count;
46 46 size_t _instance_words;
47 47
48 48 public:
49 49 KlassInfoEntry(klassOop k, KlassInfoEntry* next) :
50 50 _klass(k), _instance_count(0), _instance_words(0), _next(next)
51 51 {}
52 52 KlassInfoEntry* next() { return _next; }
53 53 bool is_equal(klassOop k) { return k == _klass; }
54 54 klassOop klass() { return _klass; }
55 55 long count() { return _instance_count; }
56 56 void set_count(long ct) { _instance_count = ct; }
57 57 size_t words() { return _instance_words; }
58 58 void set_words(size_t wds) { _instance_words = wds; }
59 59 int compare(KlassInfoEntry* e1, KlassInfoEntry* e2);
60 60 void print_on(outputStream* st) const;
61 61 };
62 62
63 63 class KlassInfoClosure: public StackObj {
64 64 public:
65 65 // Called for each KlassInfoEntry.
66 66 virtual void do_cinfo(KlassInfoEntry* cie) = 0;
67 67 };
68 68
69 69 class KlassInfoBucket: public CHeapObj {
70 70 private:
71 71 KlassInfoEntry* _list;
72 72 KlassInfoEntry* list() { return _list; }
73 73 void set_list(KlassInfoEntry* l) { _list = l; }
74 74 public:
75 75 KlassInfoEntry* lookup(const klassOop k);
76 76 void initialize() { _list = NULL; }
77 77 void empty();
78 78 void iterate(KlassInfoClosure* cic);
79 79 };
80 80
81 81 class KlassInfoTable: public StackObj {
82 82 private:
83 83 int _size;
84 84
85 85 // An aligned reference address (typically the least
86 86 // address in the perm gen) used for hashing klass
87 87 // objects.
88 88 HeapWord* _ref;
89 89
90 90 KlassInfoBucket* _buckets;
↓ open down ↓ |
90 lines elided |
↑ open up ↑ |
91 91 uint hash(klassOop p);
92 92 KlassInfoEntry* lookup(const klassOop k);
93 93
94 94 public:
95 95 // Table size
96 96 enum {
97 97 cit_size = 20011
98 98 };
99 99 KlassInfoTable(int size, HeapWord* ref);
100 100 ~KlassInfoTable();
101 - void record_instance(const oop obj);
101 + bool record_instance(const oop obj);
102 102 void iterate(KlassInfoClosure* cic);
103 + bool allocation_failed() { return _buckets == NULL; }
103 104 };
104 105
105 106 class KlassInfoHisto : public StackObj {
106 107 private:
107 108 GrowableArray<KlassInfoEntry*>* _elements;
108 109 GrowableArray<KlassInfoEntry*>* elements() const { return _elements; }
109 110 const char* _title;
110 111 const char* title() const { return _title; }
111 112 static int sort_helper(KlassInfoEntry** e1, KlassInfoEntry** e2);
112 113 void print_elements(outputStream* st) const;
113 114 public:
114 115 enum {
115 116 histo_initial_size = 1000
116 117 };
117 118 KlassInfoHisto(const char* title,
118 119 int estimatedCount);
119 120 ~KlassInfoHisto();
120 121 void add(KlassInfoEntry* cie);
121 122 void print_on(outputStream* st) const;
122 123 void sort();
123 124 };
124 125
125 126 #endif // SERVICES_KERNEL
126 127
127 128 class HeapInspection : public AllStatic {
128 129 public:
129 130 static void heap_inspection(outputStream* st) KERNEL_RETURN;
130 131 static void find_instances_at_safepoint(klassOop k, GrowableArray<oop>* result) KERNEL_RETURN;
131 132 };
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX