< prev index next >

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

Print this page
rev 12906 : [mq]: gc_interface

*** 23,72 **** */ #ifndef SHARE_VM_GC_SHARED_BARRIERSET_HPP #define SHARE_VM_GC_SHARED_BARRIERSET_HPP ! #include "memory/memRegion.hpp" ! #include "oops/oopsHierarchy.hpp" #include "utilities/fakeRttiSupport.hpp" // This class provides the interface between a barrier implementation and // the rest of the system. class BarrierSet: public CHeapObj<mtGC> { friend class VMStructs; public: // Fake RTTI support. For a derived class T to participate // - T must have a corresponding Name entry. // - GetName<T> must be specialized to return the corresponding Name // entry. // - If T is a base class, the constructor must have a FakeRtti // parameter and pass it up to its base class, with the tag set // augmented with the corresponding Name entry. // - If T is a concrete class, the constructor must create a // FakeRtti object whose tag set includes the corresponding Name // entry, and pass it up to its base class. - - enum Name { // associated class - ModRef, // ModRefBarrierSet - CardTableModRef, // CardTableModRefBS - CardTableForRS, // CardTableModRefBSForCTRS - CardTableExtension, // CardTableExtension - G1SATBCT, // G1SATBCardTableModRefBS - G1SATBCTLogging // G1SATBCardTableLoggingModRefBS - }; - - protected: typedef FakeRttiSupport<BarrierSet, Name> FakeRtti; private: FakeRtti _fake_rtti; - // Metafunction mapping a class derived from BarrierSet to the - // corresponding Name enum tag. - template<typename T> struct GetName; - // Downcast argument to a derived barrier set type. // The cast is checked in a debug build. // T must have a specialization for BarrierSet::GetName<T>. template<typename T> friend T* barrier_set_cast(BarrierSet* bs); --- 23,70 ---- */ #ifndef SHARE_VM_GC_SHARED_BARRIERSET_HPP #define SHARE_VM_GC_SHARED_BARRIERSET_HPP ! #include "gc/shared/barrierSetConfig.hpp" ! #include "runtime/access.hpp" ! #include "runtime/accessBackend.hpp" #include "utilities/fakeRttiSupport.hpp" + class JavaThread; + class BarrierSetCodeGen; + class C1BarrierSetCodeGen; + class C2BarrierSetCodeGen; + // This class provides the interface between a barrier implementation and // the rest of the system. class BarrierSet: public CHeapObj<mtGC> { friend class VMStructs; public: + enum Name { + #define BARRIER_SET_DECLARE_BS_ENUM(bs_name) bs_name , + FOR_EACH_BARRIER_SET_DO(BARRIER_SET_DECLARE_BS_ENUM) + #undef BARRIER_SET_DECLARE_BS_ENUM + UnknownBS + }; + protected: // Fake RTTI support. For a derived class T to participate // - T must have a corresponding Name entry. // - GetName<T> must be specialized to return the corresponding Name // entry. // - If T is a base class, the constructor must have a FakeRtti // parameter and pass it up to its base class, with the tag set // augmented with the corresponding Name entry. // - If T is a concrete class, the constructor must create a // FakeRtti object whose tag set includes the corresponding Name // entry, and pass it up to its base class. typedef FakeRttiSupport<BarrierSet, Name> FakeRtti; private: FakeRtti _fake_rtti; // Downcast argument to a derived barrier set type. // The cast is checked in a debug build. // T must have a specialization for BarrierSet::GetName<T>. template<typename T> friend T* barrier_set_cast(BarrierSet* bs);
*** 78,227 **** // Test whether this object is of the type corresponding to bsn. bool is_a(BarrierSet::Name bsn) const { return _fake_rtti.has_tag(bsn); } // End of fake RTTI support. - public: - enum Flags { - None = 0, - TargetUninitialized = 1 - }; - protected: ! // Some barrier sets create tables whose elements correspond to parts of ! // the heap; the CardTableModRefBS is an example. Such barrier sets will ! // normally reserve space for such tables, and commit parts of the table ! // "covering" parts of the heap that are committed. At most one covered ! // region per generation is needed. ! static const int _max_covered_regions = 2; ! ! BarrierSet(const FakeRtti& fake_rtti) : _fake_rtti(fake_rtti) { } ~BarrierSet() { } ! public: ! // These operations indicate what kind of barriers the BarrierSet has. ! virtual bool has_read_ref_barrier() = 0; ! virtual bool has_read_prim_barrier() = 0; ! virtual bool has_write_ref_barrier() = 0; ! virtual bool has_write_ref_pre_barrier() = 0; ! virtual bool has_write_prim_barrier() = 0; ! ! // These functions indicate whether a particular access of the given ! // kinds requires a barrier. ! virtual bool read_ref_needs_barrier(void* field) = 0; ! virtual bool read_prim_needs_barrier(HeapWord* field, size_t bytes) = 0; ! virtual bool write_prim_needs_barrier(HeapWord* field, size_t bytes, ! juint val1, juint val2) = 0; ! ! // The first four operations provide a direct implementation of the ! // barrier set. An interpreter loop, for example, could call these ! // directly, as appropriate. ! ! // Invoke the barrier, if any, necessary when reading the given ref field. ! virtual void read_ref_field(void* field) = 0; ! ! // Invoke the barrier, if any, necessary when reading the given primitive ! // "field" of "bytes" bytes in "obj". ! virtual void read_prim_field(HeapWord* field, size_t bytes) = 0; ! ! // Invoke the barrier, if any, necessary when writing "new_val" into the ! // ref field at "offset" in "obj". ! // (For efficiency reasons, this operation is specialized for certain ! // barrier types. Semantically, it should be thought of as a call to the ! // virtual "_work" function below, which must implement the barrier.) ! // First the pre-write versions... ! template <class T> inline void write_ref_field_pre(T* field, oop new_val); ! private: ! // Helper for write_ref_field_pre and friends, testing for specialized cases. ! bool devirtualize_reference_writes() const; ! // Keep this private so as to catch violations at build time. ! virtual void write_ref_field_pre_work( void* field, oop new_val) { guarantee(false, "Not needed"); }; ! protected: ! virtual void write_ref_field_pre_work( oop* field, oop new_val) {}; ! virtual void write_ref_field_pre_work(narrowOop* field, oop new_val) {}; ! public: - // ...then the post-write version. - inline void write_ref_field(void* field, oop new_val, bool release = false); - protected: - virtual void write_ref_field_work(void* field, oop new_val, bool release) = 0; public: ! // Invoke the barrier, if any, necessary when writing the "bytes"-byte ! // value(s) "val1" (and "val2") into the primitive "field". ! virtual void write_prim_field(HeapWord* field, size_t bytes, ! juint val1, juint val2) = 0; ! ! // Operations on arrays, or general regions (e.g., for "clone") may be ! // optimized by some barriers. ! ! // The first six operations tell whether such an optimization exists for ! // the particular barrier. ! virtual bool has_read_ref_array_opt() = 0; ! virtual bool has_read_prim_array_opt() = 0; ! virtual bool has_write_ref_array_pre_opt() { return true; } ! virtual bool has_write_ref_array_opt() = 0; ! virtual bool has_write_prim_array_opt() = 0; ! ! virtual bool has_read_region_opt() = 0; ! virtual bool has_write_region_opt() = 0; ! ! // These operations should assert false unless the corresponding operation ! // above returns true. Otherwise, they should perform an appropriate ! // barrier for an array whose elements are all in the given memory region. ! virtual void read_ref_array(MemRegion mr) = 0; ! virtual void read_prim_array(MemRegion mr) = 0; ! ! // Below length is the # array elements being written ! virtual void write_ref_array_pre(oop* dst, int length, ! bool dest_uninitialized = false) {} ! virtual void write_ref_array_pre(narrowOop* dst, int length, ! bool dest_uninitialized = false) {} ! // Below count is the # array elements being written, starting ! // at the address "start", which may not necessarily be HeapWord-aligned ! inline void write_ref_array(HeapWord* start, size_t count); ! ! // Static versions, suitable for calling from generated code; ! // count is # array elements being written, starting with "start", ! // which may not necessarily be HeapWord-aligned. ! static void static_write_ref_array_pre(HeapWord* start, size_t count); ! static void static_write_ref_array_post(HeapWord* start, size_t count); ! virtual void write_ref_nmethod_pre(oop* dst, nmethod* nm) {} ! virtual void write_ref_nmethod_post(oop* dst, nmethod* nm) {} ! protected: ! virtual void write_ref_array_work(MemRegion mr) = 0; ! public: ! virtual void write_prim_array(MemRegion mr) = 0; ! virtual void read_region(MemRegion mr) = 0; ! // (For efficiency reasons, this operation is specialized for certain ! // barrier types. Semantically, it should be thought of as a call to the ! // virtual "_work" function below, which must implement the barrier.) ! void write_region(MemRegion mr); ! protected: ! virtual void write_region_work(MemRegion mr) = 0; ! public: ! // Inform the BarrierSet that the the covered heap region that starts ! // with "base" has been changed to have the given size (possibly from 0, ! // for initialization.) ! virtual void resize_covered_region(MemRegion new_region) = 0; ! ! // If the barrier set imposes any alignment restrictions on boundaries ! // within the heap, this function tells whether they are met. ! virtual bool is_aligned(HeapWord* addr) = 0; ! // Print a description of the memory for the barrier set ! virtual void print_on(outputStream* st) const = 0; }; template<typename T> inline T* barrier_set_cast(BarrierSet* bs) { ! assert(bs->is_a(BarrierSet::GetName<T>::value), "wrong type of barrier set"); return static_cast<T*>(bs); } #endif // SHARE_VM_GC_SHARED_BARRIERSET_HPP --- 76,166 ---- // Test whether this object is of the type corresponding to bsn. bool is_a(BarrierSet::Name bsn) const { return _fake_rtti.has_tag(bsn); } // End of fake RTTI support. protected: ! BarrierSet(const FakeRtti& fake_rtti) : _fake_rtti(fake_rtti), _code_gen(NULL), _c1_code_gen(NULL), _c2_code_gen(NULL) { } ~BarrierSet() { } ! static BarrierSet* _bs; ! BarrierSetCodeGen* _code_gen; ! C1BarrierSetCodeGen* _c1_code_gen; ! C2BarrierSetCodeGen* _c2_code_gen; ! virtual BarrierSetCodeGen* make_code_gen() = 0; ! virtual C1BarrierSetCodeGen* make_c1_code_gen() = 0; ! virtual C2BarrierSetCodeGen* make_c2_code_gen() = 0; public: + static BarrierSet* barrier_set() { return _bs; } ! // Print a description of the memory for the barrier set ! virtual void print_on(outputStream* st) const = 0; ! virtual void initialize(); ! BarrierSetCodeGen* code_gen() { ! assert(_code_gen != NULL, "should be set"); ! return _code_gen; ! } ! ! C1BarrierSetCodeGen* c1_code_gen() { ! assert(_c1_code_gen != NULL, "should be set"); ! return _c1_code_gen; ! } ! ! C2BarrierSetCodeGen* c2_code_gen() { ! assert(_c2_code_gen != NULL, "should be set"); ! return _c2_code_gen; ! } ! ! // The AccessBarrier of a BarrierSet subclass is called by the Access API ! // to perform decorated accesses. ! template <DecoratorSet decorators> ! class AccessBarrier: public BasicAccessBarrier<decorators> { ! typedef BasicAccessBarrier<decorators> Basic; ! public: ! static void oop_store(void* addr, oop value); ! static void oop_store_at(oop base, ptrdiff_t offset, oop value); ! static void oop_store_at(nmethod* base, ptrdiff_t offset, oop value); ! static void oop_store_at(Klass* base, ptrdiff_t offset, oop value); ! static oop oop_load(void* addr); ! static oop oop_load_at(oop base, ptrdiff_t offset); ! static oop oop_cas(oop new_value, void* addr, oop compare_value); ! static oop oop_cas_at(oop new_value, oop base, ptrdiff_t offset, oop compare_value); ! static oop oop_swap(oop new_value, void* addr); ! static oop oop_swap_at(oop new_value, oop base, ptrdiff_t offset); ! }; ! ! // Support for optimizing compilers to call the barrier set on slow path allocations ! // that did not enter a TLAB. Used for e.g. ReduceInitialCardMarks ! virtual void on_slowpath_allocation(JavaThread* thread, oop new_obj) {} ! virtual void on_add_thread(JavaThread* thread) {} ! virtual void on_destroy_thread(JavaThread* thread) {} ! virtual void make_parsable(JavaThread* thread) {} ! ! // Resolve runtime paths for GC barriers accessible through the Access interface ! // in runtime/access.hpp ! template <DecoratorSet decorators, typename T, BarrierType barrier_type> ! void* resolve_barrier(); ! ! template <DecoratorSet decorators> ! void* resolve_clone_barrier(); }; + // Metafunction mapping a class derived from BarrierSet to the + // corresponding Name enum tag. + template<typename T> struct BSTypeToName; + template<BarrierSet::Name T> struct BSNameToType; + template<typename T> inline T* barrier_set_cast(BarrierSet* bs) { ! assert(bs->is_a(BSTypeToName<T>::value), "wrong type of barrier set"); return static_cast<T*>(bs); } #endif // SHARE_VM_GC_SHARED_BARRIERSET_HPP
< prev index next >