1 /* 2 * Copyright (c) 2017, 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 25 #include "precompiled.hpp" 26 #include "gc/shared/c1ModRefBSCodeGen.hpp" 27 #include "utilities/macros.hpp" 28 29 #ifdef ASSERT 30 #define __ lir_generator->lir(__FILE__, __LINE__)-> 31 #else 32 #define __ lir_generator->lir()-> 33 #endif 34 35 void C1ModRefBSCodeGen::store_at_resolved(LIRGenerator *lir_generator, C1DecoratorSet decorators, BasicType type, 36 LIR_Opr addr, LIRItem& base, LIR_Opr offset, LIR_Opr value, 37 CodeEmitInfo* patch_info, CodeEmitInfo* store_emit_info) { 38 bool is_oop = type == T_OBJECT || type == T_ARRAY; 39 bool on_array = (decorators & C1_ACCESS_ON_ARRAY) != 0; 40 bool on_anonymous = (decorators & C1_ACCESS_ON_ANONYMOUS) != 0; 41 42 if (is_oop) { 43 pre_barrier(lir_generator, decorators, addr, LIR_OprFact::illegalOpr /* pre_val */, patch_info); 44 } 45 46 C1BarrierSetCodeGen::store_at_resolved(lir_generator, decorators, type, addr, base, offset, value, patch_info, store_emit_info); 47 48 if (is_oop) { 49 bool precise = on_array || on_anonymous; 50 LIR_Opr post_addr = precise ? addr : base.result(); 51 post_barrier(lir_generator, decorators, post_addr, value); 52 } 53 } 54 55 LIR_Opr C1ModRefBSCodeGen::cas_at_resolved(LIRGenerator *lir_generator, C1DecoratorSet decorators, BasicType type, 56 LIR_Opr addr, LIRItem& base, LIRItem& offset, LIRItem& cmp_value, LIRItem& new_value) { 57 bool is_oop = type == T_OBJECT || type == T_ARRAY; 58 59 if (is_oop) { 60 pre_barrier(lir_generator, decorators, addr, LIR_OprFact::illegalOpr /* pre_val */, NULL); 61 } 62 63 LIR_Opr result = C1BarrierSetCodeGen::cas_at_resolved(lir_generator, decorators, type, addr, base, offset, cmp_value, new_value); 64 65 if (is_oop) { 66 post_barrier(lir_generator, decorators, addr, new_value.result()); 67 } 68 69 return result; 70 } 71 72 LIR_Opr C1ModRefBSCodeGen::swap_at_resolved(LIRGenerator* lir_generator, C1DecoratorSet decorators, BasicType type, 73 LIR_Opr addr, LIRItem& base, LIRItem& offset, LIRItem& value) { 74 bool is_oop = type == T_OBJECT || type == T_ARRAY; 75 76 if (is_oop) { 77 pre_barrier(lir_generator, decorators, addr, LIR_OprFact::illegalOpr /* pre_val */, NULL); 78 } 79 80 LIR_Opr result = C1BarrierSetCodeGen::swap_at_resolved(lir_generator, decorators, type, addr, base, offset, value); 81 82 if (is_oop) { 83 post_barrier(lir_generator, decorators, addr, value.result()); 84 } 85 86 return result; 87 }