< prev index next >

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

Print this page




  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:
  82   G1ScanObjsDuringScanRSClosure(G1CollectedHeap* g1h,
  83                                 G1ParScanThreadState* par_scan_state):
  84     G1ScanClosureBase(g1h, par_scan_state) { }
  85 
  86   template <class T> void do_oop_nv(T* p);
  87   virtual void do_oop(oop* p)          { do_oop_nv(p); }
  88   virtual void do_oop(narrowOop* p)    { do_oop_nv(p); }
  89 };
  90 
  91 // This closure is applied to the fields of the objects that have just been copied during evacuation.
  92 class G1ScanEvacuatedObjClosure : public G1ScanClosureBase {
  93 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_discoverer(ReferenceDiscoverer* rd) {
 102     set_ref_discoverer_internal(rd);
 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 


 150       G1ParCopyHelper(g1h, par_scan_state) { }
 151 
 152   template <class T> void do_oop_work(T* p);
 153   virtual void do_oop(oop* p)       { do_oop_work(p); }
 154   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 155 };
 156 
 157 class G1CLDScanClosure : public CLDClosure {
 158   G1ParCopyHelper* _closure;
 159   bool             _process_only_dirty;
 160   bool             _must_claim;
 161   int              _count;
 162 public:
 163   G1CLDScanClosure(G1ParCopyHelper* closure,
 164                    bool process_only_dirty, bool must_claim)
 165       : _process_only_dirty(process_only_dirty), _must_claim(must_claim), _closure(closure), _count(0) {}
 166   void do_cld(ClassLoaderData* cld);
 167 };
 168 
 169 // Closure for iterating over object fields during concurrent marking
 170 class G1CMOopClosure : public MetadataAwareOopClosure {
 171   G1CollectedHeap*   _g1h;
 172   G1CMTask*          _task;
 173 public:
 174   G1CMOopClosure(G1CollectedHeap* g1h,G1CMTask* task);
 175   template <class T> void do_oop_nv(T* p);
 176   virtual void do_oop(      oop* p) { do_oop_nv(p); }
 177   virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
 178 };
 179 
 180 // Closure to scan the root regions during concurrent marking
 181 class G1RootRegionScanClosure : public MetadataAwareOopClosure {
 182 private:
 183   G1CollectedHeap* _g1h;
 184   G1ConcurrentMark* _cm;
 185   uint _worker_id;
 186 public:
 187   G1RootRegionScanClosure(G1CollectedHeap* g1h, G1ConcurrentMark* cm, uint worker_id) :
 188     _g1h(g1h), _cm(cm), _worker_id(worker_id) { }
 189   template <class T> void do_oop_nv(T* p);
 190   virtual void do_oop(      oop* p) { do_oop_nv(p); }
 191   virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
 192 };
 193 
 194 class G1ConcurrentRefineOopClosure: public ExtendedOopClosure {
 195   G1CollectedHeap* _g1h;
 196   uint _worker_i;
 197 
 198 public:
 199   G1ConcurrentRefineOopClosure(G1CollectedHeap* g1h, uint worker_i) :
 200     _g1h(g1h),
 201     _worker_i(worker_i) {
 202   }
 203 
 204   // This closure needs special handling for InstanceRefKlass.
 205   virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
 206 
 207   template <class T> void do_oop_nv(T* p);
 208   virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
 209   virtual void do_oop(oop* p)       { do_oop_nv(p); }
 210 };
 211 
 212 class G1RebuildRemSetClosure : public ExtendedOopClosure {
 213   G1CollectedHeap* _g1h;
 214   uint _worker_id;
 215 public:
 216   G1RebuildRemSetClosure(G1CollectedHeap* g1h, uint worker_id) : _g1h(g1h), _worker_id(worker_id) {
 217   }
 218 
 219   template <class T> void do_oop_nv(T* p);
 220   virtual void do_oop(oop* p)       { do_oop_nv(p); }
 221   virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
 222   // This closure needs special handling for InstanceRefKlass.
 223   virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
 224 };
 225 
 226 #endif // SHARE_VM_GC_G1_G1OOPCLOSURES_HPP


  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 BasicOopIterateClosure {
  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_work(T* p);
  75   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
  76   virtual void do_oop(oop* p) { do_oop_work(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:
  82   G1ScanObjsDuringScanRSClosure(G1CollectedHeap* g1h,
  83                                 G1ParScanThreadState* par_scan_state):
  84     G1ScanClosureBase(g1h, par_scan_state) { }
  85 
  86   template <class T> void do_oop_work(T* p);
  87   virtual void do_oop(oop* p)          { do_oop_work(p); }
  88   virtual void do_oop(narrowOop* p)    { do_oop_work(p); }
  89 };
  90 
  91 // This closure is applied to the fields of the objects that have just been copied during evacuation.
  92 class G1ScanEvacuatedObjClosure : public G1ScanClosureBase {
  93 public:
  94   G1ScanEvacuatedObjClosure(G1CollectedHeap* g1h, G1ParScanThreadState* par_scan_state) :
  95     G1ScanClosureBase(g1h, par_scan_state) { }
  96 
  97   template <class T> void do_oop_work(T* p);
  98   virtual void do_oop(oop* p)          { do_oop_work(p); }
  99   virtual void do_oop(narrowOop* p)    { do_oop_work(p); }
 100 
 101   void set_ref_discoverer(ReferenceDiscoverer* rd) {
 102     set_ref_discoverer_internal(rd);
 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 


 150       G1ParCopyHelper(g1h, par_scan_state) { }
 151 
 152   template <class T> void do_oop_work(T* p);
 153   virtual void do_oop(oop* p)       { do_oop_work(p); }
 154   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 155 };
 156 
 157 class G1CLDScanClosure : public CLDClosure {
 158   G1ParCopyHelper* _closure;
 159   bool             _process_only_dirty;
 160   bool             _must_claim;
 161   int              _count;
 162 public:
 163   G1CLDScanClosure(G1ParCopyHelper* closure,
 164                    bool process_only_dirty, bool must_claim)
 165       : _process_only_dirty(process_only_dirty), _must_claim(must_claim), _closure(closure), _count(0) {}
 166   void do_cld(ClassLoaderData* cld);
 167 };
 168 
 169 // Closure for iterating over object fields during concurrent marking
 170 class G1CMOopClosure : public MetadataVisitingOopIterateClosure {
 171   G1CollectedHeap*   _g1h;
 172   G1CMTask*          _task;
 173 public:
 174   G1CMOopClosure(G1CollectedHeap* g1h,G1CMTask* task);
 175   template <class T> void do_oop_work(T* p);
 176   virtual void do_oop(      oop* p) { do_oop_work(p); }
 177   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 178 };
 179 
 180 // Closure to scan the root regions during concurrent marking
 181 class G1RootRegionScanClosure : public MetadataVisitingOopIterateClosure {
 182 private:
 183   G1CollectedHeap* _g1h;
 184   G1ConcurrentMark* _cm;
 185   uint _worker_id;
 186 public:
 187   G1RootRegionScanClosure(G1CollectedHeap* g1h, G1ConcurrentMark* cm, uint worker_id) :
 188     _g1h(g1h), _cm(cm), _worker_id(worker_id) { }
 189   template <class T> void do_oop_work(T* p);
 190   virtual void do_oop(      oop* p) { do_oop_work(p); }
 191   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 192 };
 193 
 194 class G1ConcurrentRefineOopClosure: public BasicOopIterateClosure {
 195   G1CollectedHeap* _g1h;
 196   uint _worker_i;
 197 
 198 public:
 199   G1ConcurrentRefineOopClosure(G1CollectedHeap* g1h, uint worker_i) :
 200     _g1h(g1h),
 201     _worker_i(worker_i) {
 202   }
 203 
 204   // This closure needs special handling for InstanceRefKlass.
 205   virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
 206 
 207   template <class T> void do_oop_work(T* p);
 208   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 209   virtual void do_oop(oop* p)       { do_oop_work(p); }
 210 };
 211 
 212 class G1RebuildRemSetClosure : public BasicOopIterateClosure {
 213   G1CollectedHeap* _g1h;
 214   uint _worker_id;
 215 public:
 216   G1RebuildRemSetClosure(G1CollectedHeap* g1h, uint worker_id) : _g1h(g1h), _worker_id(worker_id) {
 217   }
 218 
 219   template <class T> void do_oop_work(T* p);
 220   virtual void do_oop(oop* p)       { do_oop_work(p); }
 221   virtual void do_oop(narrowOop* p) { do_oop_work(p); }
 222   // This closure needs special handling for InstanceRefKlass.
 223   virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERED_AND_DISCOVERY; }
 224 };
 225 
 226 #endif // SHARE_VM_GC_G1_G1OOPCLOSURES_HPP
< prev index next >