1 /* 2 * Copyright (c) 2013, 2015, Red Hat, Inc. and/or its affiliates. 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 "gc/shenandoah/shenandoahHeap.hpp" 28 #include "gc/shared/barrierSet.hpp" 29 30 class ShenandoahBarrierSet: public BarrierSet { 31 private: 32 33 ShenandoahHeap* _heap; 34 35 public: 36 37 ShenandoahBarrierSet(ShenandoahHeap* heap); 38 39 void print_on(outputStream* st) const; 40 41 bool is_a(BarrierSet::Name bsn); 42 43 bool has_read_prim_array_opt(); 44 bool has_read_prim_barrier(); 45 bool has_read_ref_array_opt(); 46 bool has_read_ref_barrier(); 47 bool has_read_region_opt(); 48 bool has_write_prim_array_opt(); 49 bool has_write_prim_barrier(); 50 bool has_write_ref_array_opt(); 51 bool has_write_ref_barrier(); 52 bool has_write_ref_pre_barrier(); 53 bool has_write_region_opt(); 54 bool is_aligned(HeapWord* hw); 55 void read_prim_array(MemRegion mr); 56 void read_prim_field(HeapWord* hw, size_t s); 57 bool read_prim_needs_barrier(HeapWord* hw, size_t s); 58 void read_ref_array(MemRegion mr); 59 60 void read_ref_field(void* v); 61 62 bool read_ref_needs_barrier(void* v); 63 void read_region(MemRegion mr); 64 void resize_covered_region(MemRegion mr); 65 void write_prim_array(MemRegion mr); 66 void write_prim_field(HeapWord* hw, size_t s , juint x, juint y); 67 bool write_prim_needs_barrier(HeapWord* hw, size_t s, juint x, juint y); 68 void write_ref_array(HeapWord* start, size_t count); 69 void write_ref_array_work(MemRegion r); 70 71 template <class T> void 72 write_ref_array_pre_work(T* dst, int count); 73 74 void write_ref_array_pre(oop* dst, int count, bool dest_uninitialized); 75 76 void write_ref_array_pre(narrowOop* dst, int count, bool dest_uninitialized); 77 78 79 template <class T> static void write_ref_field_pre_static(T* field, oop newVal); 80 81 // We export this to make it available in cases where the static 82 // type of the barrier set is known. Note that it is non-virtual. 83 template <class T> inline void inline_write_ref_field_pre(T* field, oop newVal); 84 85 // These are the more general virtual versions. 86 void write_ref_field_pre_work(oop* field, oop new_val); 87 void write_ref_field_pre_work(narrowOop* field, oop new_val); 88 void write_ref_field_pre_work(void* field, oop new_val); 89 90 void write_ref_field_work(void* v, oop o, bool release = false); 91 void write_region_work(MemRegion mr); 92 93 virtual oop read_barrier(oop src); 94 95 static inline oop resolve_oop_static_not_null(oop p); 96 97 static inline oop resolve_oop_static(oop p); 98 99 virtual oop write_barrier(oop obj); 100 static oopDesc* write_barrier_IRT(oopDesc* src); 101 static oopDesc* write_barrier_JRT(oopDesc* src); 102 103 virtual oop storeval_barrier(oop obj); 104 105 bool obj_equals(oop obj1, oop obj2); 106 bool obj_equals(narrowOop obj1, narrowOop obj2); 107 108 #ifdef ASSERT 109 virtual bool is_safe(oop o); 110 virtual bool is_safe(narrowOop o); 111 virtual void verify_safe_oop(oop p); 112 #endif 113 114 private: 115 bool need_update_refs_barrier(); 116 117 template <class T, bool UPDATE_MATRIX> 118 void write_ref_array_loop(HeapWord* start, size_t count); 119 120 #ifndef CC_INTERP 121 public: 122 void interpreter_read_barrier(MacroAssembler* masm, Register dst); 123 void interpreter_read_barrier_not_null(MacroAssembler* masm, Register dst); 124 void interpreter_write_barrier(MacroAssembler* masm, Register dst); 125 void interpreter_storeval_barrier(MacroAssembler* masm, Register dst); 126 void asm_acmp_barrier(MacroAssembler* masm, Register op1, Register op2); 127 128 private: 129 void interpreter_read_barrier_impl(MacroAssembler* masm, Register dst); 130 void interpreter_read_barrier_not_null_impl(MacroAssembler* masm, Register dst); 131 132 #endif 133 }; 134 135 #endif //SHARE_VM_GC_SHENANDOAH_SHENANDOAHBARRIERSET_HPP