8201646: Introduce ReferenceDiscoverer interface
authorpliden
Thu, 19 Apr 2018 07:54:50 +0200
changeset 49827 a4672513d6e3
parent 49826 ad1a5f49b8ae
child 49828 ee3555b4a130
8201646: Introduce ReferenceDiscoverer interface Reviewed-by: stefank, tschatzl, rkennke
src/hotspot/share/gc/cms/cmsOopClosures.hpp
src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp
src/hotspot/share/gc/g1/g1CollectedHeap.cpp
src/hotspot/share/gc/g1/g1FullGCOopClosures.hpp
src/hotspot/share/gc/g1/g1OopClosures.hpp
src/hotspot/share/gc/g1/g1ParScanThreadState.hpp
src/hotspot/share/gc/serial/markSweep.cpp
src/hotspot/share/gc/serial/markSweep.hpp
src/hotspot/share/gc/shared/genOopClosures.hpp
src/hotspot/share/gc/shared/referenceDiscoverer.hpp
src/hotspot/share/gc/shared/referenceProcessor.hpp
src/hotspot/share/memory/iterator.hpp
src/hotspot/share/oops/instanceRefKlass.inline.hpp
--- a/src/hotspot/share/gc/cms/cmsOopClosures.hpp	Thu Apr 19 09:15:17 2018 +0200
+++ b/src/hotspot/share/gc/cms/cmsOopClosures.hpp	Thu Apr 19 07:54:50 2018 +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);
--- a/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp	Thu Apr 19 09:15:17 2018 +0200
+++ b/src/hotspot/share/gc/cms/concurrentMarkSweepGeneration.cpp	Thu Apr 19 07:54:50 2018 +0200
@@ -5825,7 +5825,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");
 }
 
@@ -5847,7 +5847,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");
 }
 
@@ -5871,7 +5871,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");
 }
 
@@ -5900,7 +5900,7 @@
 //////////////////////////////////////////////////
 
 MarkRefsIntoAndScanClosure::MarkRefsIntoAndScanClosure(MemRegion span,
-                                                       ReferenceProcessor* rp,
+                                                       ReferenceDiscoverer* rd,
                                                        CMSBitMap* bit_map,
                                                        CMSBitMap* mod_union_table,
                                                        CMSMarkStack*  mark_stack,
@@ -5911,15 +5911,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
@@ -6004,18 +6004,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
@@ -6842,12 +6842,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),
@@ -6855,7 +6855,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 --
@@ -6916,16 +6916,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); }
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Thu Apr 19 09:15:17 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Thu Apr 19 07:54:50 2018 +0200
@@ -3125,7 +3125,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();
 
@@ -3820,7 +3820,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);
@@ -3912,7 +3912,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
@@ -4018,7 +4018,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.
--- a/src/hotspot/share/gc/g1/g1FullGCOopClosures.hpp	Thu Apr 19 09:15:17 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1FullGCOopClosures.hpp	Thu Apr 19 07:54:50 2018 +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) { }
--- a/src/hotspot/share/gc/g1/g1OopClosures.hpp	Thu Apr 19 09:15:17 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1OopClosures.hpp	Thu Apr 19 07:54:50 2018 +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);
   }
 };
 
--- a/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp	Thu Apr 19 09:15:17 2018 +0200
+++ b/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp	Thu Apr 19 07:54:50 2018 +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(); }
--- a/src/hotspot/share/gc/serial/markSweep.cpp	Thu Apr 19 09:15:17 2018 +0200
+++ b/src/hotspot/share/gc/serial/markSweep.cpp	Thu Apr 19 07:54:50 2018 +0200
@@ -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;
--- a/src/hotspot/share/gc/serial/markSweep.hpp	Thu Apr 19 09:15:17 2018 +0200
+++ b/src/hotspot/share/gc/serial/markSweep.hpp	Thu Apr 19 07:54:50 2018 +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);
   }
 };
 
--- a/src/hotspot/share/gc/shared/genOopClosures.hpp	Thu Apr 19 09:15:17 2018 +0200
+++ b/src/hotspot/share/gc/shared/genOopClosures.hpp	Thu Apr 19 07:54:50 2018 +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 <class T> 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);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hotspot/share/gc/shared/referenceDiscoverer.hpp	Thu Apr 19 07:54:50 2018 +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/oopsHierarchy.hpp"
+
+class ReferenceDiscoverer : public CHeapObj<mtGC> {
+public:
+  virtual bool discover_reference(oop obj, ReferenceType type) = 0;
+};
+
+#endif // SHARE_GC_SHARED_REFERENCEDISCOVERER_HPP
--- a/src/hotspot/share/gc/shared/referenceProcessor.hpp	Thu Apr 19 09:15:17 2018 +0200
+++ b/src/hotspot/share/gc/shared/referenceProcessor.hpp	Thu Apr 19 07:54:50 2018 +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<mtGC> {
+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();
--- a/src/hotspot/share/memory/iterator.hpp	Thu Apr 19 09:15:17 2018 +0200
+++ b/src/hotspot/share/memory/iterator.hpp	Thu Apr 19 07:54:50 2018 +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(); }
--- a/src/hotspot/share/oops/instanceRefKlass.inline.hpp	Thu Apr 19 09:15:17 2018 +0200
+++ b/src/hotspot/share/oops/instanceRefKlass.inline.hpp	Thu Apr 19 07:54:50 2018 +0200
@@ -63,14 +63,14 @@
 
 template <typename T, class OopClosureType>
 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);
       }
     }
   }