diff --git a/src/hotspot/share/gc/shared/barrierSet.hpp b/src/hotspot/share/gc/shared/barrierSet.hpp index 52cab8a..ee30842 100644 --- a/src/hotspot/share/gc/shared/barrierSet.hpp +++ b/src/hotspot/share/gc/shared/barrierSet.hpp @@ -31,8 +31,10 @@ #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. @@ -67,6 +69,7 @@ protected: private: FakeRtti _fake_rtti; + BarrierSetCodeGen* _code_gen; public: // Metafunction mapping a class derived from BarrierSet to the @@ -87,28 +90,17 @@ public: // 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 + 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 @@ -119,15 +111,17 @@ public: 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