1 /* 2 * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #ifndef SHARE_GC_G1_C2_G1BARRIERSETC2_HPP 26 #define SHARE_GC_G1_C2_G1BARRIERSETC2_HPP 27 28 #include "gc/shared/c2/cardTableBarrierSetC2.hpp" 29 30 class PhaseTransform; 31 class Type; 32 class TypeFunc; 33 34 const int G1C2BarrierPre = 1; 35 const int G1C2BarrierPost = 2; 36 const int G1C2BarrierPostNotNull = 4; 37 38 class G1BarrierStubC2 : public BarrierStubC2 { 39 public: 40 G1BarrierStubC2(const MachNode* node); 41 virtual void emit_code(MacroAssembler& masm) = 0; 42 }; 43 44 class G1PreBarrierStubC2 : public G1BarrierStubC2 { 45 private: 46 Register _obj; 47 Register _pre_val; 48 Register _thread; 49 Register _tmp1; 50 Register _tmp2; 51 52 protected: 53 G1PreBarrierStubC2(const MachNode* node); 54 55 public: 56 static bool needs_barrier(const MachNode* node); 57 static G1PreBarrierStubC2* create(const MachNode* node); 58 void initialize_registers(Register obj, Register pre_val, Register thread, Register tmp1 = noreg, Register tmp2 = noreg); 59 Register obj() const; 60 Register pre_val() const; 61 Register thread() const; 62 Register tmp1() const; 63 Register tmp2() const; 64 virtual void emit_code(MacroAssembler& masm); 65 }; 66 67 class G1PostBarrierStubC2 : public G1BarrierStubC2 { 68 private: 69 Register _thread; 70 Register _tmp1; 71 Register _tmp2; 72 Register _tmp3; 73 74 protected: 75 G1PostBarrierStubC2(const MachNode* node); 76 77 public: 78 static bool needs_barrier(const MachNode* node); 79 static G1PostBarrierStubC2* create(const MachNode* node); 80 void initialize_registers(Register thread, Register tmp1 = noreg, Register tmp2 = noreg, Register tmp3 = noreg); 81 Register thread() const; 82 Register tmp1() const; 83 Register tmp2() const; 84 Register tmp3() const; 85 virtual void emit_code(MacroAssembler& masm); 86 }; 87 88 class G1BarrierSetC2: public CardTableBarrierSetC2 { 89 protected: 90 bool g1_can_remove_pre_barrier(GraphKit* kit, 91 PhaseValues* phase, 92 Node* adr, 93 BasicType bt, 94 uint adr_idx) const; 95 96 bool g1_can_remove_post_barrier(GraphKit* kit, 97 PhaseValues* phase, Node* store, 98 Node* adr) const; 99 100 int get_store_barrier(C2Access& access) const; 101 102 virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const; 103 virtual Node* store_at_resolved(C2Access& access, C2AccessValue& val) const; 104 virtual Node* atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access, Node* expected_val, 105 Node* new_val, const Type* value_type) const; 106 virtual Node* atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, Node* expected_val, 107 Node* new_val, const Type* value_type) const; 108 virtual Node* atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* value_type) const; 109 110 public: 111 virtual void eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const; 112 virtual void eliminate_gc_barrier_data(Node* node) const; 113 virtual bool expand_barriers(Compile* C, PhaseIterGVN& igvn) const; 114 virtual uint estimated_barrier_size(const Node* node) const; 115 virtual bool can_initialize_object(const StoreNode* store) const; 116 virtual void clone_at_expansion(PhaseMacroExpand* phase, 117 ArrayCopyNode* ac) const; 118 virtual void* create_barrier_state(Arena* comp_arena) const; 119 virtual void emit_stubs(CodeBuffer& cb) const; 120 virtual void late_barrier_analysis() const; 121 122 #ifndef PRODUCT 123 virtual void dump_barrier_data(const MachNode* mach, outputStream* st) const; 124 #endif 125 }; 126 127 #endif // SHARE_GC_G1_C2_G1BARRIERSETC2_HPP