8139341: Hide ExtendedOopClosure::_ref_processor

Make ExtendedOopClosure::_ref_processor private.

Reviewed-by: mgerdin, sjohanss
This commit is contained in:
Kim Barrett 2015-10-16 14:55:09 -04:00
parent de26bc4347
commit 4500c7fac8
7 changed files with 46 additions and 28 deletions

View File

@ -6045,7 +6045,7 @@ MarkRefsIntoClosure::MarkRefsIntoClosure(
_span(span), _span(span),
_bitMap(bitMap) _bitMap(bitMap)
{ {
assert(_ref_processor == NULL, "deliberately left NULL"); assert(ref_processor() == NULL, "deliberately left NULL");
assert(_bitMap->covers(_span), "_bitMap/_span mismatch"); assert(_bitMap->covers(_span), "_bitMap/_span mismatch");
} }
@ -6067,7 +6067,7 @@ Par_MarkRefsIntoClosure::Par_MarkRefsIntoClosure(
_span(span), _span(span),
_bitMap(bitMap) _bitMap(bitMap)
{ {
assert(_ref_processor == NULL, "deliberately left NULL"); assert(ref_processor() == NULL, "deliberately left NULL");
assert(_bitMap->covers(_span), "_bitMap/_span mismatch"); assert(_bitMap->covers(_span), "_bitMap/_span mismatch");
} }
@ -6091,7 +6091,7 @@ MarkRefsIntoVerifyClosure::MarkRefsIntoVerifyClosure(
_verification_bm(verification_bm), _verification_bm(verification_bm),
_cms_bm(cms_bm) _cms_bm(cms_bm)
{ {
assert(_ref_processor == NULL, "deliberately left NULL"); assert(ref_processor() == NULL, "deliberately left NULL");
assert(_verification_bm->covers(_span), "_verification_bm/_span mismatch"); assert(_verification_bm->covers(_span), "_verification_bm/_span mismatch");
} }
@ -6134,8 +6134,9 @@ MarkRefsIntoAndScanClosure::MarkRefsIntoAndScanClosure(MemRegion span,
_concurrent_precleaning(concurrent_precleaning), _concurrent_precleaning(concurrent_precleaning),
_freelistLock(NULL) _freelistLock(NULL)
{ {
_ref_processor = rp; // FIXME: Should initialize in base class constructor.
assert(_ref_processor != NULL, "_ref_processor shouldn't be NULL"); assert(rp != NULL, "ref_processor shouldn't be NULL");
set_ref_processor_internal(rp);
} }
// This closure is used to mark refs into the CMS generation at the // This closure is used to mark refs into the CMS generation at the
@ -6240,8 +6241,9 @@ Par_MarkRefsIntoAndScanClosure::Par_MarkRefsIntoAndScanClosure(
((uint)CMSWorkQueueDrainThreshold * ParallelGCThreads))), ((uint)CMSWorkQueueDrainThreshold * ParallelGCThreads))),
_par_pushAndMarkClosure(collector, span, rp, bit_map, work_queue) _par_pushAndMarkClosure(collector, span, rp, bit_map, work_queue)
{ {
_ref_processor = rp; // FIXME: Should initialize in base class constructor.
assert(_ref_processor != NULL, "_ref_processor shouldn't be NULL"); assert(rp != NULL, "ref_processor shouldn't be NULL");
set_ref_processor_internal(rp);
} }
// This closure is used to mark refs into the CMS generation at the // This closure is used to mark refs into the CMS generation at the
@ -7091,7 +7093,7 @@ PushAndMarkClosure::PushAndMarkClosure(CMSCollector* collector,
_mark_stack(mark_stack), _mark_stack(mark_stack),
_concurrent_precleaning(concurrent_precleaning) _concurrent_precleaning(concurrent_precleaning)
{ {
assert(_ref_processor != NULL, "_ref_processor shouldn't be NULL"); assert(ref_processor() != NULL, "ref_processor shouldn't be NULL");
} }
// Grey object rescan during pre-cleaning and second checkpoint phases -- // Grey object rescan during pre-cleaning and second checkpoint phases --
@ -7162,7 +7164,7 @@ Par_PushAndMarkClosure::Par_PushAndMarkClosure(CMSCollector* collector,
_bit_map(bit_map), _bit_map(bit_map),
_work_queue(work_queue) _work_queue(work_queue)
{ {
assert(_ref_processor != NULL, "_ref_processor shouldn't be NULL"); assert(ref_processor() != NULL, "ref_processor shouldn't be NULL");
} }
void PushAndMarkClosure::do_oop(oop* p) { PushAndMarkClosure::do_oop_work(p); } void PushAndMarkClosure::do_oop(oop* p) { PushAndMarkClosure::do_oop_work(p); }

View File

@ -3084,17 +3084,21 @@ public:
} }
}; };
static ReferenceProcessor* get_cm_oop_closure_ref_processor(G1CollectedHeap* g1h) {
ReferenceProcessor* result = NULL;
if (G1UseConcMarkReferenceProcessing) {
result = g1h->ref_processor_cm();
assert(result != NULL, "should not be NULL");
}
return result;
}
G1CMOopClosure::G1CMOopClosure(G1CollectedHeap* g1h, G1CMOopClosure::G1CMOopClosure(G1CollectedHeap* g1h,
ConcurrentMark* cm, ConcurrentMark* cm,
CMTask* task) CMTask* task)
: _g1h(g1h), _cm(cm), _task(task) { : MetadataAwareOopClosure(get_cm_oop_closure_ref_processor(g1h)),
assert(_ref_processor == NULL, "should be initialized to NULL"); _g1h(g1h), _cm(cm), _task(task)
{ }
if (G1UseConcMarkReferenceProcessing) {
_ref_processor = g1h->ref_processor_cm();
assert(_ref_processor != NULL, "should not be NULL");
}
}
void CMTask::setup_for_region(HeapRegion* hr) { void CMTask::setup_for_region(HeapRegion* hr) {
assert(hr != NULL, assert(hr != NULL,

View File

@ -80,7 +80,9 @@ public:
virtual void do_oop(oop* p) { do_oop_nv(p); } virtual void do_oop(oop* p) { do_oop_nv(p); }
virtual void do_oop(narrowOop* p) { do_oop_nv(p); } virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
void set_ref_processor(ReferenceProcessor* ref_processor) { _ref_processor = ref_processor; } void set_ref_processor(ReferenceProcessor* rp) {
set_ref_processor_internal(rp);
}
}; };
// Add back base class for metadata // Add back base class for metadata
@ -127,7 +129,7 @@ private:
public: public:
G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) : G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
G1ParCopyHelper(g1, par_scan_state) { G1ParCopyHelper(g1, par_scan_state) {
assert(_ref_processor == NULL, "sanity"); assert(ref_processor() == NULL, "sanity");
} }
template <class T> void do_oop_nv(T* p) { do_oop_work(p); } template <class T> void do_oop_nv(T* p) { do_oop_work(p); }

View File

@ -196,7 +196,9 @@ public:
virtual void do_cld(ClassLoaderData* cld); virtual void do_cld(ClassLoaderData* cld);
void do_cld_nv(ClassLoaderData* cld); void do_cld_nv(ClassLoaderData* cld);
void set_ref_processor(ReferenceProcessor* rp) { _ref_processor = rp; } void set_ref_processor(ReferenceProcessor* rp) {
set_ref_processor_internal(rp);
}
}; };
class PreservedMark VALUE_OBJ_CLASS_SPEC { class PreservedMark VALUE_OBJ_CLASS_SPEC {

View File

@ -157,7 +157,7 @@ class FilteringClosure: public ExtendedOopClosure {
} }
public: public:
FilteringClosure(HeapWord* boundary, ExtendedOopClosure* cl) : FilteringClosure(HeapWord* boundary, ExtendedOopClosure* cl) :
ExtendedOopClosure(cl->_ref_processor), _boundary(boundary), ExtendedOopClosure(cl->ref_processor()), _boundary(boundary),
_cl(cl) {} _cl(cl) {}
virtual void do_oop(oop* p); virtual void do_oop(oop* p);
virtual void do_oop(narrowOop* p); virtual void do_oop(narrowOop* p);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -51,10 +51,18 @@ class OopClosure : public Closure {
// This is needed by the GC and is extracted to a separate type to not // This is needed by the GC and is extracted to a separate type to not
// pollute the OopClosure interface. // pollute the OopClosure interface.
class ExtendedOopClosure : public OopClosure { class ExtendedOopClosure : public OopClosure {
public: private:
ReferenceProcessor* _ref_processor; ReferenceProcessor* _ref_processor;
protected:
ExtendedOopClosure(ReferenceProcessor* rp) : _ref_processor(rp) { } ExtendedOopClosure(ReferenceProcessor* rp) : _ref_processor(rp) { }
ExtendedOopClosure() : OopClosure(), _ref_processor(NULL) { } ExtendedOopClosure() : _ref_processor(NULL) { }
~ExtendedOopClosure() { }
void set_ref_processor_internal(ReferenceProcessor* rp) { _ref_processor = rp; }
public:
ReferenceProcessor* ref_processor() const { return _ref_processor; }
// If the do_metadata functions return "true", // If the do_metadata functions return "true",
// we invoke the following when running oop_iterate(): // we invoke the following when running oop_iterate():

View File

@ -43,7 +43,7 @@ void InstanceRefKlass::oop_oop_iterate_ref_processing_specialized(oop obj, OopCl
T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj); T* referent_addr = (T*)java_lang_ref_Reference::referent_addr(obj);
T heap_oop = oopDesc::load_heap_oop(referent_addr); T heap_oop = oopDesc::load_heap_oop(referent_addr);
ReferenceProcessor* rp = closure->_ref_processor; ReferenceProcessor* rp = closure->ref_processor();
if (!oopDesc::is_null(heap_oop)) { if (!oopDesc::is_null(heap_oop)) {
oop referent = oopDesc::decode_heap_oop_not_null(heap_oop); oop referent = oopDesc::decode_heap_oop_not_null(heap_oop);
if (!referent->is_gc_marked() && (rp != NULL) && if (!referent->is_gc_marked() && (rp != NULL) &&