< prev index next >

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

Print this page




  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 CardTableModRefBS;
  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 Klasses.
  85 class OopsInKlassOrGenClosure: public OopsInGenClosure {
  86   Klass* _scanned_klass;
  87  public:
  88   OopsInKlassOrGenClosure(Generation* g) : OopsInGenClosure(g), _scanned_klass(NULL) {}
  89   void set_scanned_klass(Klass* k) {
  90     assert(k == NULL || _scanned_klass == NULL, "Must be");
  91     _scanned_klass = k;
  92   }
  93   bool is_scanning_a_klass() { return _scanned_klass != NULL; }
  94   void do_klass_barrier();
  95 };
  96 
  97 // Closure for scanning DefNewGeneration.
  98 //
  99 // This closure will perform barrier store calls for ALL
 100 // pointers in scanned oops.
 101 class ScanClosure: public OopsInKlassOrGenClosure {




  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 CardTableModRefBS;
  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*  _gen;          // generation being scanned
  46 
  47  protected:
  48   // Some subtypes need access.
  49   HeapWord*    _gen_boundary; // start of generation
  50   CardTableRS* _rs;           // remembered set
  51 
  52   // For assertions
  53   Generation* generation() { return _gen; }
  54   CardTableRS* rs() { return _rs; }
  55 
  56   // Derived classes that modify oops so that they might be old-to-young
  57   // pointers must call the method below.
  58   template <class T> void do_barrier(T* p);
  59 
  60   // Version for use by closures that may be called in parallel code.
  61   template <class T> void par_do_barrier(T* p);
  62 
  63  public:
  64   OopsInGenClosure() : ExtendedOopClosure(NULL),
  65     _gen(NULL), _gen_boundary(NULL), _rs(NULL) {};
  66 
  67   OopsInGenClosure(Generation* gen);



  68 
  69   // Problem with static closures: must have _gen_boundary set at some point,
  70   // but cannot do this until after the heap is initialized.
  71   void set_generation(Generation* gen);
  72   void assert_generation(Generation* gen);


  73 
  74   HeapWord* gen_boundary() { return _gen_boundary; }

  75 };
  76 
  77 // Super class for scan closures. It contains code to dirty scanned Klasses.
  78 class OopsInKlassOrGenClosure: public OopsInGenClosure {
  79   Klass* _scanned_klass;
  80  public:
  81   OopsInKlassOrGenClosure(Generation* g) : OopsInGenClosure(g), _scanned_klass(NULL) {}
  82   void set_scanned_klass(Klass* k) {
  83     assert(k == NULL || _scanned_klass == NULL, "Must be");
  84     _scanned_klass = k;
  85   }
  86   bool is_scanning_a_klass() { return _scanned_klass != NULL; }
  87   void do_klass_barrier();
  88 };
  89 
  90 // Closure for scanning DefNewGeneration.
  91 //
  92 // This closure will perform barrier store calls for ALL
  93 // pointers in scanned oops.
  94 class ScanClosure: public OopsInKlassOrGenClosure {


< prev index next >