Skip to content

Commit 6666dcb

Browse files
committed
8237363: Remove automatic is in heap verification in OopIterateClosure
Reviewed-by: eosterlund, pliden
1 parent fa64477 commit 6666dcb

17 files changed

+34
-92
lines changed

src/hotspot/share/gc/g1/heapRegion.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,6 @@ class G1VerificationClosure : public BasicOopIterateClosure {
516516
obj->print_on(out);
517517
#endif // PRODUCT
518518
}
519-
520-
// This closure provides its own oop verification code.
521-
debug_only(virtual bool should_verify_oops() { return false; })
522519
};
523520

524521
class VerifyLiveClosure : public G1VerificationClosure {
@@ -655,9 +652,6 @@ class G1Mux2Closure : public BasicOopIterateClosure {
655652
}
656653
virtual inline void do_oop(oop* p) { do_oop_work(p); }
657654
virtual inline void do_oop(narrowOop* p) { do_oop_work(p); }
658-
659-
// This closure provides its own oop verification code.
660-
debug_only(virtual bool should_verify_oops() { return false; })
661655
};
662656

663657
void HeapRegion::verify(VerifyOption vo,

src/hotspot/share/gc/parallel/psCompactionManager.inline.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ class PCMarkAndPushClosure: public OopClosure {
4747
template <typename T> void do_oop_nv(T* p) { _compaction_manager->mark_and_push(p); }
4848
virtual void do_oop(oop* p) { do_oop_nv(p); }
4949
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
50-
51-
// This closure provides its own oop verification code.
52-
debug_only(virtual bool should_verify_oops() { return false; })
5350
};
5451

5552
class PCIterateMarkAndPushClosure: public MetadataVisitingOopIterateClosure {
@@ -64,9 +61,6 @@ class PCIterateMarkAndPushClosure: public MetadataVisitingOopIterateClosure {
6461

6562
void do_klass_nv(Klass* k) { _compaction_manager->follow_klass(k); }
6663
void do_cld_nv(ClassLoaderData* cld) { _compaction_manager->follow_class_loader(cld); }
67-
68-
// This closure provides its own oop verification code.
69-
debug_only(virtual bool should_verify_oops() { return false; })
7064
};
7165

7266
inline bool ParCompactionManager::steal(int queue_num, oop& t) {

src/hotspot/share/gc/parallel/psParallelCompact.inline.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ class PCAdjustPointerClosure: public BasicOopIterateClosure {
134134
virtual void do_oop(oop* p) { do_oop_nv(p); }
135135
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
136136

137-
// This closure provides its own oop verification code.
138-
debug_only(virtual bool should_verify_oops() { return false; })
139137
virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
140138
private:
141139
ParCompactionManager* _cm;

src/hotspot/share/gc/parallel/psPromotionManager.inline.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ class PSPushContentsClosure: public BasicOopIterateClosure {
9797

9898
virtual void do_oop(oop* p) { do_oop_nv(p); }
9999
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
100-
101-
// Don't use the oop verification code in the oop_oop_iterate framework.
102-
debug_only(virtual bool should_verify_oops() { return false; })
103100
};
104101

105102
//

src/hotspot/share/gc/serial/defNewGeneration.inline.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ inline void DefNewGeneration::KeepAliveClosure::do_oop_work(T* p) {
4545
}
4646
#endif // ASSERT
4747

48-
Devirtualizer::do_oop_no_verify(_cl, p);
48+
Devirtualizer::do_oop(_cl, p);
4949

5050
// Card marking is trickier for weak refs.
5151
// This oop is a 'next' field which was filled in while we
@@ -77,7 +77,7 @@ inline void DefNewGeneration::FastKeepAliveClosure::do_oop_work(T* p) {
7777
}
7878
#endif // ASSERT
7979

80-
Devirtualizer::do_oop_no_verify(_cl, p);
80+
Devirtualizer::do_oop(_cl, p);
8181

8282
// Optimized for Defnew generation if it's the youngest generation:
8383
// we set a younger_gen card if we have an older->youngest

src/hotspot/share/gc/serial/markSweep.hpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,6 @@ class AdjustPointerClosure: public BasicOopIterateClosure {
191191
virtual void do_oop(oop* p);
192192
virtual void do_oop(narrowOop* p);
193193
virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
194-
195-
// This closure provides its own oop verification code.
196-
debug_only(virtual bool should_verify_oops() { return false; })
197194
};
198195

199196
class PreservedMark {

src/hotspot/share/gc/z/zHeapIterator.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,6 @@ class ZHeapIteratorOopClosure : public ClaimMetadataVisitingOopIterateClosure {
160160
virtual void do_oop(narrowOop* p) {
161161
ShouldNotReachHere();
162162
}
163-
164-
#ifdef ASSERT
165-
virtual bool should_verify_oops() {
166-
return false;
167-
}
168-
#endif
169163
};
170164

171165
ZHeapIterator::ZHeapIterator(uint nworkers, bool visit_weaks) :

src/hotspot/share/gc/z/zOopClosures.hpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ class ZLoadBarrierOopClosure : public BasicOopIterateClosure {
3131
public:
3232
virtual void do_oop(oop* p);
3333
virtual void do_oop(narrowOop* p);
34-
35-
#ifdef ASSERT
36-
virtual bool should_verify_oops() {
37-
return false;
38-
}
39-
#endif
4034
};
4135

4236
class ZNMethodOopClosure : public OopClosure {
@@ -52,12 +46,6 @@ class ZMarkBarrierOopClosure : public ClaimMetadataVisitingOopIterateClosure {
5246

5347
virtual void do_oop(oop* p);
5448
virtual void do_oop(narrowOop* p);
55-
56-
#ifdef ASSERT
57-
virtual bool should_verify_oops() {
58-
return false;
59-
}
60-
#endif
6149
};
6250

6351
class ZPhantomIsAliveObjectClosure : public BoolObjectClosure {

src/hotspot/share/gc/z/zVerify.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,6 @@ class ZVerifyOopClosure : public ClaimMetadataVisitingOopIterateClosure, public
214214
virtual ReferenceIterationMode reference_iteration_mode() {
215215
return _verify_weaks ? DO_FIELDS : DO_FIELDS_EXCEPT_REFERENT;
216216
}
217-
218-
#ifdef ASSERT
219-
// Verification handled by the closure itself
220-
virtual bool should_verify_oops() {
221-
return false;
222-
}
223-
#endif
224217
};
225218

226219
template <typename RootsIterator>

src/hotspot/share/jfr/leakprofiler/chains/bfsClosure.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class BFSClosure : public BasicOopIterateClosure {
6464

6565
public:
6666
virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS_EXCEPT_REFERENT; }
67-
virtual bool should_verify_oops() { return false; }
6867

6968
BFSClosure(EdgeQueue* edge_queue, EdgeStore* edge_store, BitSet* mark_bits);
7069
void process();

src/hotspot/share/jfr/leakprofiler/chains/dfsClosure.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class DFSClosure : public BasicOopIterateClosure {
5454

5555
public:
5656
virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS_EXCEPT_REFERENT; }
57-
virtual bool should_verify_oops() { return false; }
5857

5958
static void find_leaks_from_edge(EdgeStore* edge_store, BitSet* mark_bits, const Edge* start_edge);
6059
static void find_leaks_from_root_set(EdgeStore* edge_store, BitSet* mark_bits);

src/hotspot/share/memory/filemap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,7 @@ address FileMapInfo::decode_start_address(FileMapRegion* spc, bool with_current_
17371737
size_t offset = spc->mapping_offset();
17381738
narrowOop n = CompressedOops::narrow_oop_cast(offset);
17391739
if (with_current_oop_encoding_mode) {
1740-
return cast_from_oop<address>(CompressedOops::decode_not_null(n));
1740+
return cast_from_oop<address>(CompressedOops::decode_raw_not_null(n));
17411741
} else {
17421742
return cast_from_oop<address>(HeapShared::decode_from_archive(n));
17431743
}

src/hotspot/share/memory/heapShared.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,9 +1150,6 @@ class FindEmbeddedNonNullPointers: public BasicOopIterateClosure {
11501150
FindEmbeddedNonNullPointers(narrowOop* start, BitMap* oopmap)
11511151
: _start(start), _oopmap(oopmap), _num_total_oops(0), _num_null_oops(0) {}
11521152

1153-
virtual bool should_verify_oops(void) {
1154-
return false;
1155-
}
11561153
virtual void do_oop(narrowOop* p) {
11571154
_num_total_oops ++;
11581155
narrowOop v = *p;

src/hotspot/share/memory/iterator.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,6 @@ class OopIterateClosure : public OopClosure {
102102
virtual bool do_metadata() = 0;
103103
virtual void do_klass(Klass* k) = 0;
104104
virtual void do_cld(ClassLoaderData* cld) = 0;
105-
106-
#ifdef ASSERT
107-
// Default verification of each visited oop field.
108-
template <typename T> void verify(T* p);
109-
110-
// Can be used by subclasses to turn off the default verification of oop fields.
111-
virtual bool should_verify_oops() { return true; }
112-
#endif
113105
};
114106

115107
// An OopIterateClosure that can be used when there's no need to visit the Metadata.
@@ -357,7 +349,6 @@ class CompareClosure : public Closure {
357349
// a concrete implementation, otherwise a virtual call is taken.
358350
class Devirtualizer {
359351
public:
360-
template <typename OopClosureType, typename T> static void do_oop_no_verify(OopClosureType* closure, T* p);
361352
template <typename OopClosureType, typename T> static void do_oop(OopClosureType* closure, T* p);
362353
template <typename OopClosureType> static void do_klass(OopClosureType* closure, Klass* k);
363354
template <typename OopClosureType> static void do_cld(OopClosureType* closure, ClassLoaderData* cld);

src/hotspot/share/memory/iterator.inline.hpp

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
#include "classfile/classLoaderData.hpp"
2929
#include "memory/iterator.hpp"
30-
#include "memory/universe.hpp"
3130
#include "oops/access.inline.hpp"
3231
#include "oops/compressedOops.inline.hpp"
3332
#include "oops/klass.hpp"
@@ -52,22 +51,6 @@ inline void ClaimMetadataVisitingOopIterateClosure::do_klass(Klass* k) {
5251
ClaimMetadataVisitingOopIterateClosure::do_cld(cld);
5352
}
5453

55-
#ifdef ASSERT
56-
// This verification is applied to all visited oops.
57-
// The closures can turn is off by overriding should_verify_oops().
58-
template <typename T>
59-
void OopIterateClosure::verify(T* p) {
60-
if (should_verify_oops()) {
61-
T heap_oop = RawAccess<>::oop_load(p);
62-
if (!CompressedOops::is_null(heap_oop)) {
63-
oop o = CompressedOops::decode_not_null(heap_oop);
64-
assert(Universe::heap()->is_in(o),
65-
"should be in closed *p " PTR_FORMAT " " PTR_FORMAT, p2i(p), p2i(o));
66-
}
67-
}
68-
}
69-
#endif
70-
7154
// Implementation of the non-virtual do_oop dispatch.
7255
//
7356
// The same implementation is used for do_metadata, do_klass, and do_cld.
@@ -123,16 +106,9 @@ call_do_oop(void (Receiver::*)(T*), void (Base::*)(T*), OopClosureType* closure,
123106
closure->OopClosureType::do_oop(p);
124107
}
125108

126-
template <typename OopClosureType, typename T>
127-
inline void Devirtualizer::do_oop_no_verify(OopClosureType* closure, T* p) {
128-
call_do_oop<T>(&OopClosureType::do_oop, &OopClosure::do_oop, closure, p);
129-
}
130-
131109
template <typename OopClosureType, typename T>
132110
inline void Devirtualizer::do_oop(OopClosureType* closure, T* p) {
133-
debug_only(closure->verify(p));
134-
135-
do_oop_no_verify(closure, p);
111+
call_do_oop<T>(&OopClosureType::do_oop, &OopClosure::do_oop, closure, p);
136112
}
137113

138114
// Implementation of the non-virtual do_metadata dispatch.

src/hotspot/share/oops/compressedOops.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,18 @@ class CompressedOops : public AllStatic {
119119
static bool is_null(oop v) { return v == NULL; }
120120
static bool is_null(narrowOop v) { return v == narrowOop::null; }
121121

122+
static inline oop decode_raw_not_null(narrowOop v);
122123
static inline oop decode_raw(narrowOop v);
123124
static inline oop decode_not_null(narrowOop v);
124125
static inline oop decode(narrowOop v);
125126
static inline narrowOop encode_not_null(oop v);
126127
static inline narrowOop encode(oop v);
127128

128129
// No conversions needed for these overloads
129-
static oop decode_not_null(oop v) { return v; }
130-
static oop decode(oop v) { return v; }
131-
static narrowOop encode_not_null(narrowOop v) { return v; }
132-
static narrowOop encode(narrowOop v) { return v; }
130+
static inline oop decode_not_null(oop v);
131+
static inline oop decode(oop v);
132+
static inline narrowOop encode_not_null(narrowOop v);
133+
static inline narrowOop encode(narrowOop v);
133134

134135
static inline uint32_t narrow_oop_value(oop o);
135136
static inline uint32_t narrow_oop_value(narrowOop o);

src/hotspot/share/oops/compressedOops.inline.hpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
// offset from the heap base. Saving the check for null can save instructions
4242
// in inner GC loops so these are separated.
4343

44+
inline oop CompressedOops::decode_raw_not_null(narrowOop v) {
45+
assert(!is_null(v), "narrow oop value can never be zero");
46+
return decode_raw(v);
47+
}
48+
4449
inline oop CompressedOops::decode_raw(narrowOop v) {
4550
return (oop)(void*)((uintptr_t)base() + ((uintptr_t)v << shift()));
4651
}
@@ -49,6 +54,7 @@ inline oop CompressedOops::decode_not_null(narrowOop v) {
4954
assert(!is_null(v), "narrow oop value can never be zero");
5055
oop result = decode_raw(v);
5156
assert(is_object_aligned(result), "address not aligned: " INTPTR_FORMAT, p2i((void*) result));
57+
assert(Universe::heap()->is_in(result), "object not in heap " PTR_FORMAT, p2i((void*) result));
5258
return result;
5359
}
5460

@@ -63,14 +69,32 @@ inline narrowOop CompressedOops::encode_not_null(oop v) {
6369
uint64_t pd = (uint64_t)(pointer_delta((void*)v, (void*)base(), 1));
6470
assert(OopEncodingHeapMax > pd, "change encoding max if new encoding");
6571
narrowOop result = narrow_oop_cast(pd >> shift());
66-
assert(decode(result) == v, "reversibility");
72+
assert(decode_raw(result) == v, "reversibility");
6773
return result;
6874
}
6975

7076
inline narrowOop CompressedOops::encode(oop v) {
7177
return is_null(v) ? narrowOop::null : encode_not_null(v);
7278
}
7379

80+
inline oop CompressedOops::decode_not_null(oop v) {
81+
assert(Universe::heap()->is_in(v), "object not in heap " PTR_FORMAT, p2i((void*) v));
82+
return v;
83+
}
84+
85+
inline oop CompressedOops::decode(oop v) {
86+
assert(Universe::heap()->is_in_or_null(v), "object not in heap " PTR_FORMAT, p2i((void*) v));
87+
return v;
88+
}
89+
90+
inline narrowOop CompressedOops::encode_not_null(narrowOop v) {
91+
return v;
92+
}
93+
94+
inline narrowOop CompressedOops::encode(narrowOop v) {
95+
return v;
96+
}
97+
7498
inline uint32_t CompressedOops::narrow_oop_value(oop o) {
7599
return narrow_oop_value(encode(o));
76100
}

0 commit comments

Comments
 (0)