1 /*
2 * Copyright (c) 2022, 2023, 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 #ifndef SHARE_CDS_CDSHEAPVERIFIER_HPP
26 #define SHARE_CDS_CDSHEAPVERIFIER_HPP
27
28 #include "cds/heapShared.hpp"
29 #include "memory/iterator.hpp"
30 #include "utilities/growableArray.hpp"
31 #include "utilities/resourceHash.hpp"
32
33 class InstanceKlass;
34 class Symbol;
35
36 #if INCLUDE_CDS_JAVA_HEAP
37
38 class CDSHeapVerifier : public KlassClosure {
39 class CheckStaticFields;
40 class TraceFields;
41
42 int _archived_objs;
43 int _problems;
44
45 struct StaticFieldInfo {
46 InstanceKlass* _holder;
47 Symbol* _name;
48 };
49
63 const char** find_exclusion(InstanceKlass* ik) {
64 for (int i = 0; i < _exclusions.length(); i++) {
65 const char** excl = _exclusions.at(i);
66 if (ik->name()->equals(excl[0])) {
67 return &excl[1];
68 }
69 }
70 return nullptr;
71 }
72 static int trace_to_root(outputStream* st, oop orig_obj, oop orig_field, HeapShared::CachedOopInfo* p);
73
74 CDSHeapVerifier();
75 ~CDSHeapVerifier();
76
77 public:
78
79 // Overrides KlassClosure::do_klass()
80 virtual void do_klass(Klass* k);
81
82 // For ResourceHashtable::iterate()
83 inline bool do_entry(oop& orig_obj, HeapShared::CachedOopInfo& value);
84
85 static void verify();
86
87 static void trace_to_root(outputStream* st, oop orig_obj);
88 };
89
90 #endif // INCLUDE_CDS_JAVA_HEAP
91 #endif // SHARE_CDS_CDSHEAPVERIFIER_HPP
|
1 /*
2 * Copyright (c) 2022, 2025, 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 #ifndef SHARE_CDS_CDSHEAPVERIFIER_HPP
26 #define SHARE_CDS_CDSHEAPVERIFIER_HPP
27
28 #include "cds/heapShared.hpp"
29 #include "memory/iterator.hpp"
30 #include "oops/oopHandle.hpp"
31 #include "utilities/growableArray.hpp"
32 #include "utilities/resourceHash.hpp"
33
34 class InstanceKlass;
35 class Symbol;
36
37 #if INCLUDE_CDS_JAVA_HEAP
38
39 class CDSHeapVerifier : public KlassClosure {
40 class CheckStaticFields;
41 class TraceFields;
42
43 int _archived_objs;
44 int _problems;
45
46 struct StaticFieldInfo {
47 InstanceKlass* _holder;
48 Symbol* _name;
49 };
50
64 const char** find_exclusion(InstanceKlass* ik) {
65 for (int i = 0; i < _exclusions.length(); i++) {
66 const char** excl = _exclusions.at(i);
67 if (ik->name()->equals(excl[0])) {
68 return &excl[1];
69 }
70 }
71 return nullptr;
72 }
73 static int trace_to_root(outputStream* st, oop orig_obj, oop orig_field, HeapShared::CachedOopInfo* p);
74
75 CDSHeapVerifier();
76 ~CDSHeapVerifier();
77
78 public:
79
80 // Overrides KlassClosure::do_klass()
81 virtual void do_klass(Klass* k);
82
83 // For ResourceHashtable::iterate()
84 inline bool do_entry(OopHandle& orig_obj, HeapShared::CachedOopInfo& value);
85
86 static void verify();
87
88 static void trace_to_root(outputStream* st, oop orig_obj);
89 };
90
91 #endif // INCLUDE_CDS_JAVA_HEAP
92 #endif // SHARE_CDS_CDSHEAPVERIFIER_HPP
|