< prev index next >

src/hotspot/share/gc/g1/g1OopClosures.hpp

Print this page
rev 49678 : imported patch 8200426-sangheon-review
rev 49680 : imported patch 6672778-partial-queue-trimming
rev 49681 : [mq]: 6672778-refactoring


  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1OOPCLOSURES_HPP
  26 #define SHARE_VM_GC_G1_G1OOPCLOSURES_HPP
  27 
  28 #include "gc/g1/g1InCSetState.hpp"
  29 #include "memory/iterator.hpp"
  30 #include "oops/markOop.hpp"
  31 #include "utilities/ticks.hpp"
  32 
  33 class HeapRegion;
  34 class G1CollectedHeap;
  35 class G1RemSet;
  36 class G1ConcurrentMark;
  37 class DirtyCardToOopClosure;
  38 class G1CMBitMap;
  39 class G1ParScanThreadState;
  40 class G1CMTask;
  41 class ReferenceProcessor;
  42 
  43 class G1ScanClosureBase : public ExtendedOopClosure {
  44 protected:
  45   G1CollectedHeap* _g1h;
  46   G1ParScanThreadState* _par_scan_state;
  47   HeapRegion* _from;
  48   Tickspan _trim_ticks;
  49 
  50   G1ScanClosureBase(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state);
  51   ~G1ScanClosureBase() { }
  52 
  53   template <class T>
  54   inline void prefetch_and_push(T* p, oop const obj);
  55 
  56   template <class T>
  57   inline void handle_non_cset_obj_common(InCSetState const state, T* p, oop const obj);
  58 public:
  59   // This closure needs special handling for InstanceRefKlass.
  60   virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
  61   void set_region(HeapRegion* from) { _from = from; }
  62   inline void trim_queue_partially();
  63 
  64   // Returns the currently accumulated time during partial queue triming and resets the counter.
  65   Tickspan trim_ticks_and_reset();
  66 };
  67 
  68 // Used during the Update RS phase to refine remaining cards in the DCQ during garbage collection.
  69 class G1ScanObjsDuringUpdateRSClosure: public G1ScanClosureBase {
  70   uint _worker_i;
  71 
  72 public:
  73   G1ScanObjsDuringUpdateRSClosure(G1CollectedHeap* g1h,
  74                                   G1ParScanThreadState* pss,
  75                                   uint worker_i) :
  76     G1ScanClosureBase(g1h, pss), _worker_i(worker_i) { }
  77 
  78   template <class T> void do_oop_nv(T* p);
  79   virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
  80   virtual void do_oop(oop* p) { do_oop_nv(p); }
  81 };
  82 
  83 // Used during the Scan RS phase to scan cards from the remembered set during garbage collection.
  84 class G1ScanObjsDuringScanRSClosure : public G1ScanClosureBase {
  85 public:


  98   G1ScanEvacuatedObjClosure(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state) :
  99     G1ScanClosureBase(g1h, par_scan_state) { }
 100 
 101   template <class T> void do_oop_nv(T* p);
 102   virtual void do_oop(oop* p)          { do_oop_nv(p); }
 103   virtual void do_oop(narrowOop* p)    { do_oop_nv(p); }
 104 
 105   void set_ref_processor(ReferenceProcessor* rp) {
 106     set_ref_processor_internal(rp);
 107   }
 108 };
 109 
 110 // Add back base class for metadata
 111 class G1ParCopyHelper : public OopClosure {
 112 protected:
 113   G1CollectedHeap* _g1h;
 114   G1ParScanThreadState* _par_scan_state;
 115   uint _worker_id;              // Cache value from par_scan_state.
 116   ClassLoaderData* _scanned_cld;
 117   G1ConcurrentMark* _cm;
 118   Tickspan _trim_ticks;
 119 
 120   // Mark the object if it's not already marked. This is used to mark
 121   // objects pointed to by roots that are guaranteed not to move
 122   // during the GC (i.e., non-CSet objects). It is MT-safe.
 123   inline void mark_object(oop obj);
 124 
 125   // Mark the object if it's not already marked. This is used to mark
 126   // objects pointed to by roots that have been forwarded during a
 127   // GC. It is MT-safe.
 128   inline void mark_forwarded_object(oop from_obj, oop to_obj);
 129 
 130   G1ParCopyHelper(G1CollectedHeap* g1h,  G1ParScanThreadState* par_scan_state);
 131   ~G1ParCopyHelper() { }
 132 
 133  public:
 134   inline void trim_queue_partially();
 135   void set_scanned_cld(ClassLoaderData* cld) { _scanned_cld = cld; }
 136   inline void do_cld_barrier(oop new_obj);
 137 
 138   // Returns the currently accumulated time during partial queue triming and resets the counter.
 139   Tickspan trim_ticks_and_reset();
 140 };
 141 
 142 enum G1Barrier {
 143   G1BarrierNone,
 144   G1BarrierCLD
 145 };
 146 
 147 enum G1Mark {
 148   G1MarkNone,
 149   G1MarkFromRoot,
 150   G1MarkPromotedFromRoot
 151 };
 152 
 153 template <G1Barrier barrier, G1Mark do_mark_object>
 154 class G1ParCopyClosure : public G1ParCopyHelper {
 155 public:
 156   G1ParCopyClosure(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state) :
 157       G1ParCopyHelper(g1h, par_scan_state) { }
 158 
 159   template <class T> void do_oop_work(T* p);




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1OOPCLOSURES_HPP
  26 #define SHARE_VM_GC_G1_G1OOPCLOSURES_HPP
  27 
  28 #include "gc/g1/g1InCSetState.hpp"
  29 #include "memory/iterator.hpp"
  30 #include "oops/markOop.hpp"

  31 
  32 class HeapRegion;
  33 class G1CollectedHeap;
  34 class G1RemSet;
  35 class G1ConcurrentMark;
  36 class DirtyCardToOopClosure;
  37 class G1CMBitMap;
  38 class G1ParScanThreadState;
  39 class G1CMTask;
  40 class ReferenceProcessor;
  41 
  42 class G1ScanClosureBase : public ExtendedOopClosure {
  43 protected:
  44   G1CollectedHeap* _g1h;
  45   G1ParScanThreadState* _par_scan_state;
  46   HeapRegion* _from;

  47 
  48   G1ScanClosureBase(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state);
  49   ~G1ScanClosureBase() { }
  50 
  51   template <class T>
  52   inline void prefetch_and_push(T* p, oop const obj);
  53 
  54   template <class T>
  55   inline void handle_non_cset_obj_common(InCSetState const state, T* p, oop const obj);
  56 public:
  57   // This closure needs special handling for InstanceRefKlass.
  58   virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
  59   void set_region(HeapRegion* from) { _from = from; }

  60 
  61   inline void trim_queue_partially();

  62 };
  63 
  64 // Used during the Update RS phase to refine remaining cards in the DCQ during garbage collection.
  65 class G1ScanObjsDuringUpdateRSClosure: public G1ScanClosureBase {
  66   uint _worker_i;
  67 
  68 public:
  69   G1ScanObjsDuringUpdateRSClosure(G1CollectedHeap* g1h,
  70                                   G1ParScanThreadState* pss,
  71                                   uint worker_i) :
  72     G1ScanClosureBase(g1h, pss), _worker_i(worker_i) { }
  73 
  74   template <class T> void do_oop_nv(T* p);
  75   virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
  76   virtual void do_oop(oop* p) { do_oop_nv(p); }
  77 };
  78 
  79 // Used during the Scan RS phase to scan cards from the remembered set during garbage collection.
  80 class G1ScanObjsDuringScanRSClosure : public G1ScanClosureBase {
  81 public:


  94   G1ScanEvacuatedObjClosure(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state) :
  95     G1ScanClosureBase(g1h, par_scan_state) { }
  96 
  97   template <class T> void do_oop_nv(T* p);
  98   virtual void do_oop(oop* p)          { do_oop_nv(p); }
  99   virtual void do_oop(narrowOop* p)    { do_oop_nv(p); }
 100 
 101   void set_ref_processor(ReferenceProcessor* rp) {
 102     set_ref_processor_internal(rp);
 103   }
 104 };
 105 
 106 // Add back base class for metadata
 107 class G1ParCopyHelper : public OopClosure {
 108 protected:
 109   G1CollectedHeap* _g1h;
 110   G1ParScanThreadState* _par_scan_state;
 111   uint _worker_id;              // Cache value from par_scan_state.
 112   ClassLoaderData* _scanned_cld;
 113   G1ConcurrentMark* _cm;

 114 
 115   // Mark the object if it's not already marked. This is used to mark
 116   // objects pointed to by roots that are guaranteed not to move
 117   // during the GC (i.e., non-CSet objects). It is MT-safe.
 118   inline void mark_object(oop obj);
 119 
 120   // Mark the object if it's not already marked. This is used to mark
 121   // objects pointed to by roots that have been forwarded during a
 122   // GC. It is MT-safe.
 123   inline void mark_forwarded_object(oop from_obj, oop to_obj);
 124 
 125   G1ParCopyHelper(G1CollectedHeap* g1h,  G1ParScanThreadState* par_scan_state);
 126   ~G1ParCopyHelper() { }
 127 
 128  public:

 129   void set_scanned_cld(ClassLoaderData* cld) { _scanned_cld = cld; }
 130   inline void do_cld_barrier(oop new_obj);
 131 
 132   inline void trim_queue_partially();

 133 };
 134 
 135 enum G1Barrier {
 136   G1BarrierNone,
 137   G1BarrierCLD
 138 };
 139 
 140 enum G1Mark {
 141   G1MarkNone,
 142   G1MarkFromRoot,
 143   G1MarkPromotedFromRoot
 144 };
 145 
 146 template <G1Barrier barrier, G1Mark do_mark_object>
 147 class G1ParCopyClosure : public G1ParCopyHelper {
 148 public:
 149   G1ParCopyClosure(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state) :
 150       G1ParCopyHelper(g1h, par_scan_state) { }
 151 
 152   template <class T> void do_oop_work(T* p);


< prev index next >