1 /*
2 * Copyright (c) 2015, 2025, 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 ZBarrierSetC1 : public BarrierSetC1 {
91 private:
92 address _load_barrier_on_oop_field_preloaded_runtime_stub;
93 address _load_barrier_on_weak_oop_field_preloaded_runtime_stub;
94 address _store_barrier_on_oop_field_with_healing;
95 address _store_barrier_on_oop_field_without_healing;
96
97 address load_barrier_on_oop_field_preloaded_runtime_stub(DecoratorSet decorators) const;
98 address store_barrier_on_oop_field_runtime_stub(bool self_healing) const;
99
100 LIR_Opr color(LIRAccess& access, LIR_Opr ref) const;
101
102 void load_barrier(LIRAccess& access, LIR_Opr result) const;
103 LIR_Opr store_barrier(LIRAccess& access, LIR_Opr new_zaddress, bool is_atomic) const;
104
105 protected:
106 virtual LIR_Opr resolve_address(LIRAccess& access, bool resolve_in_register);
107 virtual void load_at_resolved(LIRAccess& access, LIR_Opr result);
108 virtual void store_at_resolved(LIRAccess& access, LIR_Opr value);
109 virtual LIR_Opr atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value);
110 virtual LIR_Opr atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value);
111
112 public:
113 ZBarrierSetC1();
114
115 virtual bool generate_c1_runtime_stubs(BufferBlob* blob);
116 };
117
118 #endif // SHARE_GC_Z_C1_ZBARRIERSETC1_HPP