< prev index next >

src/share/vm/gc_implementation/g1/g1SATBCardTableModRefBS.hpp

Print this page
rev 7807 : [mq]: bcast


  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1SATBCARDTABLEMODREFBS_HPP
  27 
  28 #include "gc_implementation/g1/g1RegionToSpaceMapper.hpp"
  29 #include "memory/cardTableModRefBS.hpp"
  30 #include "memory/memRegion.hpp"
  31 #include "oops/oop.hpp"
  32 #include "utilities/macros.hpp"
  33 
  34 class DirtyCardQueueSet;
  35 class G1SATBCardTableLoggingModRefBS;
  36 
  37 // This barrier is specialized to use a logging barrier to support
  38 // snapshot-at-the-beginning marking.
  39 
  40 class G1SATBCardTableModRefBS: public CardTableModRefBS {
  41 protected:
  42   enum G1CardValues {
  43     g1_young_gen = CT_MR_BS_last_reserved << 1
  44   };
  45 
  46   G1SATBCardTableModRefBS(MemRegion whole_heap, BarrierSet::Name kind);
  47   ~G1SATBCardTableModRefBS() { }
  48 
  49 public:
  50   static int g1_young_card_val()   { return g1_young_gen; }
  51 
  52   // Add "pre_val" to a set of objects that may have been disconnected from the
  53   // pre-marking object graph.
  54   static void enqueue(oop pre_val);
  55 
  56   bool is_a(BarrierSet::Name bsn) {
  57     return bsn == BarrierSet::G1SATBCT || CardTableModRefBS::is_a(bsn);
  58   }
  59 
  60   virtual bool has_write_ref_pre_barrier() { return true; }
  61 
  62   // This notes that we don't need to access any BarrierSet data
  63   // structures, so this can be called from a static context.
  64   template <class T> static void write_ref_field_pre_static(T* field, oop newVal) {
  65     T heap_oop = oopDesc::load_heap_oop(field);
  66     if (!oopDesc::is_null(heap_oop)) {
  67       enqueue(oopDesc::decode_heap_oop(heap_oop));
  68     }
  69   }
  70 
  71   // We export this to make it available in cases where the static
  72   // type of the barrier set is known.  Note that it is non-virtual.
  73   template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal) {
  74     write_ref_field_pre_static(field, newVal);
  75   }
  76 
  77   // These are the more general virtual versions.
  78   virtual void write_ref_field_pre_work(oop* field, oop new_val) {
  79     inline_write_ref_field_pre(field, new_val);


 111       jbyte val = _byte_map[card_index];
 112       if (val == clean_card_val()) {
 113         val = (jbyte)claimed_card_val();
 114       } else {
 115         val |= (jbyte)claimed_card_val();
 116       }
 117       _byte_map[card_index] = val;
 118   }
 119 
 120   void verify_g1_young_region(MemRegion mr) PRODUCT_RETURN;
 121   void g1_mark_as_young(const MemRegion& mr);
 122 
 123   bool mark_card_deferred(size_t card_index);
 124 
 125   bool is_card_deferred(size_t card_index) {
 126     jbyte val = _byte_map[card_index];
 127     return (val & (clean_card_mask_val() | deferred_card_val())) == deferred_card_val();
 128   }
 129 };
 130 





 131 class G1SATBCardTableLoggingModRefBSChangedListener : public G1MappingChangedListener {
 132  private:
 133   G1SATBCardTableLoggingModRefBS* _card_table;
 134  public:
 135   G1SATBCardTableLoggingModRefBSChangedListener() : _card_table(NULL) { }
 136 
 137   void set_card_table(G1SATBCardTableLoggingModRefBS* card_table) { _card_table = card_table; }
 138 
 139   virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);
 140 };
 141 
 142 // Adds card-table logging to the post-barrier.
 143 // Usual invariant: all dirty cards are logged in the DirtyCardQueueSet.
 144 class G1SATBCardTableLoggingModRefBS: public G1SATBCardTableModRefBS {
 145   friend class G1SATBCardTableLoggingModRefBSChangedListener;
 146  private:
 147   G1SATBCardTableLoggingModRefBSChangedListener _listener;
 148   DirtyCardQueueSet& _dcqs;
 149  public:
 150   static size_t compute_size(size_t mem_region_size_in_words) {
 151     size_t number_of_slots = (mem_region_size_in_words / card_size_in_words);
 152     return ReservedSpace::allocation_align_size_up(number_of_slots);
 153   }
 154 
 155   G1SATBCardTableLoggingModRefBS(MemRegion whole_heap);
 156 
 157   virtual void initialize() { }
 158   virtual void initialize(G1RegionToSpaceMapper* mapper);
 159 
 160   virtual void resize_covered_region(MemRegion new_region) { ShouldNotReachHere(); }
 161 
 162   bool is_a(BarrierSet::Name bsn) {
 163     return bsn == BarrierSet::G1SATBCTLogging ||
 164       G1SATBCardTableModRefBS::is_a(bsn);
 165   }
 166 
 167   void write_ref_field_work(void* field, oop new_val, bool release = false);
 168 
 169   // Can be called from static contexts.
 170   static void write_ref_field_static(void* field, oop new_val);
 171 
 172   // NB: if you do a whole-heap invalidation, the "usual invariant" defined
 173   // above no longer applies.
 174   void invalidate(MemRegion mr, bool whole_heap = false);
 175 
 176   void write_region_work(MemRegion mr)    { invalidate(mr); }
 177   void write_ref_array_work(MemRegion mr) { invalidate(mr); }





 178 };
 179 
 180 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1SATBCARDTABLEMODREFBS_HPP


  26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1SATBCARDTABLEMODREFBS_HPP
  27 
  28 #include "gc_implementation/g1/g1RegionToSpaceMapper.hpp"
  29 #include "memory/cardTableModRefBS.hpp"
  30 #include "memory/memRegion.hpp"
  31 #include "oops/oop.hpp"
  32 #include "utilities/macros.hpp"
  33 
  34 class DirtyCardQueueSet;
  35 class G1SATBCardTableLoggingModRefBS;
  36 
  37 // This barrier is specialized to use a logging barrier to support
  38 // snapshot-at-the-beginning marking.
  39 
  40 class G1SATBCardTableModRefBS: public CardTableModRefBS {
  41 protected:
  42   enum G1CardValues {
  43     g1_young_gen = CT_MR_BS_last_reserved << 1
  44   };
  45 
  46   G1SATBCardTableModRefBS(MemRegion whole_heap, const BarrierSet::FakeRtti& fake_rtti);
  47   ~G1SATBCardTableModRefBS() { }
  48 
  49 public:
  50   static int g1_young_card_val()   { return g1_young_gen; }
  51 
  52   // Add "pre_val" to a set of objects that may have been disconnected from the
  53   // pre-marking object graph.
  54   static void enqueue(oop pre_val);
  55 




  56   virtual bool has_write_ref_pre_barrier() { return true; }
  57 
  58   // This notes that we don't need to access any BarrierSet data
  59   // structures, so this can be called from a static context.
  60   template <class T> static void write_ref_field_pre_static(T* field, oop newVal) {
  61     T heap_oop = oopDesc::load_heap_oop(field);
  62     if (!oopDesc::is_null(heap_oop)) {
  63       enqueue(oopDesc::decode_heap_oop(heap_oop));
  64     }
  65   }
  66 
  67   // We export this to make it available in cases where the static
  68   // type of the barrier set is known.  Note that it is non-virtual.
  69   template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal) {
  70     write_ref_field_pre_static(field, newVal);
  71   }
  72 
  73   // These are the more general virtual versions.
  74   virtual void write_ref_field_pre_work(oop* field, oop new_val) {
  75     inline_write_ref_field_pre(field, new_val);


 107       jbyte val = _byte_map[card_index];
 108       if (val == clean_card_val()) {
 109         val = (jbyte)claimed_card_val();
 110       } else {
 111         val |= (jbyte)claimed_card_val();
 112       }
 113       _byte_map[card_index] = val;
 114   }
 115 
 116   void verify_g1_young_region(MemRegion mr) PRODUCT_RETURN;
 117   void g1_mark_as_young(const MemRegion& mr);
 118 
 119   bool mark_card_deferred(size_t card_index);
 120 
 121   bool is_card_deferred(size_t card_index) {
 122     jbyte val = _byte_map[card_index];
 123     return (val & (clean_card_mask_val() | deferred_card_val())) == deferred_card_val();
 124   }
 125 };
 126 
 127 template<>
 128 struct BarrierSet::GetName<G1SATBCardTableModRefBS> {
 129   static const BarrierSet::Name value = BarrierSet::G1SATBCT;
 130 };
 131 
 132 class G1SATBCardTableLoggingModRefBSChangedListener : public G1MappingChangedListener {
 133  private:
 134   G1SATBCardTableLoggingModRefBS* _card_table;
 135  public:
 136   G1SATBCardTableLoggingModRefBSChangedListener() : _card_table(NULL) { }
 137 
 138   void set_card_table(G1SATBCardTableLoggingModRefBS* card_table) { _card_table = card_table; }
 139 
 140   virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);
 141 };
 142 
 143 // Adds card-table logging to the post-barrier.
 144 // Usual invariant: all dirty cards are logged in the DirtyCardQueueSet.
 145 class G1SATBCardTableLoggingModRefBS: public G1SATBCardTableModRefBS {
 146   friend class G1SATBCardTableLoggingModRefBSChangedListener;
 147  private:
 148   G1SATBCardTableLoggingModRefBSChangedListener _listener;
 149   DirtyCardQueueSet& _dcqs;
 150  public:
 151   static size_t compute_size(size_t mem_region_size_in_words) {
 152     size_t number_of_slots = (mem_region_size_in_words / card_size_in_words);
 153     return ReservedSpace::allocation_align_size_up(number_of_slots);
 154   }
 155 
 156   G1SATBCardTableLoggingModRefBS(MemRegion whole_heap);
 157 
 158   virtual void initialize() { }
 159   virtual void initialize(G1RegionToSpaceMapper* mapper);
 160 
 161   virtual void resize_covered_region(MemRegion new_region) { ShouldNotReachHere(); }
 162 





 163   void write_ref_field_work(void* field, oop new_val, bool release = false);
 164 
 165   // Can be called from static contexts.
 166   static void write_ref_field_static(void* field, oop new_val);
 167 
 168   // NB: if you do a whole-heap invalidation, the "usual invariant" defined
 169   // above no longer applies.
 170   void invalidate(MemRegion mr, bool whole_heap = false);
 171 
 172   void write_region_work(MemRegion mr)    { invalidate(mr); }
 173   void write_ref_array_work(MemRegion mr) { invalidate(mr); }
 174 };
 175 
 176 template<>
 177 struct BarrierSet::GetName<G1SATBCardTableLoggingModRefBS> {
 178   static const BarrierSet::Name value = BarrierSet::G1SATBCTLogging;
 179 };
 180 
 181 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1SATBCARDTABLEMODREFBS_HPP
< prev index next >