1 /* 2 * Copyright (c) 2015, 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 #ifndef SHARE_GC_Z_C1_ZBARRIERSETC1_HPP 25 #define SHARE_GC_Z_C1_ZBARRIERSETC1_HPP 26 27 #include "c1/c1_CodeStubs.hpp" 28 #include "c1/c1_IR.hpp" 29 #include "c1/c1_LIR.hpp" 30 #include "gc/shared/c1/barrierSetC1.hpp" 31 #include "oops/accessDecorators.hpp" 32 33 class ZLoadBarrierStubC1 : public CodeStub { 34 private: 35 DecoratorSet _decorators; 36 LIR_Opr _ref_addr; 37 LIR_Opr _ref; 38 LIR_Opr _tmp; 39 address _runtime_stub; 40 41 public: 42 ZLoadBarrierStubC1(LIRAccess& access, LIR_Opr ref, address runtime_stub); 43 44 DecoratorSet decorators() const; 45 LIR_Opr ref() const; 46 LIR_Opr ref_addr() const; 47 LIR_Opr tmp() const; 48 address runtime_stub() const; 49 50 virtual void emit_code(LIR_Assembler* ce); 51 virtual void visit(LIR_OpVisitState* visitor); 52 53 #ifndef PRODUCT 54 virtual void print_name(outputStream* out) const; 55 #endif // PRODUCT 56 }; 57 58 class ZStoreBarrierStubC1 : public CodeStub { 59 private: 60 LIR_Opr _ref_addr; 61 LIR_Opr _new_zaddress; 62 LIR_Opr _new_zpointer; 63 LIR_Opr _tmp; 64 bool _is_atomic; 65 address _runtime_stub; 66 67 public: 68 ZStoreBarrierStubC1(LIRAccess& access, 69 LIR_Opr new_zaddress, 70 LIR_Opr new_zpointer, 71 LIR_Opr tmp, 72 bool is_atomic, 73 address runtime_stub); 74 75 LIR_Opr ref_addr() const; 76 LIR_Opr new_zaddress() const; 77 LIR_Opr new_zpointer() const; 78 LIR_Opr tmp() const; 79 bool is_atomic() const; 80 address runtime_stub() const; 81 82 virtual void emit_code(LIR_Assembler* ce); 83 virtual void visit(LIR_OpVisitState* visitor); 84 85 #ifndef PRODUCT 86 virtual void print_name(outputStream* out) const; 87 #endif // PRODUCT 88 }; 89 90 class SCAddressTable; 91 92 class ZBarrierSetC1 : public BarrierSetC1 { 93 friend SCAddressTable; 94 private: 95 address _load_barrier_on_oop_field_preloaded_runtime_stub; 96 address _load_barrier_on_weak_oop_field_preloaded_runtime_stub; 97 address _store_barrier_on_oop_field_with_healing; 98 address _store_barrier_on_oop_field_without_healing; 99 100 address load_barrier_on_oop_field_preloaded_runtime_stub(DecoratorSet decorators) const; 101 address store_barrier_on_oop_field_runtime_stub(bool self_healing) const; 102 103 LIR_Opr color(LIRAccess& access, LIR_Opr ref) const; 104 105 void load_barrier(LIRAccess& access, LIR_Opr result) const; 106 LIR_Opr store_barrier(LIRAccess& access, LIR_Opr new_zaddress, bool is_atomic) const; 107 108 protected: 109 virtual LIR_Opr resolve_address(LIRAccess& access, bool resolve_in_register); 110 virtual void load_at_resolved(LIRAccess& access, LIR_Opr result); 111 virtual void store_at_resolved(LIRAccess& access, LIR_Opr value); 112 virtual LIR_Opr atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value); 113 virtual LIR_Opr atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value); 114 115 public: 116 ZBarrierSetC1(); 117 118 virtual void generate_c1_runtime_stubs(BufferBlob* blob); 119 }; 120 121 #endif // SHARE_GC_Z_C1_ZBARRIERSETC1_HPP