< prev index next >

src/share/vm/gc/shared/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_GC_SHARED_BARRIERSET_HPP
  26 #define SHARE_VM_GC_SHARED_BARRIERSET_HPP
  27 
  28 #include "memory/memRegion.hpp"
  29 #include "oops/oopsHierarchy.hpp"

  30 #include "utilities/fakeRttiSupport.hpp"
  31 
  32 // This class provides the interface between a barrier implementation and
  33 // the rest of the system.
  34 


  35 class BarrierSet: public CHeapObj<mtGC> {
  36   friend class VMStructs;
  37 public:
  38   // Fake RTTI support.  For a derived class T to participate
  39   // - T must have a corresponding Name entry.
  40   // - GetName<T> must be specialized to return the corresponding Name
  41   //   entry.
  42   // - If T is a base class, the constructor must have a FakeRtti
  43   //   parameter and pass it up to its base class, with the tag set
  44   //   augmented with the corresponding Name entry.
  45   // - If T is a concrete class, the constructor must create a
  46   //   FakeRtti object whose tag set includes the corresponding Name
  47   //   entry, and pass it up to its base class.
  48 
  49   enum Name {                   // associated class
  50     ModRef,                     // ModRefBarrierSet
  51     CardTableModRef,            // CardTableModRefBS
  52     CardTableForRS,             // CardTableModRefBSForCTRS
  53     CardTableExtension,         // CardTableExtension
  54     G1SATBCT,                   // G1SATBCardTableModRefBS
  55     G1SATBCTLogging             // G1SATBCardTableLoggingModRefBS

  56   };
  57 
  58 protected:
  59   typedef FakeRttiSupport<BarrierSet, Name> FakeRtti;
  60 
  61 private:
  62   FakeRtti _fake_rtti;
  63 
  64   // Metafunction mapping a class derived from BarrierSet to the
  65   // corresponding Name enum tag.
  66   template<typename T> struct GetName;
  67 
  68   // Downcast argument to a derived barrier set type.
  69   // The cast is checked in a debug build.
  70   // T must have a specialization for BarrierSet::GetName<T>.
  71   template<typename T> friend T* barrier_set_cast(BarrierSet* bs);
  72 
  73 public:
  74   // Note: This is not presently the Name corresponding to the
  75   // concrete class of this object.


 196   virtual void read_region(MemRegion mr) = 0;
 197 
 198   // (For efficiency reasons, this operation is specialized for certain
 199   // barrier types.  Semantically, it should be thought of as a call to the
 200   // virtual "_work" function below, which must implement the barrier.)
 201   void write_region(MemRegion mr);
 202 protected:
 203   virtual void write_region_work(MemRegion mr) = 0;
 204 public:
 205   // Inform the BarrierSet that the the covered heap region that starts
 206   // with "base" has been changed to have the given size (possibly from 0,
 207   // for initialization.)
 208   virtual void resize_covered_region(MemRegion new_region) = 0;
 209 
 210   // If the barrier set imposes any alignment restrictions on boundaries
 211   // within the heap, this function tells whether they are met.
 212   virtual bool is_aligned(HeapWord* addr) = 0;
 213 
 214   // Print a description of the memory for the barrier set
 215   virtual void print_on(outputStream* st) const = 0;


























 216 };
 217 
 218 template<typename T>
 219 inline T* barrier_set_cast(BarrierSet* bs) {
 220   assert(bs->is_a(BarrierSet::GetName<T>::value), "wrong type of barrier set");
 221   return static_cast<T*>(bs);
 222 }
 223 
 224 #endif // SHARE_VM_GC_SHARED_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_GC_SHARED_BARRIERSET_HPP
  26 #define SHARE_VM_GC_SHARED_BARRIERSET_HPP
  27 
  28 #include "memory/memRegion.hpp"
  29 #include "oops/oopsHierarchy.hpp"
  30 #include "asm/register.hpp"
  31 #include "utilities/fakeRttiSupport.hpp"
  32 
  33 // This class provides the interface between a barrier implementation and
  34 // the rest of the system.
  35 
  36 class MacroAssembler;
  37 
  38 class BarrierSet: public CHeapObj<mtGC> {
  39   friend class VMStructs;
  40 public:
  41   // Fake RTTI support.  For a derived class T to participate
  42   // - T must have a corresponding Name entry.
  43   // - GetName<T> must be specialized to return the corresponding Name
  44   //   entry.
  45   // - If T is a base class, the constructor must have a FakeRtti
  46   //   parameter and pass it up to its base class, with the tag set
  47   //   augmented with the corresponding Name entry.
  48   // - If T is a concrete class, the constructor must create a
  49   //   FakeRtti object whose tag set includes the corresponding Name
  50   //   entry, and pass it up to its base class.
  51 
  52   enum Name {                   // associated class
  53     ModRef,                     // ModRefBarrierSet
  54     CardTableModRef,            // CardTableModRefBS
  55     CardTableForRS,             // CardTableModRefBSForCTRS
  56     CardTableExtension,         // CardTableExtension
  57     G1SATBCT,                   // G1SATBCardTableModRefBS
  58     G1SATBCTLogging,            // G1SATBCardTableLoggingModRefBS
  59     ShenandoahBarrierSet        // ShenandoahBarrierSet
  60   };
  61 
  62 protected:
  63   typedef FakeRttiSupport<BarrierSet, Name> FakeRtti;
  64 
  65 private:
  66   FakeRtti _fake_rtti;
  67 
  68   // Metafunction mapping a class derived from BarrierSet to the
  69   // corresponding Name enum tag.
  70   template<typename T> struct GetName;
  71 
  72   // Downcast argument to a derived barrier set type.
  73   // The cast is checked in a debug build.
  74   // T must have a specialization for BarrierSet::GetName<T>.
  75   template<typename T> friend T* barrier_set_cast(BarrierSet* bs);
  76 
  77 public:
  78   // Note: This is not presently the Name corresponding to the
  79   // concrete class of this object.


 200   virtual void read_region(MemRegion mr) = 0;
 201 
 202   // (For efficiency reasons, this operation is specialized for certain
 203   // barrier types.  Semantically, it should be thought of as a call to the
 204   // virtual "_work" function below, which must implement the barrier.)
 205   void write_region(MemRegion mr);
 206 protected:
 207   virtual void write_region_work(MemRegion mr) = 0;
 208 public:
 209   // Inform the BarrierSet that the the covered heap region that starts
 210   // with "base" has been changed to have the given size (possibly from 0,
 211   // for initialization.)
 212   virtual void resize_covered_region(MemRegion new_region) = 0;
 213 
 214   // If the barrier set imposes any alignment restrictions on boundaries
 215   // within the heap, this function tells whether they are met.
 216   virtual bool is_aligned(HeapWord* addr) = 0;
 217 
 218   // Print a description of the memory for the barrier set
 219   virtual void print_on(outputStream* st) const = 0;
 220 
 221   virtual oop read_barrier(oop src) {
 222     return src;
 223   }
 224   virtual oop write_barrier(oop src) {
 225     return src;
 226   }
 227   virtual oop resolve_and_update_oop(oop* p, oop obj) {
 228     return obj;
 229   }
 230   virtual oop resolve_and_update_oop(narrowOop* p, oop obj) {
 231     return obj;
 232   }
 233 #ifndef CC_INTERP
 234   virtual void interpreter_read_barrier(MacroAssembler* masm, Register dst) {
 235     // Default implementation does nothing.
 236   }
 237 
 238   virtual void interpreter_read_barrier_not_null(MacroAssembler* masm, Register dst) {
 239     // Default implementation does nothing.
 240   }
 241 
 242   virtual void interpreter_write_barrier(MacroAssembler* masm, Register dst) {
 243     // Default implementation does nothing.
 244   }
 245 #endif
 246 };
 247 
 248 template<typename T>
 249 inline T* barrier_set_cast(BarrierSet* bs) {
 250   assert(bs->is_a(BarrierSet::GetName<T>::value), "wrong type of barrier set");
 251   return static_cast<T*>(bs);
 252 }
 253 
 254 #endif // SHARE_VM_GC_SHARED_BARRIERSET_HPP
< prev index next >