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