1 /*
2 * Copyright (c) 2026, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2018, 2022, Red Hat, Inc. All rights reserved.
4 * Copyright (c) 2012, 2026 SAP SE. All rights reserved.
5 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 *
7 * This code is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 only, as
9 * published by the Free Software Foundation.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 *
25 */
26
27 #ifndef CPU_PPC_GC_SHENANDOAH_SHENANDOAHBARRIERSETASSEMBLER_PPC_HPP
28 #define CPU_PPC_GC_SHENANDOAH_SHENANDOAHBARRIERSETASSEMBLER_PPC_HPP
29
30 #include "asm/macroAssembler.hpp"
31 #include "gc/shared/barrierSetAssembler.hpp"
32 #include "gc/shenandoah/shenandoahBarrierSet.hpp"
33
34 #ifdef COMPILER1
35
36 class LIR_Assembler;
37 class ShenandoahPreBarrierStub;
38 class ShenandoahLoadReferenceBarrierStub;
39 class StubAssembler;
40
41 #endif
42
43 class StubCodeGenerator;
44
45 class ShenandoahBarrierSetAssembler: public BarrierSetAssembler {
46 private:
47
48 /* ==== Actual barrier implementations ==== */
49 void satb_barrier_impl(MacroAssembler* masm, DecoratorSet decorators,
50 Register base, RegisterOrConstant ind_or_offs,
51 Register pre_val,
52 Register tmp1, Register tmp2,
53 MacroAssembler::PreservationLevel preservation_level);
54
55 void card_barrier(MacroAssembler* masm,
56 Register base, RegisterOrConstant ind_or_offs,
57 Register tmp);
58
59 void load_reference_barrier_impl(MacroAssembler* masm, DecoratorSet decorators,
60 Register base, RegisterOrConstant ind_or_offs,
61 Register dst,
62 Register tmp1, Register tmp2,
63 MacroAssembler::PreservationLevel preservation_level);
64
65 /* ==== Helper methods for barrier implementations ==== */
66 void resolve_forward_pointer_not_null(MacroAssembler* masm, Register dst, Register tmp);
67
68 void gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators,
69 Register addr, Register count,
70 Register preserve);
71
72 public:
73 virtual NMethodPatchingType nmethod_patching_type() { return NMethodPatchingType::conc_instruction_and_data_patch; }
74
75 /* ==== C1 stubs ==== */
76 #ifdef COMPILER1
77
78 void gen_pre_barrier_stub(LIR_Assembler* ce, ShenandoahPreBarrierStub* stub);
79
80 void gen_load_reference_barrier_stub(LIR_Assembler* ce, ShenandoahLoadReferenceBarrierStub* stub);
81
82 void generate_c1_pre_barrier_runtime_stub(StubAssembler* sasm);
83
84 void generate_c1_load_reference_barrier_runtime_stub(StubAssembler* sasm, DecoratorSet decorators);
85
86 #endif
87
88 /* ==== Available barriers (facades of the actual implementations) ==== */
89 void satb_barrier(MacroAssembler* masm,
90 Register base, RegisterOrConstant ind_or_offs,
91 Register tmp1, Register tmp2, Register tmp3,
92 MacroAssembler::PreservationLevel preservation_level);
93
94 void load_reference_barrier(MacroAssembler* masm, DecoratorSet decorators,
95 Register base, RegisterOrConstant ind_or_offs,
96 Register dst,
97 Register tmp1, Register tmp2,
98 MacroAssembler::PreservationLevel preservation_level);
99
100 /* ==== Helper methods used by C1 and C2 ==== */
101 void cmpxchg_oop(MacroAssembler* masm, Register base_addr, Register expected, Register new_val,
102 Register tmp1, Register tmp2,
103 bool is_cae, Register result);
104
105 /* ==== Access api ==== */
106 virtual void arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
107 Register src, Register dst, Register count,
108 Register preserve1, Register preserve2);
109 virtual void arraycopy_epilogue(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
110 Register dst, Register count,
111 Register preserve);
112
113 virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
114 Register base, RegisterOrConstant ind_or_offs, Register val,
115 Register tmp1, Register tmp2, Register tmp3,
116 MacroAssembler::PreservationLevel preservation_level);
117
118 virtual void load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type,
119 Register base, RegisterOrConstant ind_or_offs, Register dst,
120 Register tmp1, Register tmp2,
121 MacroAssembler::PreservationLevel preservation_level, Label* L_handle_null = nullptr);
122
123 virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register dst, Register jni_env,
124 Register obj, Register tmp, Label& slowpath);
125
126 virtual void try_resolve_weak_handle(MacroAssembler* masm, Register obj, Register tmp, Label& slow_path);
127 };
128
129 #endif // CPU_PPC_GC_SHENANDOAH_SHENANDOAHBARRIERSETASSEMBLER_PPC_HPP