diff --git a/src/hotspot/share/gc/shared/c1/modRefBarrierSetC1.cpp b/src/hotspot/share/gc/shared/c1/modRefBarrierSetC1.cpp new file mode 100644 index 0000000..799d0d7 --- /dev/null +++ b/src/hotspot/share/gc/shared/c1/modRefBarrierSetC1.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc/shared/c1/modRefBarrierSetC1.hpp" +#include "utilities/macros.hpp" + +#ifdef ASSERT +#define __ lir_generator->lir(__FILE__, __LINE__)-> +#else +#define __ lir_generator->lir()-> +#endif + +void ModRefBarrierSetC1::store_at_resolved(LIRGenerator *lir_generator, DecoratorSet decorators, BasicType type, + LIR_Opr addr, LIRItem& base, LIR_Opr offset, LIR_Opr value, + CodeEmitInfo* patch_info, CodeEmitInfo* store_emit_info) { + bool is_oop = type == T_OBJECT || type == T_ARRAY; + bool on_array = (decorators & IN_HEAP_ARRAY) != 0; + bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0; + + if (is_oop) { + pre_barrier(lir_generator, decorators, addr, LIR_OprFact::illegalOpr /* pre_val */, patch_info); + } + + BarrierSetC1::store_at_resolved(lir_generator, decorators, type, addr, base, offset, value, patch_info, store_emit_info); + + if (is_oop) { + bool precise = on_array || on_anonymous; + LIR_Opr post_addr = precise ? addr : base.result(); + post_barrier(lir_generator, decorators, post_addr, value); + } +} + +LIR_Opr ModRefBarrierSetC1::atomic_cmpxchg_resolved(LIRGenerator *lir_generator, DecoratorSet decorators, BasicType type, + LIR_Opr addr, LIRItem& base, LIRItem& offset, LIRItem& cmp_value, LIRItem& new_value) { + bool is_oop = type == T_OBJECT || type == T_ARRAY; + + if (is_oop) { + pre_barrier(lir_generator, decorators, addr, LIR_OprFact::illegalOpr /* pre_val */, NULL); + } + + LIR_Opr result = BarrierSetC1::atomic_cmpxchg_resolved(lir_generator, decorators, type, addr, base, offset, cmp_value, new_value); + + if (is_oop) { + post_barrier(lir_generator, decorators, addr, new_value.result()); + } + + return result; +} + +LIR_Opr ModRefBarrierSetC1::atomic_xchg_resolved(LIRGenerator* lir_generator, DecoratorSet decorators, BasicType type, + LIR_Opr addr, LIRItem& base, LIRItem& offset, LIRItem& value) { + bool is_oop = type == T_OBJECT || type == T_ARRAY; + + if (is_oop) { + pre_barrier(lir_generator, decorators, addr, LIR_OprFact::illegalOpr /* pre_val */, NULL); + } + + LIR_Opr result = BarrierSetC1::atomic_xchg_resolved(lir_generator, decorators, type, addr, base, offset, value); + + if (is_oop) { + post_barrier(lir_generator, decorators, addr, value.result()); + } + + return result; +} + +// This overrides the default to resolve the address into a register, assuming it will be used by a write barrier +void ModRefBarrierSetC1::store_at(LIRGenerator *lir_generator, DecoratorSet decorators, BasicType type, + LIRItem& base, LIR_Opr offset, LIR_Opr value, + CodeEmitInfo* patch_info, CodeEmitInfo* store_emit_info) { + bool is_oop = type == T_OBJECT || type == T_ARRAY; + bool needs_patching = (decorators & C1_NEEDS_PATCHING) != 0; + LIR_Opr addr = resolve_address(lir_generator, decorators, type, base, offset, !needs_patching && is_oop); + store_at_resolved(lir_generator, decorators, type, addr, base, offset, value, patch_info, store_emit_info); +}