< prev index next >

src/hotspot/share/gc/shared/genOopClosures.hpp

Print this page




  23  */
  24 
  25 #ifndef SHARE_VM_GC_SHARED_GENOOPCLOSURES_HPP
  26 #define SHARE_VM_GC_SHARED_GENOOPCLOSURES_HPP
  27 
  28 #include "memory/iterator.hpp"
  29 #include "oops/oop.hpp"
  30 
  31 class Generation;
  32 class HeapWord;
  33 class CardTableRS;
  34 class CardTableBarrierSet;
  35 class DefNewGeneration;
  36 class KlassRemSet;
  37 
  38 // Closure for iterating roots from a particular generation
  39 // Note: all classes deriving from this MUST call this do_barrier
  40 // method at the end of their own do_oop method!
  41 // Note: no do_oop defined, this is an abstract class.
  42 
  43 class OopsInGenClosure : public ExtendedOopClosure {
  44  private:
  45   Generation*  _orig_gen;     // generation originally set in ctor
  46   Generation*  _gen;          // generation being scanned
  47 
  48  protected:
  49   // Some subtypes need access.
  50   HeapWord*    _gen_boundary; // start of generation
  51   CardTableRS* _rs;           // remembered set
  52 
  53   // For assertions
  54   Generation* generation() { return _gen; }
  55   CardTableRS* rs() { return _rs; }
  56 
  57   // Derived classes that modify oops so that they might be old-to-young
  58   // pointers must call the method below.
  59   template <class T> void do_barrier(T* p);
  60 
  61   // Version for use by closures that may be called in parallel code.
  62   template <class T> void par_do_barrier(T* p);
  63 
  64  public:
  65   OopsInGenClosure() : ExtendedOopClosure(NULL),
  66     _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
  67 
  68   OopsInGenClosure(Generation* gen);
  69   void set_generation(Generation* gen);
  70 
  71   void reset_generation() { _gen = _orig_gen; }
  72 
  73   // Problem with static closures: must have _gen_boundary set at some point,
  74   // but cannot do this until after the heap is initialized.
  75   void set_orig_generation(Generation* gen) {
  76     _orig_gen = gen;
  77     set_generation(gen);
  78   }
  79 
  80   HeapWord* gen_boundary() { return _gen_boundary; }
  81 
  82 };
  83 










  84 // Super class for scan closures. It contains code to dirty scanned class loader data.
  85 class OopsInClassLoaderDataOrGenClosure: public OopsInGenClosure {
  86   ClassLoaderData* _scanned_cld;
  87  public:
  88   OopsInClassLoaderDataOrGenClosure(Generation* g) : OopsInGenClosure(g), _scanned_cld(NULL) {}
  89   void set_scanned_cld(ClassLoaderData* cld) {
  90     assert(cld == NULL || _scanned_cld == NULL, "Must be");
  91     _scanned_cld = cld;
  92   }
  93   bool is_scanning_a_cld() { return _scanned_cld != NULL; }
  94   void do_cld_barrier();
  95 };
  96 
  97 #if INCLUDE_SERIALGC
  98 
  99 // Closure for scanning DefNewGeneration.
 100 //
 101 // This closure will perform barrier store calls for ALL
 102 // pointers in scanned oops.
 103 class ScanClosure: public OopsInClassLoaderDataOrGenClosure {
 104  private:
 105   DefNewGeneration* _g;
 106   HeapWord*         _boundary;
 107   bool              _gc_barrier;
 108   template <class T> inline void do_oop_work(T* p);
 109  public:
 110   ScanClosure(DefNewGeneration* g, bool gc_barrier);
 111   virtual void do_oop(oop* p);
 112   virtual void do_oop(narrowOop* p);
 113   inline void do_oop_nv(oop* p);
 114   inline void do_oop_nv(narrowOop* p);
 115 };
 116 
 117 // Closure for scanning DefNewGeneration.
 118 //
 119 // This closure only performs barrier store calls on
 120 // pointers into the DefNewGeneration. This is less
 121 // precise, but faster, than a ScanClosure
 122 class FastScanClosure: public OopsInClassLoaderDataOrGenClosure {
 123  protected:
 124   DefNewGeneration* _g;
 125   HeapWord*         _boundary;
 126   bool              _gc_barrier;
 127   template <class T> inline void do_oop_work(T* p);
 128  public:
 129   FastScanClosure(DefNewGeneration* g, bool gc_barrier);
 130   virtual void do_oop(oop* p);
 131   virtual void do_oop(narrowOop* p);
 132   inline void do_oop_nv(oop* p);
 133   inline void do_oop_nv(narrowOop* p);
 134 };
 135 
 136 #endif // INCLUDE_SERIALGC
 137 
 138 class CLDScanClosure: public CLDClosure {
 139   OopsInClassLoaderDataOrGenClosure*   _scavenge_closure;
 140   // true if the the modified oops state should be saved.
 141   bool                                 _accumulate_modified_oops;
 142  public:
 143   CLDScanClosure(OopsInClassLoaderDataOrGenClosure* scavenge_closure,
 144                  bool accumulate_modified_oops) :
 145        _scavenge_closure(scavenge_closure), _accumulate_modified_oops(accumulate_modified_oops) {}
 146   void do_cld(ClassLoaderData* cld);
 147 };
 148 
 149 class FilteringClosure: public ExtendedOopClosure {
 150  private:
 151   HeapWord*   _boundary;
 152   ExtendedOopClosure* _cl;
 153  protected:
 154   template <class T> inline void do_oop_work(T* p);
 155  public:
 156   FilteringClosure(HeapWord* boundary, ExtendedOopClosure* cl) :
 157     ExtendedOopClosure(cl->ref_discoverer()), _boundary(boundary),
 158     _cl(cl) {}
 159   virtual void do_oop(oop* p);
 160   virtual void do_oop(narrowOop* p);
 161   inline void do_oop_nv(oop* p);
 162   inline void do_oop_nv(narrowOop* p);
 163   virtual bool do_metadata()          { return do_metadata_nv(); }
 164   inline bool do_metadata_nv()        { assert(!_cl->do_metadata(), "assumption broken, must change to 'return _cl->do_metadata()'"); return false; }
 165 };
 166 
 167 #if INCLUDE_SERIALGC
 168 
 169 // Closure for scanning DefNewGeneration's weak references.
 170 // NOTE: very much like ScanClosure but not derived from
 171 //  OopsInGenClosure -- weak references are processed all
 172 //  at once, with no notion of which generation they were in.
 173 class ScanWeakRefClosure: public OopClosure {
 174  protected:
 175   DefNewGeneration* _g;
 176   HeapWord*         _boundary;
 177   template <class T> inline void do_oop_work(T* p);
 178  public:
 179   ScanWeakRefClosure(DefNewGeneration* g);
 180   virtual void do_oop(oop* p);
 181   virtual void do_oop(narrowOop* p);
 182   inline void do_oop_nv(oop* p);
 183   inline void do_oop_nv(narrowOop* p);
 184 };
 185 
 186 #endif // INCLUDE_SERIALGC
 187 
 188 #endif // SHARE_VM_GC_SHARED_GENOOPCLOSURES_HPP


  23  */
  24 
  25 #ifndef SHARE_VM_GC_SHARED_GENOOPCLOSURES_HPP
  26 #define SHARE_VM_GC_SHARED_GENOOPCLOSURES_HPP
  27 
  28 #include "memory/iterator.hpp"
  29 #include "oops/oop.hpp"
  30 
  31 class Generation;
  32 class HeapWord;
  33 class CardTableRS;
  34 class CardTableBarrierSet;
  35 class DefNewGeneration;
  36 class KlassRemSet;
  37 
  38 // Closure for iterating roots from a particular generation
  39 // Note: all classes deriving from this MUST call this do_barrier
  40 // method at the end of their own do_oop method!
  41 // Note: no do_oop defined, this is an abstract class.
  42 
  43 class OopsInGenClosure : public OopIterateClosure {
  44  private:
  45   Generation*  _orig_gen;     // generation originally set in ctor
  46   Generation*  _gen;          // generation being scanned
  47 
  48  protected:
  49   // Some subtypes need access.
  50   HeapWord*    _gen_boundary; // start of generation
  51   CardTableRS* _rs;           // remembered set
  52 
  53   // For assertions
  54   Generation* generation() { return _gen; }
  55   CardTableRS* rs() { return _rs; }
  56 
  57   // Derived classes that modify oops so that they might be old-to-young
  58   // pointers must call the method below.
  59   template <class T> void do_barrier(T* p);
  60 
  61   // Version for use by closures that may be called in parallel code.
  62   template <class T> void par_do_barrier(T* p);
  63 
  64  public:
  65   OopsInGenClosure() : OopIterateClosure(NULL),
  66     _orig_gen(NULL), _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
  67 
  68   OopsInGenClosure(Generation* gen);
  69   void set_generation(Generation* gen);
  70 
  71   void reset_generation() { _gen = _orig_gen; }
  72 
  73   // Problem with static closures: must have _gen_boundary set at some point,
  74   // but cannot do this until after the heap is initialized.
  75   void set_orig_generation(Generation* gen) {
  76     _orig_gen = gen;
  77     set_generation(gen);
  78   }
  79 
  80   HeapWord* gen_boundary() { return _gen_boundary; }
  81 
  82 };
  83 
  84 class BasicOopsInGenClosure: public OopsInGenClosure {
  85  public:
  86   BasicOopsInGenClosure() : OopsInGenClosure() {}
  87   BasicOopsInGenClosure(Generation* gen);
  88 
  89   virtual bool do_metadata() { return false; }
  90   virtual void do_klass(Klass* k) { ShouldNotReachHere(); }
  91   virtual void do_cld(ClassLoaderData* cld) { ShouldNotReachHere(); }
  92 };
  93 
  94 // Super class for scan closures. It contains code to dirty scanned class loader data.
  95 class OopsInClassLoaderDataOrGenClosure: public BasicOopsInGenClosure {
  96   ClassLoaderData* _scanned_cld;
  97  public:
  98   OopsInClassLoaderDataOrGenClosure(Generation* g) : BasicOopsInGenClosure(g), _scanned_cld(NULL) {}
  99   void set_scanned_cld(ClassLoaderData* cld) {
 100     assert(cld == NULL || _scanned_cld == NULL, "Must be");
 101     _scanned_cld = cld;
 102   }
 103   bool is_scanning_a_cld() { return _scanned_cld != NULL; }
 104   void do_cld_barrier();
 105 };
 106 
 107 #if INCLUDE_SERIALGC
 108 
 109 // Closure for scanning DefNewGeneration.
 110 //
 111 // This closure will perform barrier store calls for ALL
 112 // pointers in scanned oops.
 113 class ScanClosure: public OopsInClassLoaderDataOrGenClosure {
 114  private:
 115   DefNewGeneration* _g;
 116   HeapWord*         _boundary;
 117   bool              _gc_barrier;
 118   template <class T> inline void do_oop_work(T* p);
 119  public:
 120   ScanClosure(DefNewGeneration* g, bool gc_barrier);
 121   virtual void do_oop(oop* p);
 122   virtual void do_oop(narrowOop* p);


 123 };
 124 
 125 // Closure for scanning DefNewGeneration.
 126 //
 127 // This closure only performs barrier store calls on
 128 // pointers into the DefNewGeneration. This is less
 129 // precise, but faster, than a ScanClosure
 130 class FastScanClosure: public OopsInClassLoaderDataOrGenClosure {
 131  protected:
 132   DefNewGeneration* _g;
 133   HeapWord*         _boundary;
 134   bool              _gc_barrier;
 135   template <class T> inline void do_oop_work(T* p);
 136  public:
 137   FastScanClosure(DefNewGeneration* g, bool gc_barrier);
 138   virtual void do_oop(oop* p);
 139   virtual void do_oop(narrowOop* p);


 140 };
 141 
 142 #endif // INCLUDE_SERIALGC
 143 
 144 class CLDScanClosure: public CLDClosure {
 145   OopsInClassLoaderDataOrGenClosure*   _scavenge_closure;
 146   // true if the the modified oops state should be saved.
 147   bool                                 _accumulate_modified_oops;
 148  public:
 149   CLDScanClosure(OopsInClassLoaderDataOrGenClosure* scavenge_closure,
 150                  bool accumulate_modified_oops) :
 151        _scavenge_closure(scavenge_closure), _accumulate_modified_oops(accumulate_modified_oops) {}
 152   void do_cld(ClassLoaderData* cld);
 153 };
 154 
 155 class FilteringClosure: public OopIterateClosure {
 156  private:
 157   HeapWord*   _boundary;
 158   OopIterateClosure* _cl;
 159  protected:
 160   template <class T> inline void do_oop_work(T* p);
 161  public:
 162   FilteringClosure(HeapWord* boundary, OopIterateClosure* cl) :
 163     OopIterateClosure(cl->ref_discoverer()), _boundary(boundary),
 164     _cl(cl) {}
 165   virtual void do_oop(oop* p);
 166   virtual void do_oop(narrowOop* p);
 167   virtual bool do_metadata()            { assert(!_cl->do_metadata(), "assumption broken, must change to 'return _cl->do_metadata()'"); return false; }
 168   virtual void do_klass(Klass*)         { ShouldNotReachHere(); }
 169   virtual void do_cld(ClassLoaderData*) { ShouldNotReachHere(); }

 170 };
 171 
 172 #if INCLUDE_SERIALGC
 173 
 174 // Closure for scanning DefNewGeneration's weak references.
 175 // NOTE: very much like ScanClosure but not derived from
 176 //  OopsInGenClosure -- weak references are processed all
 177 //  at once, with no notion of which generation they were in.
 178 class ScanWeakRefClosure: public OopClosure {
 179  protected:
 180   DefNewGeneration* _g;
 181   HeapWord*         _boundary;
 182   template <class T> inline void do_oop_work(T* p);
 183  public:
 184   ScanWeakRefClosure(DefNewGeneration* g);
 185   virtual void do_oop(oop* p);
 186   virtual void do_oop(narrowOop* p);


 187 };
 188 
 189 #endif // INCLUDE_SERIALGC
 190 
 191 #endif // SHARE_VM_GC_SHARED_GENOOPCLOSURES_HPP
< prev index next >