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 oop resolve_and_maybe_copy_oopHelper(oop src); 100 oop resolve_and_maybe_copy_oop_work(oop src); 101 oop resolve_and_maybe_copy_oop_work2(oop src); 102 virtual oop write_barrier(oop src); 103 104 bool obj_equals(oop obj1, oop obj2); 105 bool obj_equals(narrowOop obj1, narrowOop obj2); 106 107 #ifdef ASSERT 108 virtual bool is_safe(oop o); 109 virtual bool is_safe(narrowOop o); 110 virtual void verify_safe_oop(oop p); 111 #endif 112 113 static oopDesc* write_barrier_c2(oopDesc* src); 114 static oopDesc* write_barrier_interp(oopDesc* src); 115 116 private: 117 bool need_update_refs_barrier(); 118 119 #ifndef CC_INTERP 120 public: 121 virtual void interpreter_read_barrier(MacroAssembler* masm, Register dst); 122 virtual void interpreter_read_barrier_not_null(MacroAssembler* masm, Register dst); 123 void interpreter_write_barrier(MacroAssembler* masm, Register dst); 124 void asm_acmp_barrier(MacroAssembler* masm, Register op1, Register op2); 125 126 #endif 127 }; 128 129 #endif //SHARE_VM_GC_SHENANDOAH_SHENANDOAHBARRIERSET_HPP