< prev index next >

src/share/vm/memory/barrierSet.hpp

Print this page




  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_MEMORY_BARRIERSET_HPP
  26 #define SHARE_VM_MEMORY_BARRIERSET_HPP
  27 
  28 #include "memory/memRegion.hpp"
  29 #include "oops/oopsHierarchy.hpp"

  30 
  31 // This class provides the interface between a barrier implementation and
  32 // the rest of the system.
  33 


  34 class BarrierSet: public CHeapObj<mtGC> {
  35   friend class VMStructs;
  36 public:
  37   enum Name {
  38     ModRef,
  39     CardTableModRef,
  40     CardTableExtension,
  41     G1SATBCT,
  42     G1SATBCTLogging,

  43     Other,
  44     Uninit
  45   };
  46 
  47   enum Flags {
  48     None                = 0,
  49     TargetUninitialized = 1
  50   };
  51 protected:
  52   int _max_covered_regions;
  53   Name _kind;
  54 
  55 public:
  56 
  57   BarrierSet() { _kind = Uninit; }
  58   // To get around prohibition on RTTI.
  59   BarrierSet::Name kind() { return _kind; }
  60   virtual bool is_a(BarrierSet::Name bsn) = 0;
  61 
  62   // These operations indicate what kind of barriers the BarrierSet has.


 120   virtual bool has_write_ref_array_pre_opt() { return true; }
 121   virtual bool has_write_ref_array_opt() = 0;
 122   virtual bool has_write_prim_array_opt() = 0;
 123 
 124   virtual bool has_read_region_opt() = 0;
 125   virtual bool has_write_region_opt() = 0;
 126 
 127   // These operations should assert false unless the correponding operation
 128   // above returns true.  Otherwise, they should perform an appropriate
 129   // barrier for an array whose elements are all in the given memory region.
 130   virtual void read_ref_array(MemRegion mr) = 0;
 131   virtual void read_prim_array(MemRegion mr) = 0;
 132 
 133   // Below length is the # array elements being written
 134   virtual void write_ref_array_pre(oop* dst, int length,
 135                                    bool dest_uninitialized = false) {}
 136   virtual void write_ref_array_pre(narrowOop* dst, int length,
 137                                    bool dest_uninitialized = false) {}
 138   // Below count is the # array elements being written, starting
 139   // at the address "start", which may not necessarily be HeapWord-aligned
 140   inline void write_ref_array(HeapWord* start, size_t count);
 141 
 142   // Static versions, suitable for calling from generated code;
 143   // count is # array elements being written, starting with "start",
 144   // which may not necessarily be HeapWord-aligned.
 145   static void static_write_ref_array_pre(HeapWord* start, size_t count);
 146   static void static_write_ref_array_post(HeapWord* start, size_t count);
 147 
 148 protected:
 149   virtual void write_ref_array_work(MemRegion mr) = 0;
 150 public:
 151   virtual void write_prim_array(MemRegion mr) = 0;
 152 
 153   virtual void read_region(MemRegion mr) = 0;
 154 
 155   // (For efficiency reasons, this operation is specialized for certain
 156   // barrier types.  Semantically, it should be thought of as a call to the
 157   // virtual "_work" function below, which must implement the barrier.)
 158   inline void write_region(MemRegion mr);
 159 protected:
 160   virtual void write_region_work(MemRegion mr) = 0;


 165   // normally reserve space for such tables, and commit parts of the table
 166   // "covering" parts of the heap that are committed.  The constructor is
 167   // passed the maximum number of independently committable subregions to
 168   // be covered, and the "resize_covoered_region" function allows the
 169   // sub-parts of the heap to inform the barrier set of changes of their
 170   // sizes.
 171   BarrierSet(int max_covered_regions) :
 172     _max_covered_regions(max_covered_regions) {}
 173 
 174   // Inform the BarrierSet that the the covered heap region that starts
 175   // with "base" has been changed to have the given size (possibly from 0,
 176   // for initialization.)
 177   virtual void resize_covered_region(MemRegion new_region) = 0;
 178 
 179   // If the barrier set imposes any alignment restrictions on boundaries
 180   // within the heap, this function tells whether they are met.
 181   virtual bool is_aligned(HeapWord* addr) = 0;
 182 
 183   // Print a description of the memory for the barrier set
 184   virtual void print_on(outputStream* st) const = 0;




























 185 };
 186 
 187 #endif // SHARE_VM_MEMORY_BARRIERSET_HPP


  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_MEMORY_BARRIERSET_HPP
  26 #define SHARE_VM_MEMORY_BARRIERSET_HPP
  27 
  28 #include "memory/memRegion.hpp"
  29 #include "oops/oopsHierarchy.hpp"
  30 #include "asm/register.hpp"
  31 
  32 // This class provides the interface between a barrier implementation and
  33 // the rest of the system.
  34 
  35 class MacroAssembler;
  36 
  37 class BarrierSet: public CHeapObj<mtGC> {
  38   friend class VMStructs;
  39 public:
  40   enum Name {
  41     ModRef,
  42     CardTableModRef,
  43     CardTableExtension,
  44     G1SATBCT,
  45     G1SATBCTLogging,
  46     ShenandoahBarrierSet,
  47     Other,
  48     Uninit
  49   };
  50 
  51   enum Flags {
  52     None                = 0,
  53     TargetUninitialized = 1
  54   };
  55 protected:
  56   int _max_covered_regions;
  57   Name _kind;
  58 
  59 public:
  60 
  61   BarrierSet() { _kind = Uninit; }
  62   // To get around prohibition on RTTI.
  63   BarrierSet::Name kind() { return _kind; }
  64   virtual bool is_a(BarrierSet::Name bsn) = 0;
  65 
  66   // These operations indicate what kind of barriers the BarrierSet has.


 124   virtual bool has_write_ref_array_pre_opt() { return true; }
 125   virtual bool has_write_ref_array_opt() = 0;
 126   virtual bool has_write_prim_array_opt() = 0;
 127 
 128   virtual bool has_read_region_opt() = 0;
 129   virtual bool has_write_region_opt() = 0;
 130 
 131   // These operations should assert false unless the correponding operation
 132   // above returns true.  Otherwise, they should perform an appropriate
 133   // barrier for an array whose elements are all in the given memory region.
 134   virtual void read_ref_array(MemRegion mr) = 0;
 135   virtual void read_prim_array(MemRegion mr) = 0;
 136 
 137   // Below length is the # array elements being written
 138   virtual void write_ref_array_pre(oop* dst, int length,
 139                                    bool dest_uninitialized = false) {}
 140   virtual void write_ref_array_pre(narrowOop* dst, int length,
 141                                    bool dest_uninitialized = false) {}
 142   // Below count is the # array elements being written, starting
 143   // at the address "start", which may not necessarily be HeapWord-aligned
 144   virtual void write_ref_array(HeapWord* start, size_t count);
 145 
 146   // Static versions, suitable for calling from generated code;
 147   // count is # array elements being written, starting with "start",
 148   // which may not necessarily be HeapWord-aligned.
 149   static void static_write_ref_array_pre(HeapWord* start, size_t count);
 150   static void static_write_ref_array_post(HeapWord* start, size_t count);
 151 
 152 protected:
 153   virtual void write_ref_array_work(MemRegion mr) = 0;
 154 public:
 155   virtual void write_prim_array(MemRegion mr) = 0;
 156 
 157   virtual void read_region(MemRegion mr) = 0;
 158 
 159   // (For efficiency reasons, this operation is specialized for certain
 160   // barrier types.  Semantically, it should be thought of as a call to the
 161   // virtual "_work" function below, which must implement the barrier.)
 162   inline void write_region(MemRegion mr);
 163 protected:
 164   virtual void write_region_work(MemRegion mr) = 0;


 169   // normally reserve space for such tables, and commit parts of the table
 170   // "covering" parts of the heap that are committed.  The constructor is
 171   // passed the maximum number of independently committable subregions to
 172   // be covered, and the "resize_covoered_region" function allows the
 173   // sub-parts of the heap to inform the barrier set of changes of their
 174   // sizes.
 175   BarrierSet(int max_covered_regions) :
 176     _max_covered_regions(max_covered_regions) {}
 177 
 178   // Inform the BarrierSet that the the covered heap region that starts
 179   // with "base" has been changed to have the given size (possibly from 0,
 180   // for initialization.)
 181   virtual void resize_covered_region(MemRegion new_region) = 0;
 182 
 183   // If the barrier set imposes any alignment restrictions on boundaries
 184   // within the heap, this function tells whether they are met.
 185   virtual bool is_aligned(HeapWord* addr) = 0;
 186 
 187   // Print a description of the memory for the barrier set
 188   virtual void print_on(outputStream* st) const = 0;
 189 
 190   virtual oop read_barrier(oop src) {
 191     return src;
 192   }
 193   virtual oop write_barrier(oop src) {
 194     return src;
 195   }
 196 
 197   virtual bool obj_equals(oop obj1, oop obj2);
 198 
 199   virtual bool obj_equals(narrowOop obj1, narrowOop obj2);
 200 
 201 #ifndef CC_INTERP
 202   virtual void interpreter_read_barrier(MacroAssembler* masm, Register dst) {
 203     // Default implementation does nothing.
 204   }
 205 
 206   virtual void interpreter_read_barrier_not_null(MacroAssembler* masm, Register dst) {
 207     // Default implementation does nothing.
 208   }
 209 
 210   virtual void interpreter_write_barrier(MacroAssembler* masm, Register dst) {
 211     // Default implementation does nothing.
 212   }
 213   virtual void asm_acmp_barrier(MacroAssembler* masm, Register op1, Register op2) {
 214     // Default implementation does nothing.
 215   }
 216 #endif
 217 };
 218 
 219 #endif // SHARE_VM_MEMORY_BARRIERSET_HPP
< prev index next >