< prev index next >

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

Print this page
rev 12906 : [mq]: gc_interface


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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_MODREFBARRIERSET_HPP
  26 #define SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP
  27 
  28 #include "gc/shared/barrierSet.hpp"

  29 
  30 // This kind of "BarrierSet" allows a "CollectedHeap" to detect and
  31 // enumerate ref fields that have been modified (since the last
  32 // enumeration), using a card table.
  33 
  34 class OopClosure;
  35 class Generation;
  36 
  37 class ModRefBarrierSet: public BarrierSet {












  38 public:


  39 
  40   // Barriers only on ref writes.
  41   bool has_read_ref_barrier() { return false; }
  42   bool has_read_prim_barrier() { return false; }
  43   bool has_write_ref_barrier() { return true; }
  44   bool has_write_prim_barrier() { return false; }
  45 
  46   bool read_ref_needs_barrier(void* field) { return false; }
  47   bool read_prim_needs_barrier(HeapWord* field, size_t bytes) { return false; }
  48   bool write_prim_needs_barrier(HeapWord* field, size_t bytes,
  49                                 juint val1, juint val2) { return false; }
  50 
  51   void write_prim_field(oop obj, size_t offset, size_t bytes,
  52                         juint val1, juint val2) {}






  53 
  54   void read_ref_field(void* field) {}
  55   void read_prim_field(HeapWord* field, size_t bytes) {}



  56 
  57 protected:

  58 
  59   ModRefBarrierSet(const BarrierSet::FakeRtti& fake_rtti)
  60     : BarrierSet(fake_rtti.add_tag(BarrierSet::ModRef)) { }
  61   ~ModRefBarrierSet() { }
  62 
  63 public:
  64   void write_prim_field(HeapWord* field, size_t bytes,
  65                         juint val1, juint val2) {}
  66 
  67   bool has_read_ref_array_opt() { return false; }
  68   bool has_read_prim_array_opt() { return false; }
  69   bool has_write_prim_array_opt() { return false; }
  70 
  71   bool has_read_region_opt() { return false; }

  72 

  73 
  74   // These operations should assert false unless the corresponding operation
  75   // above returns true.
  76   void read_ref_array(MemRegion mr) {
  77     assert(false, "can't call");
  78   }
  79   void read_prim_array(MemRegion mr) {
  80     assert(false, "can't call");
  81   }
  82   void write_prim_array(MemRegion mr) {
  83     assert(false, "can't call");
  84   }
  85   void read_region(MemRegion mr) {
  86     assert(false, "can't call");
  87   }
  88 
  89   // Causes all refs in "mr" to be assumed to be modified.
  90   virtual void invalidate(MemRegion mr) = 0;



  91 
  92   // The caller guarantees that "mr" contains no references.  (Perhaps it's
  93   // objects have been moved elsewhere.)
  94   virtual void clear(MemRegion mr) = 0;

  95 };
  96 
  97 template<>
  98 struct BarrierSet::GetName<ModRefBarrierSet> {
  99   static const BarrierSet::Name value = BarrierSet::ModRef;





 100 };
 101 
 102 #endif // SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP


   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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_MODREFBARRIERSET_HPP
  26 #define SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP
  27 
  28 #include "gc/shared/barrierSet.hpp"
  29 #include "memory/memRegion.hpp"
  30 
  31 class Klass;





  32 
  33 class ModRefBarrierSet: public BarrierSet {
  34 protected:
  35   ModRefBarrierSet(const BarrierSet::FakeRtti& fake_rtti)
  36     : BarrierSet(fake_rtti.add_tag(BarrierSet::ModRef)) { }
  37   ~ModRefBarrierSet() { }
  38 
  39   virtual void write_ref_array_region(MemRegion mr) = 0;
  40 
  41   // These methods serve the only purpose of speeding up build times by reducing
  42   // included files
  43   static Klass* bound_for_array(oop obj);
  44   static bool is_bounded_by(oop obj, Klass* klass);
  45 
  46 public:
  47   // Causes all refs in "mr" to be assumed to be modified.
  48   virtual void invalidate(MemRegion mr) = 0;
  49 
  50   // Operations on arrays, or general regions (e.g., for "clone") may be
  51   // optimized by some barriers.








  52 
  53   // Below length is the # array elements being written
  54   virtual void write_ref_array_pre(oop* dst, int length,
  55                                    bool dest_uninitialized = false) {}
  56   virtual void write_ref_array_pre(narrowOop* dst, int length,
  57                                    bool dest_uninitialized = false) {}
  58   // Below count is the # array elements being written, starting
  59   // at the address "start", which may not necessarily be HeapWord-aligned
  60   inline void write_ref_array(HeapWord* start, size_t count);
  61 
  62   // Static versions, suitable for calling from generated code;
  63   // count is # array elements being written, starting with "start",
  64   // which may not necessarily be HeapWord-aligned.
  65   static void static_write_ref_array_pre(HeapWord* start, size_t count);
  66   static void static_write_ref_array_post(HeapWord* start, size_t count);
  67 
  68   template <DecoratorSet decorators>
  69   inline void write_ref_field_pre(void* addr) {}
  70 
  71   template <DecoratorSet decorators>
  72   inline void write_ref_field_post(void *addr, oop new_value) {}

  73 
  74   // barriers used by klass_oop_store
  75   void klass_update_barrier_set_pre(Klass* klass, oop* p) {}
  76   void klass_update_barrier_set(Klass* klass, oop* p, oop v);
  77 
  78   template <DecoratorSet decorators, typename BarrierSetT>
  79   class AccessBarrier: public BarrierSet::AccessBarrier<decorators> {
  80     typedef BarrierSet::AccessBarrier<decorators> Basic;
  81 
  82   public:
  83     typedef Basic SuperAccessBarrier;
  84 
  85     static void oop_store(void* addr, oop value);
  86 
  87     static oop oop_cas(oop new_value, void* addr, oop compare_value);
  88 
  89     static oop oop_swap(oop new_value, void* addr);
  90 
  91     template <typename T>
  92     static bool oop_copy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length);
  93 
  94     static void clone(oop src, oop dst, size_t size);
  95 
  96     static inline void oop_store_at(oop base, ptrdiff_t offset, oop value) {
  97       oop_store(Basic::field_addr(base, offset), value);


  98     }
  99 
 100     static inline void oop_store_at(Klass* base, ptrdiff_t offset, oop value);
 101 
 102     static inline oop oop_swap_at(oop new_value, oop base, ptrdiff_t offset) {
 103       return oop_swap(new_value, Basic::field_addr(base, offset));
 104     }
 105 
 106     static inline oop oop_cas_at(oop new_value, oop base, ptrdiff_t offset, oop compare_value) {
 107       return oop_cas(new_value, Basic::field_addr(base, offset), compare_value);
 108     }
 109   };
 110 };
 111 
 112 template<>
 113 struct BSTypeToName<ModRefBarrierSet> {
 114   static const BarrierSet::Name value = BarrierSet::ModRef;
 115 };
 116 
 117 template<>
 118 struct BSNameToType<BarrierSet::ModRef> {
 119   typedef ModRefBarrierSet type;
 120 };
 121 
 122 #endif // SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP
< prev index next >