< prev index next >

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

Print this page




  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_SHARED_CARDTABLERS_HPP
  26 #define SHARE_VM_GC_SHARED_CARDTABLERS_HPP
  27 
  28 #include "gc/shared/cardTableModRefBSForCTRS.hpp"
  29 #include "memory/memRegion.hpp"
  30 
  31 class Space;
  32 class OopsInGenClosure;
  33 
  34 // Helper to remember modified oops in all klasses.
  35 class KlassRemSet {
  36   bool _accumulate_modified_oops;
  37  public:
  38   KlassRemSet() : _accumulate_modified_oops(false) {}
  39   void set_accumulate_modified_oops(bool value) { _accumulate_modified_oops = value; }
  40   bool accumulate_modified_oops() { return _accumulate_modified_oops; }
  41   bool mod_union_is_clear();
  42   void clear_mod_union();
  43 };
  44 
  45 // This RemSet uses a card table both as shared data structure
  46 // for a mod ref barrier set and for the rem set information.
  47 
  48 class CardTableRS: public CHeapObj<mtGC> {
  49   friend class VMStructs;
  50   // Below are private classes used in impl.
  51   friend class VerifyCTSpaceClosure;
  52   friend class ClearNoncleanCardWrapper;
  53 
  54   static jbyte clean_card_val() {
  55     return CardTableModRefBSForCTRS::clean_card;
  56   }
  57 
  58   static intptr_t clean_card_row() {
  59     return CardTableModRefBSForCTRS::clean_card_row;
  60   }
  61 
  62   static bool
  63   card_is_dirty_wrt_gen_iter(jbyte cv) {
  64     return CardTableModRefBSForCTRS::card_is_dirty_wrt_gen_iter(cv);
  65   }
  66 
  67   KlassRemSet _klass_rem_set;
  68   BarrierSet* _bs;
  69 
  70   CardTableModRefBSForCTRS* _ct_bs;
  71 
  72   void verify_space(Space* s, HeapWord* gen_start);
  73 
  74   enum ExtendedCardValue {
  75     youngergen_card   = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 1,
  76     // These are for parallel collection.
  77     // There are three P (parallel) youngergen card values.  In general, this
  78     // needs to be more than the number of generations (including the perm
  79     // gen) that might have younger_refs_do invoked on them separately.  So
  80     // if we add more gens, we have to add more values.
  81     youngergenP1_card  = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 2,
  82     youngergenP2_card  = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 3,
  83     youngergenP3_card  = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 4,
  84     cur_youngergen_and_prev_nonclean_card =
  85       CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 5
  86   };
  87 


 103     _cur_youngergen_card_val = v;
 104   }
 105   bool is_prev_youngergen_card_val(jbyte v) {
 106     return
 107       youngergen_card <= v &&
 108       v < cur_youngergen_and_prev_nonclean_card &&
 109       v != _cur_youngergen_card_val;
 110   }
 111   // Return a youngergen_card_value that is not currently in use.
 112   jbyte find_unused_youngergenP_card_value();
 113 
 114 public:
 115   CardTableRS(MemRegion whole_heap);
 116   ~CardTableRS();
 117 
 118   // Return the barrier set associated with "this."
 119   BarrierSet* bs() { return _bs; }
 120 
 121   // Set the barrier set.
 122   void set_bs(BarrierSet* bs) { _bs = bs; }
 123 
 124   KlassRemSet* klass_rem_set() { return &_klass_rem_set; }
 125 
 126   CardTableModRefBSForCTRS* ct_bs() { return _ct_bs; }
 127 
 128   void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl, uint n_threads);
 129 
 130   // Override.
 131   void prepare_for_younger_refs_iterate(bool parallel);
 132 
 133   // Card table entries are cleared before application; "blk" is
 134   // responsible for dirtying if the oop is still older-to-younger after
 135   // closure application.
 136   void younger_refs_iterate(Generation* g, OopsInGenClosure* blk, uint n_threads);
 137 
 138   void inline_write_ref_field_gc(void* field, oop new_val) {
 139     jbyte* byte = _ct_bs->byte_for(field);
 140     *byte = youngergen_card;
 141   }
 142   void write_ref_field_gc_work(void* field, oop new_val) {
 143     inline_write_ref_field_gc(field, new_val);
 144   }




  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_SHARED_CARDTABLERS_HPP
  26 #define SHARE_VM_GC_SHARED_CARDTABLERS_HPP
  27 
  28 #include "gc/shared/cardTableModRefBSForCTRS.hpp"
  29 #include "memory/memRegion.hpp"
  30 
  31 class Space;
  32 class OopsInGenClosure;
  33 











  34 // This RemSet uses a card table both as shared data structure
  35 // for a mod ref barrier set and for the rem set information.
  36 
  37 class CardTableRS: public CHeapObj<mtGC> {
  38   friend class VMStructs;
  39   // Below are private classes used in impl.
  40   friend class VerifyCTSpaceClosure;
  41   friend class ClearNoncleanCardWrapper;
  42 
  43   static jbyte clean_card_val() {
  44     return CardTableModRefBSForCTRS::clean_card;
  45   }
  46 
  47   static intptr_t clean_card_row() {
  48     return CardTableModRefBSForCTRS::clean_card_row;
  49   }
  50 
  51   static bool
  52   card_is_dirty_wrt_gen_iter(jbyte cv) {
  53     return CardTableModRefBSForCTRS::card_is_dirty_wrt_gen_iter(cv);
  54   }
  55 

  56   BarrierSet* _bs;
  57 
  58   CardTableModRefBSForCTRS* _ct_bs;
  59 
  60   void verify_space(Space* s, HeapWord* gen_start);
  61 
  62   enum ExtendedCardValue {
  63     youngergen_card   = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 1,
  64     // These are for parallel collection.
  65     // There are three P (parallel) youngergen card values.  In general, this
  66     // needs to be more than the number of generations (including the perm
  67     // gen) that might have younger_refs_do invoked on them separately.  So
  68     // if we add more gens, we have to add more values.
  69     youngergenP1_card  = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 2,
  70     youngergenP2_card  = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 3,
  71     youngergenP3_card  = CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 4,
  72     cur_youngergen_and_prev_nonclean_card =
  73       CardTableModRefBSForCTRS::CT_MR_BS_last_reserved + 5
  74   };
  75 


  91     _cur_youngergen_card_val = v;
  92   }
  93   bool is_prev_youngergen_card_val(jbyte v) {
  94     return
  95       youngergen_card <= v &&
  96       v < cur_youngergen_and_prev_nonclean_card &&
  97       v != _cur_youngergen_card_val;
  98   }
  99   // Return a youngergen_card_value that is not currently in use.
 100   jbyte find_unused_youngergenP_card_value();
 101 
 102 public:
 103   CardTableRS(MemRegion whole_heap);
 104   ~CardTableRS();
 105 
 106   // Return the barrier set associated with "this."
 107   BarrierSet* bs() { return _bs; }
 108 
 109   // Set the barrier set.
 110   void set_bs(BarrierSet* bs) { _bs = bs; }


 111 
 112   CardTableModRefBSForCTRS* ct_bs() { return _ct_bs; }
 113 
 114   void younger_refs_in_space_iterate(Space* sp, OopsInGenClosure* cl, uint n_threads);
 115 
 116   // Override.
 117   void prepare_for_younger_refs_iterate(bool parallel);
 118 
 119   // Card table entries are cleared before application; "blk" is
 120   // responsible for dirtying if the oop is still older-to-younger after
 121   // closure application.
 122   void younger_refs_iterate(Generation* g, OopsInGenClosure* blk, uint n_threads);
 123 
 124   void inline_write_ref_field_gc(void* field, oop new_val) {
 125     jbyte* byte = _ct_bs->byte_for(field);
 126     *byte = youngergen_card;
 127   }
 128   void write_ref_field_gc_work(void* field, oop new_val) {
 129     inline_write_ref_field_gc(field, new_val);
 130   }


< prev index next >