1 /* 2 * Copyright (c) 2018, Red Hat, Inc. All rights reserved. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * version 2 for more details (a copy is included in the LICENSE file that 12 * accompanied this code). 13 * 14 * You should have received a copy of the GNU General Public License version 15 * 2 along with this work; if not, write to the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * or visit www.oracle.com if you need additional information or have any 20 * questions. 21 * 22 */ 23 24 #ifndef SHARE_GC_SHENANDOAH_C1_SHENANDOAHBARRIERSETC1_HPP 25 #define SHARE_GC_SHENANDOAH_C1_SHENANDOAHBARRIERSETC1_HPP 26 27 #include "c1/c1_CodeStubs.hpp" 28 #include "memory/allocation.hpp" 29 30 class LIRGenerator; 31 class LIRItem; 32 33 class ShenandoahLoadReferenceBarrierStub: public CodeStub { 34 friend class ShenandoahBarrierSetC1; 35 private: 36 LIR_Opr _obj; 37 LIR_Opr _addr; 38 LIR_Opr _result; 39 LIR_Opr _tmp1; 40 LIR_Opr _tmp2; 41 42 public: 43 ShenandoahLoadReferenceBarrierStub(LIR_Opr obj, LIR_Opr addr, LIR_Opr result, LIR_Opr tmp1, LIR_Opr tmp2) : 44 _obj(obj), _addr(addr), _result(result), _tmp1(tmp1), _tmp2(tmp2) 45 { 46 assert(_obj->is_register(), "should be register"); 47 assert(_addr->is_register(), "should be register"); 48 assert(_result->is_register(), "should be register"); 49 assert(_tmp1->is_register(), "should be register"); 50 assert(_tmp2->is_register(), "should be register"); 51 } 52 53 LIR_Opr obj() const { return _obj; } 54 LIR_Opr addr() const { return _addr; } 55 LIR_Opr result() const { return _result; } 56 LIR_Opr tmp1() const { return _tmp1; } 57 LIR_Opr tmp2() const { return _tmp2; } 58 59 virtual void emit_code(LIR_Assembler* e); 60 virtual void visit(LIR_OpVisitState* visitor) { 61 visitor->do_slow_case(); 62 visitor->do_input(_obj); 63 visitor->do_temp(_obj); 64 visitor->do_input(_addr); 65 visitor->do_temp(_addr); 66 visitor->do_temp(_result); 67 visitor->do_temp(_tmp1); 68 visitor->do_temp(_tmp2); 69 } 70 #ifndef PRODUCT 71 virtual void print_name(outputStream* out) const { out->print("ShenandoahLoadReferenceBarrierStub"); } 72 #endif // PRODUCT 73 }; 74 75 class ShenandoahBarrierSetC1 : public CHeapObj<mtGC>{ 76 private: 77 CodeBlob* _pre_barrier_c1_runtime_code_blob; 78 public: 79 static ShenandoahBarrierSetC1* bsc1(); 80 81 LIR_Opr load_reference_barrier(LIRGenerator* gen, LIR_Opr obj, LIR_Opr addr); 82 LIR_Opr storeval_barrier(LIRGenerator* gen, LIR_Opr obj, CodeEmitInfo* info, bool patch); 83 84 LIR_Opr resolve_address(LIRGenerator* gen, LIR_Address* addr, BasicType type, CodeEmitInfo* patch_emit_info); 85 86 private: 87 LIR_Opr load_reference_barrier_impl(LIRGenerator* gen, LIR_Opr obj, LIR_Opr addr); 88 LIR_Opr ensure_in_register(LIRGenerator* gen, LIR_Opr obj, BasicType type); 89 }; 90 91 #endif // SHARE_GC_SHENANDOAH_C1_SHENANDOAHBARRIERSETC1_HPP