1 /*
2 * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
137 "in read-only memory. (This could change with CDS design)") \
138 f(rw_bytes, RWAll, \
139 "Size of all class meta data that must be placed in read/write " \
140 "memory. (This could change with CDS design) ") \
141 f(total_bytes, Total, \
142 "ROAll + RWAll. Note that this does NOT include InstBytes.")
143
144 // Size statistics for a Klass - filled in by Klass::collect_statistics()
145 class KlassSizeStats {
146 public:
147 #define COUNT_KLASS_SIZE_STATS_FIELD(field, name, help) _index_ ## field,
148 #define DECLARE_KLASS_SIZE_STATS_FIELD(field, name, help) julong _ ## field;
149
150 enum {
151 HEAP_INSPECTION_COLUMNS_DO(COUNT_KLASS_SIZE_STATS_FIELD)
152 _num_columns
153 };
154
155 HEAP_INSPECTION_COLUMNS_DO(DECLARE_KLASS_SIZE_STATS_FIELD)
156
157 static int count(oop x) {
158 return (HeapWordSize * (((x) != NULL) ? (x)->size() : 0));
159 }
160
161 static int count_array(objArrayOop x) {
162 return (HeapWordSize * (((x) != NULL) ? (x)->size() : 0));
163 }
164
165 template <class T> static int count(T* x) {
166 return (HeapWordSize * ((x) ? (x)->size() : 0));
167 }
168
169 template <class T> static int count_array(T* x) {
170 if (x == NULL) {
171 return 0;
172 }
173 if (x->length() == 0) {
174 // This is a shared array, e.g., Universe::the_empty_int_array(). Don't
175 // count it to avoid double-counting.
176 return 0;
177 }
178 return HeapWordSize * x->size();
179 }
180 };
181
182
183
|
1 /*
2 * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
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 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
137 "in read-only memory. (This could change with CDS design)") \
138 f(rw_bytes, RWAll, \
139 "Size of all class meta data that must be placed in read/write " \
140 "memory. (This could change with CDS design) ") \
141 f(total_bytes, Total, \
142 "ROAll + RWAll. Note that this does NOT include InstBytes.")
143
144 // Size statistics for a Klass - filled in by Klass::collect_statistics()
145 class KlassSizeStats {
146 public:
147 #define COUNT_KLASS_SIZE_STATS_FIELD(field, name, help) _index_ ## field,
148 #define DECLARE_KLASS_SIZE_STATS_FIELD(field, name, help) julong _ ## field;
149
150 enum {
151 HEAP_INSPECTION_COLUMNS_DO(COUNT_KLASS_SIZE_STATS_FIELD)
152 _num_columns
153 };
154
155 HEAP_INSPECTION_COLUMNS_DO(DECLARE_KLASS_SIZE_STATS_FIELD)
156
157 static int count(oop x);
158
159 static int count_array(objArrayOop x);
160
161 template <class T> static int count(T* x) {
162 return (HeapWordSize * ((x) ? (x)->size() : 0));
163 }
164
165 template <class T> static int count_array(T* x) {
166 if (x == NULL) {
167 return 0;
168 }
169 if (x->length() == 0) {
170 // This is a shared array, e.g., Universe::the_empty_int_array(). Don't
171 // count it to avoid double-counting.
172 return 0;
173 }
174 return HeapWordSize * x->size();
175 }
176 };
177
178
179
|