annotate src/share/vm/memory/classify.cpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children 3582bf76420e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 2003, 2010, 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: 1142
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1142
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: 1142
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 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "memory/classify.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 const char* ClassifyObjectClosure::object_type_name[number_object_types] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
31 "unknown",
a61af66fc99e Initial load
duke
parents:
diff changeset
32 "instance",
a61af66fc99e Initial load
duke
parents:
diff changeset
33 "instanceRef",
a61af66fc99e Initial load
duke
parents:
diff changeset
34 "objArray",
a61af66fc99e Initial load
duke
parents:
diff changeset
35 "symbol",
a61af66fc99e Initial load
duke
parents:
diff changeset
36 "klass",
a61af66fc99e Initial load
duke
parents:
diff changeset
37 "instanceKlass",
a61af66fc99e Initial load
duke
parents:
diff changeset
38 "method",
a61af66fc99e Initial load
duke
parents:
diff changeset
39 "constMethod",
a61af66fc99e Initial load
duke
parents:
diff changeset
40 "methodData",
a61af66fc99e Initial load
duke
parents:
diff changeset
41 "constantPool",
a61af66fc99e Initial load
duke
parents:
diff changeset
42 "constantPoolCache",
a61af66fc99e Initial load
duke
parents:
diff changeset
43 "typeArray",
a61af66fc99e Initial load
duke
parents:
diff changeset
44 "compiledICHolder"
a61af66fc99e Initial load
duke
parents:
diff changeset
45 };
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 object_type ClassifyObjectClosure::classify_object(oop obj, bool count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 object_type type = unknown_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 Klass* k = obj->blueprint();
a61af66fc99e Initial load
duke
parents:
diff changeset
52
1142
4ce7240d622c 6914300: ciEnv should export all well known classes
never
parents: 0
diff changeset
53 if (k->as_klassOop() == SystemDictionary::Object_klass()) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
54 tty->print_cr("Found the class!");
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 if (count) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 k->set_alloc_count(k->alloc_count() + 1);
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 if (obj->is_instance()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 if (k->oop_is_instanceRef()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 type = instanceRef_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 type = instance_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 } else if (obj->is_typeArray()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
68 type = typeArray_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 } else if (obj->is_objArray()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 type = objArray_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 } else if (obj->is_symbol()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 type = symbol_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 } else if (obj->is_klass()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 Klass* k = ((klassOop)obj)->klass_part();
a61af66fc99e Initial load
duke
parents:
diff changeset
75 if (k->oop_is_instance()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 type = instanceKlass_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 type = klass_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 } else if (obj->is_method()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 type = method_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 } else if (obj->is_constMethod()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 type = constMethod_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 } else if (obj->is_methodData()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
86 } else if (obj->is_constantPool()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 type = constantPool_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 } else if (obj->is_constantPoolCache()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 type = constantPoolCache_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 } else if (obj->is_compiledICHolder()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 type = compiledICHolder_type;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 ShouldNotReachHere();
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 assert(type != unknown_type, "found object of unknown type.");
a61af66fc99e Initial load
duke
parents:
diff changeset
97 return type;
a61af66fc99e Initial load
duke
parents:
diff changeset
98 }
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 void ClassifyObjectClosure::reset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 for (int i = 0; i < number_object_types; ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 object_count[i] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 object_size[i] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 total_object_count = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 total_object_size = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 void ClassifyObjectClosure::do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 int i = classify_object(obj, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 ++object_count[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
114 ++total_object_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 size_t size = obj->size() * HeapWordSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
116 object_size[i] += size;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 total_object_size += size;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 size_t ClassifyObjectClosure::print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
122 int num_objects = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 size_t size_objects = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 for (int i = 0; i < number_object_types; ++i) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 if (object_count[i] != 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 tty->print_cr("%8d %-22s (%8d bytes, %5.2f bytes/object)",
a61af66fc99e Initial load
duke
parents:
diff changeset
127 object_count[i], object_type_name[i], object_size[i],
a61af66fc99e Initial load
duke
parents:
diff changeset
128 (float)object_size[i]/(float)object_count[i]);
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 num_objects += object_count[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
131 size_objects += object_size[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 assert(num_objects == total_object_count, "Object count mismatch!");
a61af66fc99e Initial load
duke
parents:
diff changeset
134 assert(size_objects == total_object_size, "Object size mismatch!");
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 tty->print_cr(" Total: %d objects, %d bytes", total_object_count,
a61af66fc99e Initial load
duke
parents:
diff changeset
137 total_object_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
138 return total_object_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 void ClassifyInstanceKlassClosure::do_object(oop obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
143 int type = classify_object(obj, false);
a61af66fc99e Initial load
duke
parents:
diff changeset
144 if (type == instanceKlass_type || type == klass_type) {
a61af66fc99e Initial load
duke
parents:
diff changeset
145 Klass* k = ((klassOop)obj)->klass_part();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 if (k->alloc_count() > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
148 const char *name;
a61af66fc99e Initial load
duke
parents:
diff changeset
149 if (k->name() == NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 if (obj == Universe::klassKlassObj()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
152 name = "_klassKlassObj";
a61af66fc99e Initial load
duke
parents:
diff changeset
153 } else if (obj == Universe::arrayKlassKlassObj()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
154 name = "_arrayKlassKlassObj";
a61af66fc99e Initial load
duke
parents:
diff changeset
155 } else if (obj == Universe::objArrayKlassKlassObj()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 name = "_objArrayKlassKlassObj";
a61af66fc99e Initial load
duke
parents:
diff changeset
157 } else if (obj == Universe::typeArrayKlassKlassObj()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
158 name = "_typeArrayKlassKlassObj";
a61af66fc99e Initial load
duke
parents:
diff changeset
159 } else if (obj == Universe::instanceKlassKlassObj()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
160 name = "_instanceKlassKlassObj";
a61af66fc99e Initial load
duke
parents:
diff changeset
161 } else if (obj == Universe::symbolKlassObj()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 name = "_symbolKlassObj";
a61af66fc99e Initial load
duke
parents:
diff changeset
163 } else if (obj == Universe::methodKlassObj()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 name = "_methodKlassObj";
a61af66fc99e Initial load
duke
parents:
diff changeset
165 } else if (obj == Universe::constMethodKlassObj()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
166 name = "_constMethodKlassObj";
a61af66fc99e Initial load
duke
parents:
diff changeset
167 } else if (obj == Universe::constantPoolKlassObj()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 name = "_constantPoolKlassObj";
a61af66fc99e Initial load
duke
parents:
diff changeset
169 } else if (obj == Universe::constantPoolCacheKlassObj()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 name = "_constantPoolCacheKlassObj";
a61af66fc99e Initial load
duke
parents:
diff changeset
171 } else if (obj == Universe::compiledICHolderKlassObj()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
172 name = "_compiledICHolderKlassObj";
a61af66fc99e Initial load
duke
parents:
diff changeset
173 } else if (obj == Universe::systemObjArrayKlassObj()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
174 name = "_systemObjArrayKlassObj";
a61af66fc99e Initial load
duke
parents:
diff changeset
175 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 name = "[unnamed]";
a61af66fc99e Initial load
duke
parents:
diff changeset
177 }
a61af66fc99e Initial load
duke
parents:
diff changeset
178 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 name = k->external_name();
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 tty->print_cr("% 8d instances of %s", k->alloc_count(), name);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 }
a61af66fc99e Initial load
duke
parents:
diff changeset
183 total_instances += k->alloc_count();
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 void ClassifyInstanceKlassClosure::print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
189 tty->print_cr(" Total instances: %d.", total_instances);
a61af66fc99e Initial load
duke
parents:
diff changeset
190 }
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 void ClassifyInstanceKlassClosure::reset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 total_instances = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }