< prev index next >

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

BarrierSetCodeGen_v2

8198949_arraycopy
 #include "memory/memRegion.hpp"
 #include "oops/access.hpp"
 #include "oops/accessBackend.hpp"
 #include "oops/oopsHierarchy.hpp"
 #include "utilities/fakeRttiSupport.hpp"
+#include "utilities/macros.hpp"
 
 class JavaThread;
+class BarrierSetCodeGen;
 
 // This class provides the interface between a barrier implementation and
 // the rest of the system.
 
 class BarrierSet: public CHeapObj<mtGC> {

@@ -65,10 +67,11 // entry, and pass it up to its base class. typedef FakeRttiSupport<BarrierSet, Name> FakeRtti; private: FakeRtti _fake_rtti; + BarrierSetCodeGen* _code_gen; public: // Metafunction mapping a class derived from BarrierSet to the // corresponding Name enum tag. template<typename T> struct GetName;
@@ -85,51 +88,42 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) { } + BarrierSet(BarrierSetCodeGen* code_gen, const FakeRtti& fake_rtti) : + _fake_rtti(fake_rtti), + _code_gen(code_gen) { } ~BarrierSet() { } -public: - // Operations on arrays, or general regions (e.g., for "clone") may be - // optimized by some barriers. - - // 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); + template <class BarrierSetCodeGenT> + BarrierSetCodeGen* make_code_gen() { + return NOT_ZERO(new BarrierSetCodeGenT()) ZERO_ONLY(NULL); + } +public: // Support for optimizing compilers to call the barrier set on slow path allocations // that did not enter a TLAB. Used for e.g. ReduceInitialCardMarks. // The allocation is safe to use iff it returns true. If not, the slow-path allocation // is redone until it succeeds. This can e.g. prevent allocations from the slow path // to be in old. virtual void on_slowpath_allocation_exit(JavaThread* thread, oop new_obj) {} virtual void on_thread_attach(JavaThread* thread) {} virtual void on_thread_detach(JavaThread* thread) {} virtual void make_parsable(JavaThread* thread) {} -protected: - virtual void write_ref_array_work(MemRegion mr) = 0; - public: // Print a description of the memory for the barrier set virtual void print_on(outputStream* st) const = 0; static void set_bs(BarrierSet* bs) { _bs = bs; } + BarrierSetCodeGen* code_gen() { + assert(_code_gen != NULL, "should be set"); + return _code_gen; + } + // The AccessBarrier of a BarrierSet subclass is called by the Access API // (cf. oops/access.hpp) to perform decorated accesses. GC implementations // may override these default access operations by declaring an // AccessBarrier class in its BarrierSet. Its accessors will then be // automatically resolved at runtime.
< prev index next >