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_VM_GC_G1_G1HEAPVERIFIER_HPP
26 #define SHARE_VM_GC_G1_G1HEAPVERIFIER_HPP
27
28 #include "gc/g1/heapRegionSet.hpp"
29 #include "memory/allocation.hpp"
30 #include "memory/universe.hpp"
31
32 class G1CollectedHeap;
33
34 class G1HeapVerifier : public CHeapObj<mtGC> {
35 private:
36 G1CollectedHeap* _g1h;
37
38 // verify_region_sets() performs verification over the region
39 // lists. It will be compiled in the product code to be used when
40 // necessary (i.e., during heap verification).
41 void verify_region_sets();
42
43 public:
44
45 G1HeapVerifier(G1CollectedHeap* heap) : _g1h(heap) { }
46
47 // Perform verification.
48
49 // vo == UsePrevMarking -> use "prev" marking information,
50 // vo == UseNextMarking -> use "next" marking information
51 // vo == UseFullMarking -> use "next" marking bitmap but no TAMS
52 //
53 // NOTE: Only the "prev" marking information is guaranteed to be
54 // consistent most of the time, so most calls to this should use
55 // vo == UsePrevMarking.
56 // Currently, there is only one case where this is called with
57 // vo == UseNextMarking, which is to verify the "next" marking
58 // information at the end of remark.
59 // Currently there is only one place where this is called with
60 // vo == UseFullMarking, which is to verify the marking during a
61 // full GC.
62 void verify(VerifyOption vo);
63
64 // verify_region_sets_optional() is planted in the code for
65 // list verification in non-product builds (and it can be enabled in
66 // product builds by defining HEAP_REGION_SET_FORCE_VERIFY to be 1).
67 #if HEAP_REGION_SET_FORCE_VERIFY
68 void verify_region_sets_optional() {
69 verify_region_sets();
70 }
71 #else // HEAP_REGION_SET_FORCE_VERIFY
72 void verify_region_sets_optional() { }
73 #endif // HEAP_REGION_SET_FORCE_VERIFY
74
75 void prepare_for_verify();
76 double verify(bool guard, const char* msg);
77 void verify_before_gc();
78 void verify_after_gc();
79
80 #ifndef PRODUCT
81 // Make sure that the given bitmap has no marked objects in the
82 // range [from,limit). If it does, print an error message and return
83 // false. Otherwise, just return true. bitmap_name should be "prev"
84 // or "next".
85 bool verify_no_bits_over_tams(const char* bitmap_name, const G1CMBitMap* const bitmap,
86 HeapWord* from, HeapWord* limit);
87
88 // Verify that the prev / next bitmap range [tams,end) for the given
89 // region has no marks. Return true if all is well, false if errors
90 // are detected.
91 bool verify_bitmaps(const char* caller, HeapRegion* hr);
92 #endif // PRODUCT
93
94 // If G1VerifyBitmaps is set, verify that the marking bitmaps for
95 // the given region do not have any spurious marks. If errors are
96 // detected, print appropriate error messages and crash.
97 void check_bitmaps(const char* caller, HeapRegion* hr) PRODUCT_RETURN;
98
|
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_VM_GC_G1_G1HEAPVERIFIER_HPP
26 #define SHARE_VM_GC_G1_G1HEAPVERIFIER_HPP
27
28 #include "gc/g1/heapRegionSet.hpp"
29 #include "memory/allocation.hpp"
30 #include "memory/universe.hpp"
31
32 class G1CollectedHeap;
33
34 class G1HeapVerifier : public CHeapObj<mtGC> {
35 private:
36 G1CollectedHeap* _g1h;
37 int _enabled_verification_types;
38
39 // verify_region_sets() performs verification over the region
40 // lists. It will be compiled in the product code to be used when
41 // necessary (i.e., during heap verification).
42 void verify_region_sets();
43
44 public:
45 enum G1VerifyType {
46 G1VerifyYoung = 1,
47 G1VerifyMixed = 2,
48 G1VerifyRemark = 4,
49 G1VerifyCleanup = 8,
50 G1VerifyFull = 16,
51 G1VerifyAll = -1
52 };
53
54 G1HeapVerifier(G1CollectedHeap* heap) : _g1h(heap), _enabled_verification_types(G1VerifyAll) { }
55
56 void parse_verification_type(const char* type);
57 void enable_verification_type(G1VerifyType type);
58 bool should_verify(G1VerifyType type);
59
60 // Perform verification.
61
62 // vo == UsePrevMarking -> use "prev" marking information,
63 // vo == UseNextMarking -> use "next" marking information
64 // vo == UseFullMarking -> use "next" marking bitmap but no TAMS
65 //
66 // NOTE: Only the "prev" marking information is guaranteed to be
67 // consistent most of the time, so most calls to this should use
68 // vo == UsePrevMarking.
69 // Currently, there is only one case where this is called with
70 // vo == UseNextMarking, which is to verify the "next" marking
71 // information at the end of remark.
72 // Currently there is only one place where this is called with
73 // vo == UseFullMarking, which is to verify the marking during a
74 // full GC.
75 void verify(VerifyOption vo);
76
77 // verify_region_sets_optional() is planted in the code for
78 // list verification in non-product builds (and it can be enabled in
79 // product builds by defining HEAP_REGION_SET_FORCE_VERIFY to be 1).
80 #if HEAP_REGION_SET_FORCE_VERIFY
81 void verify_region_sets_optional() {
82 verify_region_sets();
83 }
84 #else // HEAP_REGION_SET_FORCE_VERIFY
85 void verify_region_sets_optional() { }
86 #endif // HEAP_REGION_SET_FORCE_VERIFY
87
88 void prepare_for_verify();
89 double verify(G1VerifyType type, VerifyOption vo, const char* msg);
90 void verify_before_gc(G1VerifyType type);
91 void verify_after_gc(G1VerifyType type);
92
93 #ifndef PRODUCT
94 // Make sure that the given bitmap has no marked objects in the
95 // range [from,limit). If it does, print an error message and return
96 // false. Otherwise, just return true. bitmap_name should be "prev"
97 // or "next".
98 bool verify_no_bits_over_tams(const char* bitmap_name, const G1CMBitMap* const bitmap,
99 HeapWord* from, HeapWord* limit);
100
101 // Verify that the prev / next bitmap range [tams,end) for the given
102 // region has no marks. Return true if all is well, false if errors
103 // are detected.
104 bool verify_bitmaps(const char* caller, HeapRegion* hr);
105 #endif // PRODUCT
106
107 // If G1VerifyBitmaps is set, verify that the marking bitmaps for
108 // the given region do not have any spurious marks. If errors are
109 // detected, print appropriate error messages and crash.
110 void check_bitmaps(const char* caller, HeapRegion* hr) PRODUCT_RETURN;
111
|