--- old/src/hotspot/share/gc/cms/cmsOopClosures.hpp 2018-04-17 14:39:47.432889655 +0200 +++ new/src/hotspot/share/gc/cms/cmsOopClosures.hpp 2018-04-17 14:39:47.223880614 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -113,7 +113,7 @@ public: PushAndMarkClosure(CMSCollector* collector, MemRegion span, - ReferenceProcessor* rp, + ReferenceDiscoverer* rd, CMSBitMap* bit_map, CMSBitMap* mod_union_table, CMSMarkStack* mark_stack, @@ -141,7 +141,7 @@ public: ParPushAndMarkClosure(CMSCollector* collector, MemRegion span, - ReferenceProcessor* rp, + ReferenceDiscoverer* rd, CMSBitMap* bit_map, OopTaskQueue* work_queue); virtual void do_oop(oop* p); @@ -166,7 +166,7 @@ DO_OOP_WORK_DEFN public: MarkRefsIntoAndScanClosure(MemRegion span, - ReferenceProcessor* rp, + ReferenceDiscoverer* rd, CMSBitMap* bit_map, CMSBitMap* mod_union_table, CMSMarkStack* mark_stack, @@ -204,7 +204,7 @@ public: ParMarkRefsIntoAndScanClosure(CMSCollector* collector, MemRegion span, - ReferenceProcessor* rp, + ReferenceDiscoverer* rd, CMSBitMap* bit_map, OopTaskQueue* work_queue); virtual void do_oop(oop* p); --- old/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp 2018-04-17 14:39:47.765904061 +0200 +++ new/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp 2018-04-17 14:39:47.545894544 +0200 @@ -5823,7 +5823,7 @@ _span(span), _bitMap(bitMap) { - assert(ref_processor() == NULL, "deliberately left NULL"); + assert(ref_discoverer() == NULL, "deliberately left NULL"); assert(_bitMap->covers(_span), "_bitMap/_span mismatch"); } @@ -5845,7 +5845,7 @@ _span(span), _bitMap(bitMap) { - assert(ref_processor() == NULL, "deliberately left NULL"); + assert(ref_discoverer() == NULL, "deliberately left NULL"); assert(_bitMap->covers(_span), "_bitMap/_span mismatch"); } @@ -5869,7 +5869,7 @@ _verification_bm(verification_bm), _cms_bm(cms_bm) { - assert(ref_processor() == NULL, "deliberately left NULL"); + assert(ref_discoverer() == NULL, "deliberately left NULL"); assert(_verification_bm->covers(_span), "_verification_bm/_span mismatch"); } @@ -5898,7 +5898,7 @@ ////////////////////////////////////////////////// MarkRefsIntoAndScanClosure::MarkRefsIntoAndScanClosure(MemRegion span, - ReferenceProcessor* rp, + ReferenceDiscoverer* rd, CMSBitMap* bit_map, CMSBitMap* mod_union_table, CMSMarkStack* mark_stack, @@ -5909,15 +5909,15 @@ _span(span), _bit_map(bit_map), _mark_stack(mark_stack), - _pushAndMarkClosure(collector, span, rp, bit_map, mod_union_table, + _pushAndMarkClosure(collector, span, rd, bit_map, mod_union_table, mark_stack, concurrent_precleaning), _yield(should_yield), _concurrent_precleaning(concurrent_precleaning), _freelistLock(NULL) { // FIXME: Should initialize in base class constructor. - assert(rp != NULL, "ref_processor shouldn't be NULL"); - set_ref_processor_internal(rp); + assert(rd != NULL, "ref_discoverer shouldn't be NULL"); + set_ref_discoverer_internal(rd); } // This closure is used to mark refs into the CMS generation at the @@ -6002,18 +6002,18 @@ // MarkRefsIntoAndScanClosure /////////////////////////////////////////////////////////// ParMarkRefsIntoAndScanClosure::ParMarkRefsIntoAndScanClosure( - CMSCollector* collector, MemRegion span, ReferenceProcessor* rp, + CMSCollector* collector, MemRegion span, ReferenceDiscoverer* rd, CMSBitMap* bit_map, OopTaskQueue* work_queue): _span(span), _bit_map(bit_map), _work_queue(work_queue), _low_water_mark(MIN2((work_queue->max_elems()/4), ((uint)CMSWorkQueueDrainThreshold * ParallelGCThreads))), - _parPushAndMarkClosure(collector, span, rp, bit_map, work_queue) + _parPushAndMarkClosure(collector, span, rd, bit_map, work_queue) { // FIXME: Should initialize in base class constructor. - assert(rp != NULL, "ref_processor shouldn't be NULL"); - set_ref_processor_internal(rp); + assert(rd != NULL, "ref_discoverer shouldn't be NULL"); + set_ref_discoverer_internal(rd); } // This closure is used to mark refs into the CMS generation at the @@ -6840,12 +6840,12 @@ PushAndMarkClosure::PushAndMarkClosure(CMSCollector* collector, MemRegion span, - ReferenceProcessor* rp, + ReferenceDiscoverer* rd, CMSBitMap* bit_map, CMSBitMap* mod_union_table, CMSMarkStack* mark_stack, bool concurrent_precleaning): - MetadataAwareOopClosure(rp), + MetadataAwareOopClosure(rd), _collector(collector), _span(span), _bit_map(bit_map), @@ -6853,7 +6853,7 @@ _mark_stack(mark_stack), _concurrent_precleaning(concurrent_precleaning) { - assert(ref_processor() != NULL, "ref_processor shouldn't be NULL"); + assert(ref_discoverer() != NULL, "ref_discoverer shouldn't be NULL"); } // Grey object rescan during pre-cleaning and second checkpoint phases -- @@ -6914,16 +6914,16 @@ ParPushAndMarkClosure::ParPushAndMarkClosure(CMSCollector* collector, MemRegion span, - ReferenceProcessor* rp, + ReferenceDiscoverer* rd, CMSBitMap* bit_map, OopTaskQueue* work_queue): - MetadataAwareOopClosure(rp), + MetadataAwareOopClosure(rd), _collector(collector), _span(span), _bit_map(bit_map), _work_queue(work_queue) { - assert(ref_processor() != NULL, "ref_processor shouldn't be NULL"); + assert(ref_discoverer() != NULL, "ref_discoverer shouldn't be NULL"); } void PushAndMarkClosure::do_oop(oop* p) { PushAndMarkClosure::do_oop_work(p); } --- old/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2018-04-17 14:39:48.233924307 +0200 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2018-04-17 14:39:48.017914963 +0200 @@ -3127,7 +3127,7 @@ ReferenceProcessor* rp = _g1h->ref_processor_stw(); G1ParScanThreadState* pss = _pss->state_for_worker(worker_id); - pss->set_ref_processor(rp); + pss->set_ref_discoverer(rp); double start_strong_roots_sec = os::elapsedTime(); @@ -3827,7 +3827,7 @@ G1STWIsAliveClosure is_alive(_g1h); G1ParScanThreadState* pss = _pss->state_for_worker(worker_id); - pss->set_ref_processor(NULL); + pss->set_ref_discoverer(NULL); // Keep alive closure. G1CopyingKeepAliveClosure keep_alive(_g1h, pss->closures()->raw_strong_oops(), pss); @@ -3919,7 +3919,7 @@ HandleMark hm; G1ParScanThreadState* pss = _pss->state_for_worker(worker_id); - pss->set_ref_processor(NULL); + pss->set_ref_discoverer(NULL); assert(pss->queue_is_empty(), "both queue and overflow should be empty"); // Is alive closure @@ -4025,7 +4025,7 @@ // Use only a single queue for this PSS. G1ParScanThreadState* pss = per_thread_states->state_for_worker(0); - pss->set_ref_processor(NULL); + pss->set_ref_discoverer(NULL); assert(pss->queue_is_empty(), "pre-condition"); // Keep alive closure. --- old/src/hotspot/share/gc/g1/g1FullGCOopClosures.hpp 2018-04-17 14:39:48.650942346 +0200 +++ new/src/hotspot/share/gc/g1/g1FullGCOopClosures.hpp 2018-04-17 14:39:48.435933045 +0200 @@ -60,7 +60,7 @@ uint _worker_id; public: - G1MarkAndPushClosure(uint worker, G1FullGCMarker* marker, ReferenceProcessor* ref) : + G1MarkAndPushClosure(uint worker, G1FullGCMarker* marker, ReferenceDiscoverer* ref) : _marker(marker), _worker_id(worker), ExtendedOopClosure(ref) { } --- old/src/hotspot/share/gc/g1/g1OopClosures.hpp 2018-04-17 14:39:48.984956795 +0200 +++ new/src/hotspot/share/gc/g1/g1OopClosures.hpp 2018-04-17 14:39:48.771947581 +0200 @@ -96,8 +96,8 @@ virtual void do_oop(oop* p) { do_oop_nv(p); } virtual void do_oop(narrowOop* p) { do_oop_nv(p); } - void set_ref_processor(ReferenceProcessor* rp) { - set_ref_processor_internal(rp); + void set_ref_discoverer(ReferenceDiscoverer* rd) { + set_ref_discoverer_internal(rd); } }; --- old/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp 2018-04-17 14:39:49.318971244 +0200 +++ new/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp 2018-04-17 14:39:49.103961943 +0200 @@ -87,7 +87,7 @@ G1ParScanThreadState(G1CollectedHeap* g1h, uint worker_id, size_t young_cset_length); virtual ~G1ParScanThreadState(); - void set_ref_processor(ReferenceProcessor* rp) { _scanner.set_ref_processor(rp); } + void set_ref_discoverer(ReferenceDiscoverer* rd) { _scanner.set_ref_discoverer(rd); } #ifdef ASSERT bool queue_is_empty() const { return _refs->is_empty(); } --- old/src/hotspot/share/gc/serial/markSweep.cpp 2018-04-17 14:39:49.661986082 +0200 +++ new/src/hotspot/share/gc/serial/markSweep.cpp 2018-04-17 14:39:49.445976738 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -211,7 +211,7 @@ void MarkSweep::set_ref_processor(ReferenceProcessor* rp) { _ref_processor = rp; - mark_and_push_closure.set_ref_processor(_ref_processor); + mark_and_push_closure.set_ref_discoverer(_ref_processor); } AdjustPointerClosure MarkSweep::adjust_pointer_closure; --- old/src/hotspot/share/gc/serial/markSweep.hpp 2018-04-17 14:39:50.007001007 +0200 +++ new/src/hotspot/share/gc/serial/markSweep.hpp 2018-04-17 14:39:49.791991706 +0200 @@ -184,8 +184,8 @@ virtual void do_cld(ClassLoaderData* cld); void do_cld_nv(ClassLoaderData* cld); - void set_ref_processor(ReferenceProcessor* rp) { - set_ref_processor_internal(rp); + void set_ref_discoverer(ReferenceDiscoverer* rd) { + set_ref_discoverer_internal(rd); } }; --- old/src/hotspot/share/gc/shared/genOopClosures.hpp 2018-04-17 14:39:50.325014764 +0200 +++ new/src/hotspot/share/gc/shared/genOopClosures.hpp 2018-04-17 14:39:50.113005593 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -151,7 +151,7 @@ template inline void do_oop_work(T* p); public: FilteringClosure(HeapWord* boundary, ExtendedOopClosure* cl) : - ExtendedOopClosure(cl->ref_processor()), _boundary(boundary), + ExtendedOopClosure(cl->ref_discoverer()), _boundary(boundary), _cl(cl) {} virtual void do_oop(oop* p); virtual void do_oop(narrowOop* p); --- old/src/hotspot/share/gc/shared/referenceProcessor.hpp 2018-04-17 14:39:50.638028304 +0200 +++ new/src/hotspot/share/gc/shared/referenceProcessor.hpp 2018-04-17 14:39:50.426019133 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ #ifndef SHARE_VM_GC_SHARED_REFERENCEPROCESSOR_HPP #define SHARE_VM_GC_SHARED_REFERENCEPROCESSOR_HPP +#include "gc/shared/referenceDiscoverer.hpp" #include "gc/shared/referencePolicy.hpp" #include "gc/shared/referenceProcessorPhaseTimes.hpp" #include "gc/shared/referenceProcessorStats.hpp" @@ -166,7 +167,7 @@ } }; -class ReferenceProcessor : public CHeapObj { +class ReferenceProcessor : public ReferenceDiscoverer { private: size_t total_count(DiscoveredList lists[]) const; @@ -405,7 +406,7 @@ void verify_list(DiscoveredList& ref_list); // Discover a Reference object, using appropriate discovery criteria - bool discover_reference(oop obj, ReferenceType rt); + virtual bool discover_reference(oop obj, ReferenceType rt); // Has discovered references that need handling bool has_discovered_references(); --- old/src/hotspot/share/memory/iterator.hpp 2018-04-17 14:39:50.977042970 +0200 +++ new/src/hotspot/share/memory/iterator.hpp 2018-04-17 14:39:50.762033669 +0200 @@ -31,7 +31,7 @@ class CodeBlob; class nmethod; -class ReferenceProcessor; +class ReferenceDiscoverer; class DataLayout; class KlassClosure; class ClassLoaderData; @@ -60,17 +60,17 @@ // pollute the OopClosure interface. class ExtendedOopClosure : public OopClosure { private: - ReferenceProcessor* _ref_processor; + ReferenceDiscoverer* _ref_discoverer; protected: - ExtendedOopClosure(ReferenceProcessor* rp) : _ref_processor(rp) { } - ExtendedOopClosure() : _ref_processor(NULL) { } + ExtendedOopClosure(ReferenceDiscoverer* rd) : _ref_discoverer(rd) { } + ExtendedOopClosure() : _ref_discoverer(NULL) { } ~ExtendedOopClosure() { } - void set_ref_processor_internal(ReferenceProcessor* rp) { _ref_processor = rp; } + void set_ref_discoverer_internal(ReferenceDiscoverer* rd) { _ref_discoverer = rd; } public: - ReferenceProcessor* ref_processor() const { return _ref_processor; } + ReferenceDiscoverer* ref_discoverer() const { return _ref_discoverer; } // Iteration of InstanceRefKlasses differ depending on the closure, // the below enum describes the different alternatives. @@ -165,7 +165,7 @@ public: MetadataAwareOopClosure() : ExtendedOopClosure() { } - MetadataAwareOopClosure(ReferenceProcessor* rp) : ExtendedOopClosure(rp) { } + MetadataAwareOopClosure(ReferenceDiscoverer* rd) : ExtendedOopClosure(rd) { } bool do_metadata_nv() { return true; } virtual bool do_metadata() { return do_metadata_nv(); } --- old/src/hotspot/share/oops/instanceRefKlass.inline.hpp 2018-04-17 14:39:51.295056726 +0200 +++ new/src/hotspot/share/oops/instanceRefKlass.inline.hpp 2018-04-17 14:39:51.083047555 +0200 @@ -63,14 +63,14 @@ template bool InstanceRefKlass::try_discover(oop obj, ReferenceType type, OopClosureType* closure) { - ReferenceProcessor* rp = closure->ref_processor(); - if (rp != NULL) { + ReferenceDiscoverer* rd = closure->ref_discoverer(); + if (rd != NULL) { T referent_oop = RawAccess<>::oop_load((T*)java_lang_ref_Reference::referent_addr_raw(obj)); if (!CompressedOops::is_null(referent_oop)) { oop referent = CompressedOops::decode_not_null(referent_oop); if (!referent->is_gc_marked()) { // Only try to discover if not yet marked. - return rp->discover_reference(obj, type); + return rd->discover_reference(obj, type); } } } --- /dev/null 2018-04-03 12:55:20.301839954 +0200 +++ new/src/hotspot/share/gc/shared/referenceDiscoverer.hpp 2018-04-17 14:39:51.413061831 +0200 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_GC_SHARED_REFERENCEDISCOVERER_HPP +#define SHARE_GC_SHARED_REFERENCEDISCOVERER_HPP + +#include "memory/allocation.hpp" +#include "memory/referenceType.hpp" +#include "oops/oop.hpp" + +class ReferenceDiscoverer : public CHeapObj { +public: + virtual bool discover_reference(oop obj, ReferenceType type) = 0; +}; + +#endif // SHARE_GC_SHARED_REFERENCEDISCOVERER_HPP