24 |
24 |
25 #ifndef SHARE_VM_GC_SHARED_CARDTABLEMODREFBS_HPP |
25 #ifndef SHARE_VM_GC_SHARED_CARDTABLEMODREFBS_HPP |
26 #define SHARE_VM_GC_SHARED_CARDTABLEMODREFBS_HPP |
26 #define SHARE_VM_GC_SHARED_CARDTABLEMODREFBS_HPP |
27 |
27 |
28 #include "gc/shared/modRefBarrierSet.hpp" |
28 #include "gc/shared/modRefBarrierSet.hpp" |
29 #include "oops/oop.hpp" |
|
30 #include "utilities/align.hpp" |
29 #include "utilities/align.hpp" |
31 |
30 |
32 // This kind of "BarrierSet" allows a "CollectedHeap" to detect and |
31 // This kind of "BarrierSet" allows a "CollectedHeap" to detect and |
33 // enumerate ref fields that have been modified (since the last |
32 // enumerate ref fields that have been modified (since the last |
34 // enumeration.) |
33 // enumeration.) |
179 |
178 |
180 protected: |
179 protected: |
181 CardTableModRefBS(MemRegion whole_heap, const BarrierSet::FakeRtti& fake_rtti); |
180 CardTableModRefBS(MemRegion whole_heap, const BarrierSet::FakeRtti& fake_rtti); |
182 ~CardTableModRefBS(); |
181 ~CardTableModRefBS(); |
183 |
182 |
|
183 protected: |
|
184 void write_region_work(MemRegion mr) { |
|
185 dirty_MemRegion(mr); |
|
186 } |
|
187 |
|
188 protected: |
|
189 void write_ref_array_work(MemRegion mr) { |
|
190 dirty_MemRegion(mr); |
|
191 } |
|
192 |
|
193 public: |
|
194 bool is_aligned(HeapWord* addr) { |
|
195 return is_card_aligned(addr); |
|
196 } |
|
197 |
|
198 // *** Card-table-barrier-specific things. |
|
199 |
184 // Record a reference update. Note that these versions are precise! |
200 // Record a reference update. Note that these versions are precise! |
185 // The scanning code has to handle the fact that the write barrier may be |
201 // The scanning code has to handle the fact that the write barrier may be |
186 // either precise or imprecise. We make non-virtual inline variants of |
202 // either precise or imprecise. We make non-virtual inline variants of |
187 // these functions here for performance. |
203 // these functions here for performance. |
188 |
204 template <DecoratorSet decorators, typename T> |
189 void write_ref_field_work(oop obj, size_t offset, oop newVal); |
205 void write_ref_field_post(T* field, oop newVal); |
190 virtual void write_ref_field_work(void* field, oop newVal, bool release); |
|
191 |
|
192 protected: |
|
193 void write_region_work(MemRegion mr) { |
|
194 dirty_MemRegion(mr); |
|
195 } |
|
196 |
|
197 protected: |
|
198 void write_ref_array_work(MemRegion mr) { |
|
199 dirty_MemRegion(mr); |
|
200 } |
|
201 |
|
202 public: |
|
203 bool is_aligned(HeapWord* addr) { |
|
204 return is_card_aligned(addr); |
|
205 } |
|
206 |
|
207 // *** Card-table-barrier-specific things. |
|
208 |
|
209 template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal) {} |
|
210 |
|
211 template <class T> inline void inline_write_ref_field(T* field, oop newVal, bool release); |
|
212 |
206 |
213 // These are used by G1, when it uses the card table as a temporary data |
207 // These are used by G1, when it uses the card table as a temporary data |
214 // structure for card claiming. |
208 // structure for card claiming. |
215 bool is_card_dirty(size_t card_index) { |
209 bool is_card_dirty(size_t card_index) { |
216 return _byte_map[card_index] == dirty_card_val(); |
210 return _byte_map[card_index] == dirty_card_val(); |
317 // val_equals -> it will check that all cards covered by mr equal val |
311 // val_equals -> it will check that all cards covered by mr equal val |
318 // !val_equals -> it will check that all cards covered by mr do not equal val |
312 // !val_equals -> it will check that all cards covered by mr do not equal val |
319 void verify_region(MemRegion mr, jbyte val, bool val_equals) PRODUCT_RETURN; |
313 void verify_region(MemRegion mr, jbyte val, bool val_equals) PRODUCT_RETURN; |
320 void verify_not_dirty_region(MemRegion mr) PRODUCT_RETURN; |
314 void verify_not_dirty_region(MemRegion mr) PRODUCT_RETURN; |
321 void verify_dirty_region(MemRegion mr) PRODUCT_RETURN; |
315 void verify_dirty_region(MemRegion mr) PRODUCT_RETURN; |
|
316 |
|
317 template <DecoratorSet decorators, typename BarrierSetT = CardTableModRefBS> |
|
318 class AccessBarrier: public ModRefBarrierSet::AccessBarrier<decorators, BarrierSetT> {}; |
322 }; |
319 }; |
323 |
320 |
324 template<> |
321 template<> |
325 struct BarrierSet::GetName<CardTableModRefBS> { |
322 struct BarrierSet::GetName<CardTableModRefBS> { |
326 static const BarrierSet::Name value = BarrierSet::CardTableModRef; |
323 static const BarrierSet::Name value = BarrierSet::CardTableModRef; |
327 }; |
324 }; |
328 |
325 |
|
326 template<> |
|
327 struct BarrierSet::GetType<BarrierSet::CardTableModRef> { |
|
328 typedef CardTableModRefBS type; |
|
329 }; |
329 |
330 |
330 #endif // SHARE_VM_GC_SHARED_CARDTABLEMODREFBS_HPP |
331 #endif // SHARE_VM_GC_SHARED_CARDTABLEMODREFBS_HPP |