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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoaderData.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "gc/shared/collectedHeap.hpp"
29 #include "gc/shared/genCollectedHeap.hpp"
30 #include "memory/heapInspection.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "oops/oop.inline.hpp"
33 #include "runtime/os.hpp"
34 #include "utilities/globalDefinitions.hpp"
35 #include "utilities/macros.hpp"
36 #include "utilities/stack.inline.hpp"
37 #if INCLUDE_ALL_GCS
38 #include "gc/parallel/parallelScavengeHeap.hpp"
39 #endif // INCLUDE_ALL_GCS
40
41 // HeapInspection
42
43 inline KlassInfoEntry::~KlassInfoEntry() {
44 if (_subclasses != NULL) {
45 delete _subclasses;
46 }
47 }
48
49 inline void KlassInfoEntry::add_subclass(KlassInfoEntry* cie) {
50 if (_subclasses == NULL) {
51 _subclasses = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<KlassInfoEntry*>(4, true);
52 }
53 _subclasses->append(cie);
54 }
55
56 int KlassInfoEntry::compare(KlassInfoEntry* e1, KlassInfoEntry* e2) {
57 if(e1->_instance_words > e2->_instance_words) {
58 return -1;
59 } else if(e1->_instance_words < e2->_instance_words) {
60 return 1;
61 }
|
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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoaderData.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "gc/shared/collectedHeap.hpp"
29 #include "gc/shared/genCollectedHeap.hpp"
30 #include "memory/heapInspection.hpp"
31 #include "memory/resourceArea.hpp"
32 #include "oops/oop.inline.hpp"
33 #include "runtime/os.hpp"
34 #include "utilities/globalDefinitions.hpp"
35 #include "utilities/macros.hpp"
36 #include "utilities/stack.inline.hpp"
37 #if INCLUDE_ALL_GCS
38 #include "gc/parallel/parallelScavengeHeap.hpp"
39 #endif // INCLUDE_ALL_GCS
40
41 // HeapInspection
42
43 int KlassSizeStats::count(oop x) {
44 return (HeapWordSize * (((x) != NULL) ? (x)->size() : 0));
45 }
46
47 int KlassSizeStats::count_array(objArrayOop x) {
48 return (HeapWordSize * (((x) != NULL) ? (x)->size() : 0));
49 }
50
51 inline KlassInfoEntry::~KlassInfoEntry() {
52 if (_subclasses != NULL) {
53 delete _subclasses;
54 }
55 }
56
57 inline void KlassInfoEntry::add_subclass(KlassInfoEntry* cie) {
58 if (_subclasses == NULL) {
59 _subclasses = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<KlassInfoEntry*>(4, true);
60 }
61 _subclasses->append(cie);
62 }
63
64 int KlassInfoEntry::compare(KlassInfoEntry* e1, KlassInfoEntry* e2) {
65 if(e1->_instance_words > e2->_instance_words) {
66 return -1;
67 } else if(e1->_instance_words < e2->_instance_words) {
68 return 1;
69 }
|