< prev index next >

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

Print this page
rev 10742 : Make fields used in lock-free algorithms volatile


  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 
  88   // An array that contains, for each generation, the card table value last
  89   // used as the current value for a younger_refs_do iteration of that
  90   // portion of the table. The perm gen is index 0. The young gen is index 1,
  91   // but will always have the value "clean_card". The old gen is index 2.
  92   jbyte* _last_cur_val_in_gen;
  93 
  94   jbyte _cur_youngergen_card_val;
  95 
  96   // Number of generations, plus one for lingering PermGen issues in CardTableRS.
  97   static const int _regions_to_iterate = 3;
  98 
  99   jbyte cur_youngergen_card_val() {
 100     return _cur_youngergen_card_val;
 101   }
 102   void set_cur_youngergen_card_val(jbyte v) {
 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();


 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   }
 145 
 146   // Override.  Might want to devirtualize this in the same fashion as
 147   // above.  Ensures that the value of the card for field says that it's
 148   // a younger card in the current collection.
 149   virtual void write_ref_field_gc_par(void* field, oop new_val);
 150 
 151   void resize_covered_region(MemRegion new_region);
 152 
 153   bool is_aligned(HeapWord* addr) {
 154     return _ct_bs->is_card_aligned(addr);
 155   }
 156 
 157   void verify();
 158 
 159   void clear(MemRegion mr) { _ct_bs->clear(mr); }
 160   void clear_into_younger(Generation* old_gen);
 161 
 162   void invalidate(MemRegion mr, bool whole_heap = false) {
 163     _ct_bs->invalidate(mr, whole_heap);
 164   }
 165   void invalidate_or_clear(Generation* old_gen);
 166 
 167   static uintx ct_max_alignment_constraint() {
 168     return CardTableModRefBSForCTRS::ct_max_alignment_constraint();
 169   }
 170 
 171   jbyte* byte_for(void* p)     { return _ct_bs->byte_for(p); }
 172   jbyte* byte_after(void* p)   { return _ct_bs->byte_after(p); }
 173   HeapWord* addr_for(jbyte* p) { return _ct_bs->addr_for(p); }
 174 
 175   bool is_prev_nonclean_card_val(jbyte v) {
 176     return
 177       youngergen_card <= v &&
 178       v <= cur_youngergen_and_prev_nonclean_card &&
 179       v != _cur_youngergen_card_val;
 180   }
 181 
 182   static bool youngergen_may_have_been_dirty(jbyte cv) {
 183     return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card;
 184   }
 185 
 186 };
 187 
 188 class ClearNoncleanCardWrapper: public MemRegionClosure {
 189   DirtyCardToOopClosure* _dirty_card_closure;
 190   CardTableRS* _ct;
 191   bool _is_par;
 192 private:
 193   // Clears the given card, return true if the corresponding card should be
 194   // processed.
 195   inline bool clear_card(jbyte* entry);
 196   // Work methods called by the clear_card()
 197   inline bool clear_card_serial(jbyte* entry);
 198   inline bool clear_card_parallel(jbyte* entry);
 199   // check alignment of pointer
 200   bool is_word_aligned(jbyte* entry);
 201 
 202 public:
 203   ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct, bool is_par);
 204   void do_MemRegion(MemRegion mr);
 205 };
 206 
 207 #endif // SHARE_VM_GC_SHARED_CARDTABLERS_HPP


  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 
  88   // An array that contains, for each generation, the card table value last
  89   // used as the current value for a younger_refs_do iteration of that
  90   // portion of the table. The perm gen is index 0. The young gen is index 1,
  91   // but will always have the value "clean_card". The old gen is index 2.
  92   volatile jbyte* _last_cur_val_in_gen;
  93 
  94   jbyte _cur_youngergen_card_val;
  95 
  96   // Number of generations, plus one for lingering PermGen issues in CardTableRS.
  97   static const int _regions_to_iterate = 3;
  98 
  99   jbyte cur_youngergen_card_val() {
 100     return _cur_youngergen_card_val;
 101   }
 102   void set_cur_youngergen_card_val(jbyte v) {
 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();


 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     volatile 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   }
 145 
 146   // Override.  Might want to devirtualize this in the same fashion as
 147   // above.  Ensures that the value of the card for field says that it's
 148   // a younger card in the current collection.
 149   virtual void write_ref_field_gc_par(void* field, oop new_val);
 150 
 151   void resize_covered_region(MemRegion new_region);
 152 
 153   bool is_aligned(HeapWord* addr) {
 154     return _ct_bs->is_card_aligned(addr);
 155   }
 156 
 157   void verify();
 158 
 159   void clear(MemRegion mr) { _ct_bs->clear(mr); }
 160   void clear_into_younger(Generation* old_gen);
 161 
 162   void invalidate(MemRegion mr, bool whole_heap = false) {
 163     _ct_bs->invalidate(mr, whole_heap);
 164   }
 165   void invalidate_or_clear(Generation* old_gen);
 166 
 167   static uintx ct_max_alignment_constraint() {
 168     return CardTableModRefBSForCTRS::ct_max_alignment_constraint();
 169   }
 170 
 171   volatile jbyte* byte_for(void* p)     { return _ct_bs->byte_for(p); }
 172   volatile jbyte* byte_after(void* p)   { return _ct_bs->byte_after(p); }
 173   HeapWord* addr_for(volatile jbyte* p) { return _ct_bs->addr_for(p); }
 174 
 175   bool is_prev_nonclean_card_val(jbyte v) {
 176     return
 177       youngergen_card <= v &&
 178       v <= cur_youngergen_and_prev_nonclean_card &&
 179       v != _cur_youngergen_card_val;
 180   }
 181 
 182   static bool youngergen_may_have_been_dirty(jbyte cv) {
 183     return cv == CardTableRS::cur_youngergen_and_prev_nonclean_card;
 184   }
 185 
 186 };
 187 
 188 class ClearNoncleanCardWrapper: public MemRegionClosure {
 189   DirtyCardToOopClosure* _dirty_card_closure;
 190   CardTableRS* _ct;
 191   bool _is_par;
 192 private:
 193   // Clears the given card, return true if the corresponding card should be
 194   // processed.
 195   inline bool clear_card(volatile jbyte* entry);
 196   // Work methods called by the clear_card()
 197   inline bool clear_card_serial(volatile jbyte* entry);
 198   inline bool clear_card_parallel(volatile jbyte* entry);
 199   // check alignment of pointer
 200   bool is_word_aligned(volatile jbyte* entry);
 201 
 202 public:
 203   ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct, bool is_par);
 204   void do_MemRegion(MemRegion mr);
 205 };
 206 
 207 #endif // SHARE_VM_GC_SHARED_CARDTABLERS_HPP
< prev index next >