1 /*
2 * Copyright (c) 2017, 2020, Red Hat, Inc. 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_GC_SHENANDOAH_SHENANDOAHVERIFIER_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHVERIFIER_HPP
27
28 #include "gc/shared/markBitMap.hpp"
29 #include "gc/shenandoah/shenandoahRootVerifier.hpp"
30 #include "memory/allocation.hpp"
31 #include "oops/oopsHierarchy.hpp"
32 #include "utilities/stack.hpp"
33
34 class ShenandoahHeap;
35
36 #ifdef _WINDOWS
37 #pragma warning( disable : 4522 )
38 #endif
39
40 class ShenandoahVerifierTask {
41 public:
42 ShenandoahVerifierTask(oop o = nullptr, int idx = 0): _obj(o) { }
43 ShenandoahVerifierTask(oop o, size_t idx): _obj(o) { }
44 // Trivially copyable.
45
46 inline oop obj() const { return _obj; }
47
48 private:
49 oop _obj;
50 };
51
52 typedef Stack<ShenandoahVerifierTask, mtGC> ShenandoahVerifierStack;
53 typedef volatile juint ShenandoahLivenessData;
54
55 class ShenandoahVerifier : public CHeapObj<mtGC> {
56 private:
57 ShenandoahHeap* _heap;
58 MarkBitMap* _verification_bit_map;
59 public:
60 typedef enum {
61 // Disable marked objects verification.
62 _verify_marked_disable,
63
64 // Objects should be marked in "next" bitmap.
65 _verify_marked_incomplete,
66
67 // Objects should be marked in "complete" bitmap.
68 _verify_marked_complete,
69
70 // Objects should be marked in "complete" bitmap, except j.l.r.Reference referents, which
71 // may be dangling after marking but before conc-weakrefs-processing.
72 _verify_marked_complete_except_references
73 } VerifyMarked;
74
75 typedef enum {
76 // Disable forwarded objects verification.
77 _verify_forwarded_disable,
78
79 // Objects should not have forwardees.
80 _verify_forwarded_none,
81
82 // Objects may have forwardees.
83 _verify_forwarded_allow
84 } VerifyForwarded;
85
86 typedef enum {
87 // Disable collection set verification.
88 _verify_cset_disable,
89
90 // Should have no references to cset.
91 _verify_cset_none,
92
105
106 // All objects should belong to live regions,
107 // and liveness data should be accurate
108 _verify_liveness_complete
109 } VerifyLiveness;
110
111 typedef enum {
112 // Disable region verification
113 _verify_regions_disable,
114
115 // No trash regions allowed
116 _verify_regions_notrash,
117
118 // No collection set regions allowed
119 _verify_regions_nocset,
120
121 // No trash and no cset regions allowed
122 _verify_regions_notrash_nocset
123 } VerifyRegions;
124
125 typedef enum {
126 // Disable gc-state verification
127 _verify_gcstate_disable,
128
129 // Nothing is in progress, no forwarded objects
130 _verify_gcstate_stable,
131
132 // Nothing is in progress, no forwarded objects, weak roots handling
133 _verify_gcstate_stable_weakroots,
134
135 // Nothing is in progress, some objects are forwarded
136 _verify_gcstate_forwarded
137 } VerifyGCState;
138
139 struct VerifyOptions {
140 VerifyForwarded _verify_forwarded;
141 VerifyMarked _verify_marked;
142 VerifyCollectionSet _verify_cset;
143 VerifyLiveness _verify_liveness;
144 VerifyRegions _verify_regions;
145 VerifyGCState _verify_gcstate;
146
147 VerifyOptions(VerifyForwarded verify_forwarded,
148 VerifyMarked verify_marked,
149 VerifyCollectionSet verify_collection_set,
150 VerifyLiveness verify_liveness,
151 VerifyRegions verify_regions,
152 VerifyGCState verify_gcstate) :
153 _verify_forwarded(verify_forwarded), _verify_marked(verify_marked),
154 _verify_cset(verify_collection_set),
155 _verify_liveness(verify_liveness), _verify_regions(verify_regions),
156 _verify_gcstate(verify_gcstate) {}
157 };
158
159 private:
160 void verify_at_safepoint(const char *label,
161 VerifyForwarded forwarded,
162 VerifyMarked marked,
163 VerifyCollectionSet cset,
164 VerifyLiveness liveness,
165 VerifyRegions regions,
166 VerifyGCState gcstate);
167
168 public:
169 ShenandoahVerifier(ShenandoahHeap* heap, MarkBitMap* verification_bitmap) :
170 _heap(heap), _verification_bit_map(verification_bitmap) {};
171
172 void verify_before_concmark();
173 void verify_after_concmark();
174 void verify_before_evacuation();
175 void verify_before_updaterefs();
176 void verify_after_updaterefs();
177 void verify_before_fullgc();
178 void verify_after_fullgc();
179 void verify_after_degenerated();
180 void verify_generic(VerifyOption option);
181
182 // Roots should only contain to-space oops
183 void verify_roots_in_to_space();
184
185 void verify_roots_no_forwarded();
186 };
187
188 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHVERIFIER_HPP
|
1 /*
2 * Copyright (c) 2017, 2020, Red Hat, Inc. All rights reserved.
3 * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHVERIFIER_HPP
27 #define SHARE_GC_SHENANDOAH_SHENANDOAHVERIFIER_HPP
28
29 #include "gc/shared/markBitMap.hpp"
30 #include "gc/shenandoah/shenandoahRootVerifier.hpp"
31 #include "memory/allocation.hpp"
32 #include "oops/oopsHierarchy.hpp"
33 #include "utilities/stack.hpp"
34
35 class ShenandoahHeap;
36 class ShenandoahMarkingContext;
37
38 #ifdef _WINDOWS
39 #pragma warning( disable : 4522 )
40 #endif
41
42 class ShenandoahVerifierTask {
43 public:
44 ShenandoahVerifierTask(oop o = nullptr, int idx = 0): _obj(o) { }
45 ShenandoahVerifierTask(oop o, size_t idx): _obj(o) { }
46 // Trivially copyable.
47
48 inline oop obj() const { return _obj; }
49
50 private:
51 oop _obj;
52 };
53
54 typedef Stack<ShenandoahVerifierTask, mtGC> ShenandoahVerifierStack;
55 typedef volatile juint ShenandoahLivenessData;
56
57 class ShenandoahVerifier : public CHeapObj<mtGC> {
58 private:
59 ShenandoahHeap* _heap;
60 MarkBitMap* _verification_bit_map;
61 public:
62 typedef enum {
63 // Disable remembered set verification.
64 _verify_remembered_disable,
65
66 // Old objects should be registered and RS cards within *read-only* RS are dirty for all
67 // inter-generational pointers.
68 _verify_remembered_before_marking,
69
70 // Old objects should be registered and RS cards within *read-write* RS are dirty for all
71 // inter-generational pointers.
72 _verify_remembered_before_updating_references,
73
74 // Old objects should be registered and RS cards within *read-write* RS are dirty for all
75 // inter-generational pointers. Differs from previous verification modes by using top instead
76 // of update watermark and not using the marking context.
77 _verify_remembered_after_full_gc
78 } VerifyRememberedSet;
79
80 typedef enum {
81 // Disable marked objects verification.
82 _verify_marked_disable,
83
84 // Objects should be marked in "next" bitmap.
85 _verify_marked_incomplete,
86
87 // Objects should be marked in "complete" bitmap.
88 _verify_marked_complete,
89
90 // Objects should be marked in "complete" bitmap, except j.l.r.Reference referents, which
91 // may be dangling after marking but before conc-weakrefs-processing.
92 _verify_marked_complete_except_references,
93
94 // Objects should be marked in "complete" bitmap, except j.l.r.Reference referents, which
95 // may be dangling after marking but before conc-weakrefs-processing. All SATB buffers must
96 // be empty.
97 _verify_marked_complete_satb_empty,
98 } VerifyMarked;
99
100 typedef enum {
101 // Disable forwarded objects verification.
102 _verify_forwarded_disable,
103
104 // Objects should not have forwardees.
105 _verify_forwarded_none,
106
107 // Objects may have forwardees.
108 _verify_forwarded_allow
109 } VerifyForwarded;
110
111 typedef enum {
112 // Disable collection set verification.
113 _verify_cset_disable,
114
115 // Should have no references to cset.
116 _verify_cset_none,
117
130
131 // All objects should belong to live regions,
132 // and liveness data should be accurate
133 _verify_liveness_complete
134 } VerifyLiveness;
135
136 typedef enum {
137 // Disable region verification
138 _verify_regions_disable,
139
140 // No trash regions allowed
141 _verify_regions_notrash,
142
143 // No collection set regions allowed
144 _verify_regions_nocset,
145
146 // No trash and no cset regions allowed
147 _verify_regions_notrash_nocset
148 } VerifyRegions;
149
150 typedef enum {
151 // Disable size verification
152 _verify_size_disable,
153
154 // Enforce exact consistency
155 _verify_size_exact,
156
157 // Expect promote-in-place adjustments: padding inserted to temporarily prevent further allocation in regular regions
158 _verify_size_adjusted_for_padding
159 } VerifySize;
160
161 typedef enum {
162 // Disable gc-state verification
163 _verify_gcstate_disable,
164
165 // Nothing is in progress, no forwarded objects
166 _verify_gcstate_stable,
167
168 // Nothing is in progress, no forwarded objects, weak roots handling
169 _verify_gcstate_stable_weakroots,
170
171 // Nothing is in progress, some objects are forwarded
172 _verify_gcstate_forwarded,
173
174 // Evacuation is done, some objects are forwarded, updating is in progress
175 _verify_gcstate_updating
176 } VerifyGCState;
177
178 struct VerifyOptions {
179 VerifyForwarded _verify_forwarded;
180 VerifyMarked _verify_marked;
181 VerifyCollectionSet _verify_cset;
182 VerifyLiveness _verify_liveness;
183 VerifyRegions _verify_regions;
184 VerifyGCState _verify_gcstate;
185
186 VerifyOptions(VerifyForwarded verify_forwarded,
187 VerifyMarked verify_marked,
188 VerifyCollectionSet verify_collection_set,
189 VerifyLiveness verify_liveness,
190 VerifyRegions verify_regions,
191 VerifyGCState verify_gcstate) :
192 _verify_forwarded(verify_forwarded), _verify_marked(verify_marked),
193 _verify_cset(verify_collection_set),
194 _verify_liveness(verify_liveness), _verify_regions(verify_regions),
195 _verify_gcstate(verify_gcstate) {}
196 };
197
198 private:
199 void verify_at_safepoint(const char* label,
200 VerifyRememberedSet remembered,
201 VerifyForwarded forwarded,
202 VerifyMarked marked,
203 VerifyCollectionSet cset,
204 VerifyLiveness liveness,
205 VerifyRegions regions,
206 VerifySize sizeness,
207 VerifyGCState gcstate);
208
209 public:
210 ShenandoahVerifier(ShenandoahHeap* heap, MarkBitMap* verification_bitmap) :
211 _heap(heap), _verification_bit_map(verification_bitmap) {};
212
213 void verify_before_concmark();
214 void verify_after_concmark();
215 void verify_after_concmark_with_promotions();
216 void verify_before_evacuation();
217 void verify_before_updaterefs();
218 void verify_after_updaterefs();
219 void verify_before_fullgc();
220 void verify_after_fullgc();
221 void verify_after_degenerated();
222 void verify_generic(VerifyOption option);
223
224 // Roots should only contain to-space oops
225 void verify_roots_in_to_space();
226 void verify_roots_no_forwarded();
227
228 // Check that generation usages are accurate before rebuilding free set
229 void verify_before_rebuilding_free_set();
230 private:
231 template<typename Scanner>
232 void help_verify_region_rem_set(Scanner* scanner, ShenandoahHeapRegion* r, ShenandoahMarkingContext* ctx,
233 HeapWord* update_watermark, const char* message);
234
235 void verify_rem_set_before_mark();
236 void verify_rem_set_before_update_ref();
237 void verify_rem_set_after_full_gc();
238
239 ShenandoahMarkingContext* get_marking_context_for_old();
240 };
241
242 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHVERIFIER_HPP
|