8205607: Use oop_iterate instead of oop_iterate_no_header

Reviewed-by: pliden, kbarrett
This commit is contained in:
Stefan Karlsson 2018-06-26 13:54:19 +02:00
parent 35a9c52708
commit 5012044e63
15 changed files with 22 additions and 55 deletions

View File

@ -2435,7 +2435,7 @@ class VerifyAllBlksClosure: public BlkClosure {
} }
}; };
class VerifyAllOopsClosure: public OopClosure { class VerifyAllOopsClosure: public BasicOopIterateClosure {
private: private:
const CMSCollector* _collector; const CMSCollector* _collector;
const CompactibleFreeListSpace* _sp; const CompactibleFreeListSpace* _sp;
@ -2524,9 +2524,8 @@ void CompactibleFreeListSpace::verify() const {
VerifyAllOopsClosure cl(_collector, this, span, past_remark, VerifyAllOopsClosure cl(_collector, this, span, past_remark,
_collector->markBitMap()); _collector->markBitMap());
// Iterate over all oops in the heap. Uses the _no_header version // Iterate over all oops in the heap.
// since we are not interested in following the klass pointers. CMSHeap::heap()->oop_iterate(&cl);
CMSHeap::heap()->oop_iterate_no_header(&cl);
} }
if (VerifyObjectStartArray) { if (VerifyObjectStartArray) {

View File

@ -120,8 +120,7 @@ void G1FullGCMarker::follow_array_chunk(objArrayOop array, int index) {
if (VerifyDuringGC) { if (VerifyDuringGC) {
_verify_closure.set_containing_obj(array); _verify_closure.set_containing_obj(array);
NoHeaderExtendedOopClosure no(&_verify_closure); array->oop_iterate_range(&_verify_closure, beg_index, end_index);
array->oop_iterate_range(&no, beg_index, end_index);
if (_verify_closure.failures()) { if (_verify_closure.failures()) {
assert(false, "Failed"); assert(false, "Failed");
} }
@ -141,7 +140,7 @@ inline void G1FullGCMarker::follow_object(oop obj) {
return; return;
} }
_verify_closure.set_containing_obj(obj); _verify_closure.set_containing_obj(obj);
obj->oop_iterate_no_header(&_verify_closure); obj->oop_iterate(&_verify_closure);
if (_verify_closure.failures()) { if (_verify_closure.failures()) {
log_warning(gc, verify)("Failed after %d", _verify_closure._cc); log_warning(gc, verify)("Failed after %d", _verify_closure._cc);
assert(false, "Failed"); assert(false, "Failed");

View File

@ -84,7 +84,7 @@ public:
virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; } virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; }
}; };
class G1VerifyOopClosure: public OopClosure { class G1VerifyOopClosure: public BasicOopIterateClosure {
private: private:
G1CollectedHeap* _g1h; G1CollectedHeap* _g1h;
bool _failures; bool _failures;

View File

@ -180,7 +180,7 @@ class VerifyCLDClosure: public CLDClosure {
} }
}; };
class VerifyLivenessOopClosure: public OopClosure { class VerifyLivenessOopClosure: public BasicOopIterateClosure {
G1CollectedHeap* _g1h; G1CollectedHeap* _g1h;
VerifyOption _vo; VerifyOption _vo;
public: public:
@ -226,7 +226,7 @@ public:
guarantee(!_g1h->is_obj_dead(o), "Full GC marking and concurrent mark mismatch"); guarantee(!_g1h->is_obj_dead(o), "Full GC marking and concurrent mark mismatch");
} }
o->oop_iterate_no_header(&isLive); o->oop_iterate(&isLive);
if (!_hr->obj_allocated_since_prev_marking(o)) { if (!_hr->obj_allocated_since_prev_marking(o)) {
size_t obj_size = o->size(); // Make sure we don't overflow size_t obj_size = o->size(); // Make sure we don't overflow
_live_bytes += (obj_size * HeapWordSize); _live_bytes += (obj_size * HeapWordSize);
@ -236,7 +236,7 @@ public:
size_t live_bytes() { return _live_bytes; } size_t live_bytes() { return _live_bytes; }
}; };
class VerifyArchiveOopClosure: public OopClosure { class VerifyArchiveOopClosure: public BasicOopIterateClosure {
HeapRegion* _hr; HeapRegion* _hr;
public: public:
VerifyArchiveOopClosure(HeapRegion *hr) VerifyArchiveOopClosure(HeapRegion *hr)
@ -269,7 +269,7 @@ public:
void do_object(oop o) { void do_object(oop o) {
VerifyArchiveOopClosure checkOop(_hr); VerifyArchiveOopClosure checkOop(_hr);
assert(o != NULL, "Should not be here for NULL oops"); assert(o != NULL, "Should not be here for NULL oops");
o->oop_iterate_no_header(&checkOop); o->oop_iterate(&checkOop);
} }
}; };

View File

@ -215,12 +215,12 @@ bool MutableSpace::cas_deallocate(HeapWord *obj, size_t size) {
return Atomic::cmpxchg(obj, top_addr(), expected_top) == expected_top; return Atomic::cmpxchg(obj, top_addr(), expected_top) == expected_top;
} }
void MutableSpace::oop_iterate_no_header(OopClosure* cl) { void MutableSpace::oop_iterate(OopIterateClosure* cl) {
HeapWord* obj_addr = bottom(); HeapWord* obj_addr = bottom();
HeapWord* t = top(); HeapWord* t = top();
// Could call objects iterate, but this is easier. // Could call objects iterate, but this is easier.
while (obj_addr < t) { while (obj_addr < t) {
obj_addr += oop(obj_addr)->oop_iterate_no_header(cl); obj_addr += oop(obj_addr)->oop_iterate_size(cl);
} }
} }

View File

@ -134,7 +134,7 @@ class MutableSpace: public ImmutableSpace {
bool cas_deallocate(HeapWord *obj, size_t size); bool cas_deallocate(HeapWord *obj, size_t size);
// Iteration. // Iteration.
void oop_iterate_no_header(OopClosure* cl); void oop_iterate(OopIterateClosure* cl);
void object_iterate(ObjectClosure* cl); void object_iterate(ObjectClosure* cl);
// Debugging // Debugging

View File

@ -39,7 +39,7 @@
// Checks an individual oop for missing precise marks. Mark // Checks an individual oop for missing precise marks. Mark
// may be either dirty or newgen. // may be either dirty or newgen.
class CheckForUnmarkedOops : public OopClosure { class CheckForUnmarkedOops : public BasicOopIterateClosure {
private: private:
PSYoungGen* _young_gen; PSYoungGen* _young_gen;
PSCardTable* _card_table; PSCardTable* _card_table;
@ -89,7 +89,7 @@ class CheckForUnmarkedObjects : public ObjectClosure {
// fail unless the object head is also unmarked. // fail unless the object head is also unmarked.
virtual void do_object(oop obj) { virtual void do_object(oop obj) {
CheckForUnmarkedOops object_check(_young_gen, _card_table); CheckForUnmarkedOops object_check(_young_gen, _card_table);
obj->oop_iterate_no_header(&object_check); obj->oop_iterate(&object_check);
if (object_check.has_unmarked_oop()) { if (object_check.has_unmarked_oop()) {
guarantee(_card_table->addr_is_marked_imprecise(obj), "Found unmarked young_gen object"); guarantee(_card_table->addr_is_marked_imprecise(obj), "Found unmarked young_gen object");
} }
@ -97,7 +97,7 @@ class CheckForUnmarkedObjects : public ObjectClosure {
}; };
// Checks for precise marking of oops as newgen. // Checks for precise marking of oops as newgen.
class CheckForPreciseMarks : public OopClosure { class CheckForPreciseMarks : public BasicOopIterateClosure {
private: private:
PSYoungGen* _young_gen; PSYoungGen* _young_gen;
PSCardTable* _card_table; PSCardTable* _card_table;
@ -336,7 +336,7 @@ void PSCardTable::verify_all_young_refs_precise() {
CheckForPreciseMarks check(heap->young_gen(), this); CheckForPreciseMarks check(heap->young_gen(), this);
old_gen->oop_iterate_no_header(&check); old_gen->oop_iterate(&check);
verify_all_young_refs_precise_helper(old_gen->object_space()->used_region()); verify_all_young_refs_precise_helper(old_gen->object_space()->used_region());
} }

View File

@ -192,7 +192,7 @@ class PSOldGen : public CHeapObj<mtGC> {
HeapWord* allocate(size_t word_size); HeapWord* allocate(size_t word_size);
// Iteration. // Iteration.
void oop_iterate_no_header(OopClosure* cl) { object_space()->oop_iterate_no_header(cl); } void oop_iterate(OopIterateClosure* cl) { object_space()->oop_iterate(cl); }
void object_iterate(ObjectClosure* cl) { object_space()->object_iterate(cl); } void object_iterate(ObjectClosure* cl) { object_space()->object_iterate(cl); }
// Debugging - do not use for time critical operations // Debugging - do not use for time critical operations

View File

@ -330,7 +330,7 @@ void CardTableRS::invalidate_or_clear(Generation* old_gen) {
} }
class VerifyCleanCardClosure: public OopClosure { class VerifyCleanCardClosure: public BasicOopIterateClosure {
private: private:
HeapWord* _boundary; HeapWord* _boundary;
HeapWord* _begin; HeapWord* _begin;
@ -430,7 +430,7 @@ void CardTableRS::verify_space(Space* s, HeapWord* gen_boundary) {
VerifyCleanCardClosure verify_blk(gen_boundary, begin, end); VerifyCleanCardClosure verify_blk(gen_boundary, begin, end);
for (HeapWord* cur = start_block; cur < end; cur += s->block_size(cur)) { for (HeapWord* cur = start_block; cur < end; cur += s->block_size(cur)) {
if (s->block_is_obj(cur) && s->obj_is_alive(cur)) { if (s->block_is_obj(cur) && s->obj_is_alive(cur)) {
oop(cur)->oop_iterate_no_header(&verify_blk, mr); oop(cur)->oop_iterate(&verify_blk, mr);
} }
} }
} }

View File

@ -1042,11 +1042,6 @@ bool GenCollectedHeap::is_in_partial_collection(const void* p) {
} }
#endif #endif
void GenCollectedHeap::oop_iterate_no_header(OopClosure* cl) {
NoHeaderExtendedOopClosure no_header_cl(cl);
oop_iterate(&no_header_cl);
}
void GenCollectedHeap::oop_iterate(OopIterateClosure* cl) { void GenCollectedHeap::oop_iterate(OopIterateClosure* cl) {
_young_gen->oop_iterate(cl); _young_gen->oop_iterate(cl);
_old_gen->oop_iterate(cl); _old_gen->oop_iterate(cl);

View File

@ -258,7 +258,6 @@ public:
virtual void verify_nmethod(nmethod* nmethod); virtual void verify_nmethod(nmethod* nmethod);
// Iteration functions. // Iteration functions.
void oop_iterate_no_header(OopClosure* cl);
void oop_iterate(OopIterateClosure* cl); void oop_iterate(OopIterateClosure* cl);
void object_iterate(ObjectClosure* cl); void object_iterate(ObjectClosure* cl);
void safe_object_iterate(ObjectClosure* cl); void safe_object_iterate(ObjectClosure* cl);

View File

@ -117,16 +117,6 @@ public:
virtual void do_cld(ClassLoaderData* cld) { ShouldNotReachHere(); } virtual void do_cld(ClassLoaderData* cld) { ShouldNotReachHere(); }
}; };
// Wrapper closure only used to implement oop_iterate_no_header().
class NoHeaderExtendedOopClosure : public BasicOopIterateClosure {
OopClosure* _wrapped_closure;
public:
NoHeaderExtendedOopClosure(OopClosure* cl) : _wrapped_closure(cl) {}
// Warning: this calls the virtual version do_oop in the the wrapped closure.
virtual void do_oop(oop* p) { _wrapped_closure->do_oop(p); }
virtual void do_oop(narrowOop* p) { _wrapped_closure->do_oop(p); }
};
class KlassClosure : public Closure { class KlassClosure : public Closure {
public: public:
virtual void do_klass(Klass* k) = 0; virtual void do_klass(Klass* k) = 0;

View File

@ -3430,7 +3430,7 @@ void InstanceKlass::collect_statistics(KlassSizeStats *sz) const {
// Verification // Verification
class VerifyFieldClosure: public OopClosure { class VerifyFieldClosure: public BasicOopIterateClosure {
protected: protected:
template <class T> void do_oop_work(T* p) { template <class T> void do_oop_work(T* p) {
oop obj = RawAccess<>::oop_load(p); oop obj = RawAccess<>::oop_load(p);
@ -3578,7 +3578,7 @@ void InstanceKlass::verify_on(outputStream* st) {
void InstanceKlass::oop_verify_on(oop obj, outputStream* st) { void InstanceKlass::oop_verify_on(oop obj, outputStream* st) {
Klass::oop_verify_on(obj, st); Klass::oop_verify_on(obj, st);
VerifyFieldClosure blk; VerifyFieldClosure blk;
obj->oop_iterate_no_header(&blk); obj->oop_iterate(&blk);
} }

View File

@ -302,9 +302,6 @@ class oopDesc {
template <typename OopClosureType> template <typename OopClosureType>
inline void oop_iterate_backwards(OopClosureType* cl); inline void oop_iterate_backwards(OopClosureType* cl);
inline int oop_iterate_no_header(OopClosure* bk);
inline int oop_iterate_no_header(OopClosure* bk, MemRegion mr);
inline static bool is_instanceof_or_null(oop obj, Klass* klass); inline static bool is_instanceof_or_null(oop obj, Klass* klass);
// identity hash; returns the identity hash key (computes it if necessary) // identity hash; returns the identity hash key (computes it if necessary)

View File

@ -463,18 +463,6 @@ void oopDesc::oop_iterate_backwards(OopClosureType* cl) {
OopIteratorClosureDispatch::oop_oop_iterate_backwards(cl, this, klass()); OopIteratorClosureDispatch::oop_oop_iterate_backwards(cl, this, klass());
} }
int oopDesc::oop_iterate_no_header(OopClosure* blk) {
// The NoHeaderExtendedOopClosure wraps the OopClosure and proxies all
// the do_oop calls, but turns off all other features in OopIterateClosure.
NoHeaderExtendedOopClosure cl(blk);
return oop_iterate_size(&cl);
}
int oopDesc::oop_iterate_no_header(OopClosure* blk, MemRegion mr) {
NoHeaderExtendedOopClosure cl(blk);
return oop_iterate_size(&cl, mr);
}
bool oopDesc::is_instanceof_or_null(oop obj, Klass* klass) { bool oopDesc::is_instanceof_or_null(oop obj, Klass* klass) {
return obj == NULL || obj->klass()->is_subtype_of(klass); return obj == NULL || obj->klass()->is_subtype_of(klass);
} }