1 /* |
1 /* |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
22 * |
22 * |
23 */ |
23 */ |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "classfile/classLoaderData.hpp" |
26 #include "classfile/classLoaderData.hpp" |
|
27 #include "memory/heapInspection.hpp" |
27 #include "memory/metadataFactory.hpp" |
28 #include "memory/metadataFactory.hpp" |
28 #include "memory/oopFactory.hpp" |
29 #include "memory/oopFactory.hpp" |
29 #include "oops/annotations.hpp" |
30 #include "oops/annotations.hpp" |
30 #include "oops/instanceKlass.hpp" |
31 #include "oops/instanceKlass.hpp" |
31 #include "utilities/ostream.hpp" |
32 #include "utilities/ostream.hpp" |
112 |
113 |
113 void Annotations::print_value_on(outputStream* st) const { |
114 void Annotations::print_value_on(outputStream* st) const { |
114 st->print("Anotations(" INTPTR_FORMAT ")", this); |
115 st->print("Anotations(" INTPTR_FORMAT ")", this); |
115 } |
116 } |
116 |
117 |
|
118 #if INCLUDE_SERVICES |
|
119 // Size Statistics |
|
120 |
|
121 julong Annotations::count_bytes(Array<AnnotationArray*>* p) { |
|
122 julong bytes = 0; |
|
123 if (p != NULL) { |
|
124 for (int i = 0; i < p->length(); i++) { |
|
125 bytes += KlassSizeStats::count_array(p->at(i)); |
|
126 } |
|
127 bytes += KlassSizeStats::count_array(p); |
|
128 } |
|
129 return bytes; |
|
130 } |
|
131 |
|
132 void Annotations::collect_statistics(KlassSizeStats *sz) const { |
|
133 sz->_annotations_bytes = sz->count(this); |
|
134 sz->_class_annotations_bytes = sz->count(class_annotations()); |
|
135 sz->_fields_annotations_bytes = count_bytes(fields_annotations()); |
|
136 sz->_methods_annotations_bytes = count_bytes(methods_annotations()); |
|
137 sz->_methods_parameter_annotations_bytes = |
|
138 count_bytes(methods_parameter_annotations()); |
|
139 sz->_methods_default_annotations_bytes = |
|
140 count_bytes(methods_default_annotations()); |
|
141 |
|
142 const Annotations* type_anno = type_annotations(); |
|
143 if (type_anno != NULL) { |
|
144 sz->_type_annotations_bytes = sz->count(type_anno); |
|
145 sz->_type_annotations_bytes += sz->count(type_anno->class_annotations()); |
|
146 sz->_type_annotations_bytes += count_bytes(type_anno->fields_annotations()); |
|
147 sz->_type_annotations_bytes += count_bytes(type_anno->methods_annotations()); |
|
148 } |
|
149 |
|
150 sz->_annotations_bytes += |
|
151 sz->_class_annotations_bytes + |
|
152 sz->_fields_annotations_bytes + |
|
153 sz->_methods_annotations_bytes + |
|
154 sz->_methods_parameter_annotations_bytes + |
|
155 sz->_methods_default_annotations_bytes + |
|
156 sz->_type_annotations_bytes; |
|
157 |
|
158 sz->_ro_bytes += sz->_annotations_bytes; |
|
159 } |
|
160 #endif // INCLUDE_SERVICES |
|
161 |
117 #define BULLET " - " |
162 #define BULLET " - " |
118 |
163 |
119 #ifndef PRODUCT |
164 #ifndef PRODUCT |
120 void Annotations::print_on(outputStream* st) const { |
165 void Annotations::print_on(outputStream* st) const { |
121 st->print(BULLET"class_annotations "); class_annotations()->print_value_on(st); |
166 st->print(BULLET"class_annotations "); class_annotations()->print_value_on(st); |