< prev index next >

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

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

@@ -87,11 +87,11 @@
 
   // An array that contains, for each generation, the card table value last
   // used as the current value for a younger_refs_do iteration of that
   // portion of the table. The perm gen is index 0. The young gen is index 1,
   // but will always have the value "clean_card". The old gen is index 2.
-  jbyte* _last_cur_val_in_gen;
+  volatile jbyte* _last_cur_val_in_gen;
 
   jbyte _cur_youngergen_card_val;
 
   // Number of generations, plus one for lingering PermGen issues in CardTableRS.
   static const int _regions_to_iterate = 3;

@@ -134,11 +134,11 @@
   // responsible for dirtying if the oop is still older-to-younger after
   // closure application.
   void younger_refs_iterate(Generation* g, OopsInGenClosure* blk, uint n_threads);
 
   void inline_write_ref_field_gc(void* field, oop new_val) {
-    jbyte* byte = _ct_bs->byte_for(field);
+    volatile jbyte* byte = _ct_bs->byte_for(field);
     *byte = youngergen_card;
   }
   void write_ref_field_gc_work(void* field, oop new_val) {
     inline_write_ref_field_gc(field, new_val);
   }

@@ -166,13 +166,13 @@
 
   static uintx ct_max_alignment_constraint() {
     return CardTableModRefBSForCTRS::ct_max_alignment_constraint();
   }
 
-  jbyte* byte_for(void* p)     { return _ct_bs->byte_for(p); }
-  jbyte* byte_after(void* p)   { return _ct_bs->byte_after(p); }
-  HeapWord* addr_for(jbyte* p) { return _ct_bs->addr_for(p); }
+  volatile jbyte* byte_for(void* p)     { return _ct_bs->byte_for(p); }
+  volatile jbyte* byte_after(void* p)   { return _ct_bs->byte_after(p); }
+  HeapWord* addr_for(volatile jbyte* p) { return _ct_bs->addr_for(p); }
 
   bool is_prev_nonclean_card_val(jbyte v) {
     return
       youngergen_card <= v &&
       v <= cur_youngergen_and_prev_nonclean_card &&

@@ -190,16 +190,16 @@
   CardTableRS* _ct;
   bool _is_par;
 private:
   // Clears the given card, return true if the corresponding card should be
   // processed.
-  inline bool clear_card(jbyte* entry);
+  inline bool clear_card(volatile jbyte* entry);
   // Work methods called by the clear_card()
-  inline bool clear_card_serial(jbyte* entry);
-  inline bool clear_card_parallel(jbyte* entry);
+  inline bool clear_card_serial(volatile jbyte* entry);
+  inline bool clear_card_parallel(volatile jbyte* entry);
   // check alignment of pointer
-  bool is_word_aligned(jbyte* entry);
+  bool is_word_aligned(volatile jbyte* entry);
 
 public:
   ClearNoncleanCardWrapper(DirtyCardToOopClosure* dirty_card_closure, CardTableRS* ct, bool is_par);
   void do_MemRegion(MemRegion mr);
 };
< prev index next >