Path: blob/master/src/hotspot/cpu/ppc/gc/shenandoah/c1/shenandoahBarrierSetC1_ppc.cpp
66646 views
/*1* Copyright (c) 2018, 2021, Red Hat, Inc. All rights reserved.2* Copyright (c) 2012, 2021 SAP SE. 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 it6* under the terms of the GNU General Public License version 2 only, as7* published by the Free Software Foundation.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 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 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*23*/2425#include "precompiled.hpp"26#include "asm/macroAssembler.inline.hpp"27#include "c1/c1_LIRAssembler.hpp"28#include "c1/c1_MacroAssembler.hpp"29#include "gc/shenandoah/shenandoahBarrierSet.hpp"30#include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp"31#include "gc/shenandoah/c1/shenandoahBarrierSetC1.hpp"3233#define __ masm->masm()->3435void LIR_OpShenandoahCompareAndSwap::emit_code(LIR_Assembler *masm) {36__ block_comment("LIR_OpShenandoahCompareAndSwap (shenandaohgc) {");3738Register addr = _addr->as_register_lo();39Register new_val = _new_value->as_register();40Register cmp_val = _cmp_value->as_register();41Register tmp1 = _tmp1->as_register();42Register tmp2 = _tmp2->as_register();43Register result = result_opr()->as_register();4445if (ShenandoahIUBarrier) {46ShenandoahBarrierSet::assembler()->iu_barrier(masm->masm(), new_val, tmp1, tmp2,47MacroAssembler::PRESERVATION_FRAME_LR_GP_FP_REGS);48}4950if (UseCompressedOops) {51__ encode_heap_oop(cmp_val, cmp_val);52__ encode_heap_oop(new_val, new_val);53}5455// Due to the memory barriers emitted in ShenandoahBarrierSetC1::atomic_cmpxchg_at_resolved,56// there is no need to specify stronger memory semantics.57ShenandoahBarrierSet::assembler()->cmpxchg_oop(masm->masm(), addr, cmp_val, new_val, tmp1, tmp2,58false, result);5960if (UseCompressedOops) {61__ decode_heap_oop(cmp_val);62__ decode_heap_oop(new_val);63}6465__ block_comment("} LIR_OpShenandoahCompareAndSwap (shenandaohgc)");66}6768#undef __6970#ifdef ASSERT71#define __ gen->lir(__FILE__, __LINE__)->72#else73#define __ gen->lir()->74#endif7576LIR_Opr ShenandoahBarrierSetC1::atomic_cmpxchg_at_resolved(LIRAccess &access, LIRItem &cmp_value, LIRItem &new_value) {77BasicType bt = access.type();7879if (access.is_oop()) {80LIRGenerator* gen = access.gen();8182if (ShenandoahCASBarrier) {83if (support_IRIW_for_not_multiple_copy_atomic_cpu) {84__ membar();85} else {86__ membar_release();87}88}8990if (ShenandoahSATBBarrier) {91pre_barrier(gen, access.access_emit_info(), access.decorators(), access.resolved_addr(),92LIR_OprFact::illegalOpr);93}9495if (ShenandoahCASBarrier) {96cmp_value.load_item();97new_value.load_item();9899LIR_Opr t1 = gen->new_register(T_OBJECT);100LIR_Opr t2 = gen->new_register(T_OBJECT);101LIR_Opr addr = access.resolved_addr()->as_address_ptr()->base();102LIR_Opr result = gen->new_register(T_INT);103104__ append(new LIR_OpShenandoahCompareAndSwap(addr, cmp_value.result(), new_value.result(), t1, t2, result));105106if (support_IRIW_for_not_multiple_copy_atomic_cpu) {107__ membar_acquire();108} else {109__ membar();110}111112return result;113}114}115116return BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);117}118119LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess &access, LIRItem &value) {120LIRGenerator* gen = access.gen();121BasicType type = access.type();122123LIR_Opr result = gen->new_register(type);124value.load_item();125LIR_Opr value_opr = value.result();126127if (support_IRIW_for_not_multiple_copy_atomic_cpu) {128__ membar();129} else {130__ membar_release();131}132133if (access.is_oop()) {134value_opr = iu_barrier(access.gen(), value_opr, access.access_emit_info(), access.decorators());135}136137assert(type == T_INT || is_reference_type(type) LP64_ONLY( || type == T_LONG ), "unexpected type");138LIR_Opr tmp_xchg = gen->new_register(T_INT);139__ xchg(access.resolved_addr(), value_opr, result, tmp_xchg);140141if (access.is_oop()) {142result = load_reference_barrier_impl(access.gen(), result, LIR_OprFact::addressConst(0),143access.decorators());144145LIR_Opr tmp_barrier = gen->new_register(type);146__ move(result, tmp_barrier);147result = tmp_barrier;148149if (ShenandoahSATBBarrier) {150pre_barrier(access.gen(), access.access_emit_info(), access.decorators(), LIR_OprFact::illegalOpr, result);151}152}153154if (support_IRIW_for_not_multiple_copy_atomic_cpu) {155__ membar_acquire();156} else {157__ membar();158}159160return result;161}162163164