--- old/src/share/vm/gc/shared/modRefBarrierSet.hpp 2017-04-25 16:45:11.319173928 +0200 +++ new/src/share/vm/gc/shared/modRefBarrierSet.hpp 2017-04-25 16:45:11.171173933 +0200 @@ -26,77 +26,97 @@ #define SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP #include "gc/shared/barrierSet.hpp" +#include "memory/memRegion.hpp" -// This kind of "BarrierSet" allows a "CollectedHeap" to detect and -// enumerate ref fields that have been modified (since the last -// enumeration), using a card table. - -class OopClosure; -class Generation; +class Klass; class ModRefBarrierSet: public BarrierSet { -public: - - // Barriers only on ref writes. - bool has_read_ref_barrier() { return false; } - bool has_read_prim_barrier() { return false; } - bool has_write_ref_barrier() { return true; } - bool has_write_prim_barrier() { return false; } - - bool read_ref_needs_barrier(void* field) { return false; } - bool read_prim_needs_barrier(HeapWord* field, size_t bytes) { return false; } - bool write_prim_needs_barrier(HeapWord* field, size_t bytes, - juint val1, juint val2) { return false; } - - void write_prim_field(oop obj, size_t offset, size_t bytes, - juint val1, juint val2) {} - - void read_ref_field(void* field) {} - void read_prim_field(HeapWord* field, size_t bytes) {} - protected: - ModRefBarrierSet(const BarrierSet::FakeRtti& fake_rtti) : BarrierSet(fake_rtti.add_tag(BarrierSet::ModRef)) { } ~ModRefBarrierSet() { } -public: - void write_prim_field(HeapWord* field, size_t bytes, - juint val1, juint val2) {} + virtual void write_ref_array_region(MemRegion mr) = 0; - bool has_read_ref_array_opt() { return false; } - bool has_read_prim_array_opt() { return false; } - bool has_write_prim_array_opt() { return false; } - - bool has_read_region_opt() { return false; } - - - // These operations should assert false unless the corresponding operation - // above returns true. - void read_ref_array(MemRegion mr) { - assert(false, "can't call"); - } - void read_prim_array(MemRegion mr) { - assert(false, "can't call"); - } - void write_prim_array(MemRegion mr) { - assert(false, "can't call"); - } - void read_region(MemRegion mr) { - assert(false, "can't call"); - } + // These methods serve the only purpose of speeding up build times by reducing + // included files + static Klass* bound_for_array(oop obj); + static bool is_bounded_by(oop obj, Klass* klass); +public: // Causes all refs in "mr" to be assumed to be modified. virtual void invalidate(MemRegion mr) = 0; - // The caller guarantees that "mr" contains no references. (Perhaps it's - // objects have been moved elsewhere.) - virtual void clear(MemRegion mr) = 0; + // 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 + inline void write_ref_field_pre(void* addr) {} + + template + inline void write_ref_field_post(void *addr, oop new_value) {} + + // barriers used by klass_oop_store + void klass_update_barrier_set_pre(Klass* klass, oop* p) {} + void klass_update_barrier_set(Klass* klass, oop* p, oop v); + + template + class AccessBarrier: public BarrierSet::AccessBarrier { + typedef BarrierSet::AccessBarrier Basic; + + public: + typedef Basic SuperAccessBarrier; + + static void oop_store(void* addr, oop value); + + static oop oop_cas(oop new_value, void* addr, oop compare_value); + + static oop oop_swap(oop new_value, void* addr); + + template + static bool oop_copy(arrayOop src_obj, arrayOop dst_obj, T* src, T* dst, size_t length); + + static void clone(oop src, oop dst, size_t size); + + static inline void oop_store_at(oop base, ptrdiff_t offset, oop value) { + oop_store(Basic::field_addr(base, offset), value); + } + + static inline void oop_store_at(Klass* base, ptrdiff_t offset, oop value); + + static inline oop oop_swap_at(oop new_value, oop base, ptrdiff_t offset) { + return oop_swap(new_value, Basic::field_addr(base, offset)); + } + + static inline oop oop_cas_at(oop new_value, oop base, ptrdiff_t offset, oop compare_value) { + return oop_cas(new_value, Basic::field_addr(base, offset), compare_value); + } + }; }; template<> -struct BarrierSet::GetName { +struct BSTypeToName { static const BarrierSet::Name value = BarrierSet::ModRef; }; +template<> +struct BSNameToType { + typedef ModRefBarrierSet type; +}; + #endif // SHARE_VM_GC_SHARED_MODREFBARRIERSET_HPP