1 /* 2 * Copyright (c) 2013, 2018, Red Hat, Inc. All rights reserved. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * version 2 for more details (a copy is included in the LICENSE file that 12 * accompanied this code). 13 * 14 * You should have received a copy of the GNU General Public License version 15 * 2 along with this work; if not, write to the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * or visit www.oracle.com if you need additional information or have any 20 * questions. 21 * 22 */ 23 24 #ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHBARRIERSET_HPP 25 #define SHARE_VM_GC_SHENANDOAH_SHENANDOAHBARRIERSET_HPP 26 27 #include "memory/barrierSet.hpp" 28 #include "gc_implementation/shenandoah/shenandoahAsserts.hpp" 29 30 class ShenandoahBarrierSetAssembler; 31 class ShenandoahBarrierSetC1; 32 class ShenandoahBarrierSetC2; 33 class ShenandoahHeap; 34 35 class ShenandoahBarrierSet: public BarrierSet { 36 private: 37 ShenandoahHeap* _heap; 38 ShenandoahBarrierSetAssembler* const _bsasm; 39 ShenandoahBarrierSetC1* const _bsc1; 40 ShenandoahBarrierSetC2* const _bsc2; 41 42 inline bool need_bulk_update(HeapWord* dst); 43 public: 44 ShenandoahBarrierSet(ShenandoahHeap* heap); 45 46 inline static ShenandoahBarrierSet* barrier_set() { 47 BarrierSet *bs = oopDesc::bs(); 48 assert(bs->kind() == BarrierSet::ShenandoahBarrierSet, "sanity"); 49 return (ShenandoahBarrierSet*)bs; 50 } 51 52 ShenandoahBarrierSetAssembler* bsasm() const; 53 ShenandoahBarrierSetC1* bsc1() const; 54 ShenandoahBarrierSetC2* bsc2() const; 55 56 void print_on(outputStream* st) const; 57 58 bool is_a(BarrierSet::Name bsn); 59 60 bool has_read_prim_array_opt(); 61 bool has_read_prim_barrier(); 62 bool has_read_ref_array_opt(); 63 bool has_read_ref_barrier(); 64 bool has_read_region_opt(); 65 bool has_write_prim_array_opt(); 66 bool has_write_prim_barrier(); 67 bool has_write_ref_array_opt(); 68 bool has_write_ref_barrier(); 69 bool has_write_ref_pre_barrier(); 70 bool has_write_region_opt(); 71 bool is_aligned(HeapWord* hw); 72 void read_prim_array(MemRegion mr) shenandoah_not_implemented; 73 void read_prim_field(HeapWord* hw, size_t s) shenandoah_not_implemented; 74 bool read_prim_needs_barrier(HeapWord* hw, size_t s); 75 void read_ref_array(MemRegion mr) shenandoah_not_implemented; 76 77 void read_ref_field(void* v); 78 79 bool read_ref_needs_barrier(void* v) shenandoah_not_implemented_return(false); 80 void read_region(MemRegion mr) shenandoah_not_implemented; 81 void resize_covered_region(MemRegion mr) shenandoah_not_implemented; 82 void write_prim_array(MemRegion mr) shenandoah_not_implemented; 83 void write_prim_field(HeapWord* hw, size_t s , juint x, juint y) shenandoah_not_implemented; 84 bool write_prim_needs_barrier(HeapWord* hw, size_t s, juint x, juint y) shenandoah_not_implemented_return(false); 85 86 void write_ref_array_work(MemRegion mr) {} 87 88 template <class T> 89 inline void arraycopy_barrier(T* src, T* dst, size_t count); 90 inline void clone_barrier(oop src); 91 void clone_barrier_runtime(oop src); 92 93 // We export this to make it available in cases where the static 94 // type of the barrier set is known. Note that it is non-virtual. 95 template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal); 96 97 // These are the more general virtual versions. 98 void write_ref_field_pre_work(oop* field, oop new_val); 99 void write_ref_field_pre_work(narrowOop* field, oop new_val); 100 void write_ref_field_pre_work(void* field, oop new_val) shenandoah_not_implemented; 101 102 void write_ref_field_work(void* v, oop o, bool release = false); 103 void write_region_work(MemRegion mr) {}; 104 105 static inline oop resolve_forwarded_not_null(oop p); 106 static inline oop resolve_forwarded_not_null_mutator(oop p); 107 static inline oop resolve_forwarded(oop p); 108 109 void storeval_barrier(oop obj); 110 111 oop load_reference_barrier(oop obj); 112 oop load_reference_barrier_not_null(oop obj); 113 inline oop load_reference_barrier_mutator(oop obj, oop* load_addr); 114 inline oop load_reference_barrier_mutator(oop obj, narrowOop* load_addr); 115 116 template <class T> 117 inline oop load_reference_barrier_mutator_work(oop obj, T* load_addr); 118 119 oop oop_atomic_cmpxchg_in_heap(oop new_value, volatile HeapWord* dest, oop compare_value); 120 121 void enqueue(oop obj); 122 void keep_alive_barrier(oop obj); 123 124 private: 125 template <class T> 126 inline void arraycopy_marking(T* src, T* dst, size_t count); 127 template <class T> 128 inline void arraycopy_evacuation(T* src, size_t count); 129 template <class T> 130 inline void arraycopy_update(T* src, size_t count); 131 132 inline void clone_marking(oop src); 133 inline void clone_evacuation(oop src); 134 inline void clone_update(oop src); 135 136 template <class T, bool HAS_FWD, bool EVAC, bool ENQUEUE> 137 inline void arraycopy_work(T* src, size_t count); 138 139 oop load_reference_barrier_impl(oop obj); 140 141 oop atomic_compare_exchange_oop(oop exchange_value, 142 volatile HeapWord *dest, 143 oop compare_value); 144 }; 145 146 #endif //SHARE_VM_GC_SHENANDOAH_SHENANDOAHBARRIERSET_HPP