1// 2// Copyright (c) 2018, Red Hat, Inc. 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 25source_hpp %{ 26#include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" 27#include "gc/shenandoah/c2/shenandoahSupport.hpp" 28%} 29 30instruct compareAndSwapP_shenandoah(rRegI res, 31 memory mem_ptr, 32 eRegP tmp1, eRegP tmp2, 33 eAXRegP oldval, eRegP newval, 34 eFlagsReg cr) 35%{ 36 match(Set res (ShenandoahCompareAndSwapP mem_ptr (Binary oldval newval))); 37 match(Set res (ShenandoahWeakCompareAndSwapP mem_ptr (Binary oldval newval))); 38 effect(TEMP tmp1, TEMP tmp2, KILL cr, KILL oldval); 39 40 format %{ "shenandoah_cas_oop $mem_ptr,$newval" %} 41 42 ins_encode %{ 43 ShenandoahBarrierSet::assembler()->cmpxchg_oop(&_masm, 44 $res$$Register, $mem_ptr$$Address, $oldval$$Register, $newval$$Register, 45 false, // swap 46 $tmp1$$Register, $tmp2$$Register 47 ); 48 %} 49 ins_pipe( pipe_cmpxchg ); 50%} 51 52instruct compareAndExchangeP_shenandoah(memory mem_ptr, 53 eAXRegP oldval, eRegP newval, 54 eRegP tmp1, eRegP tmp2, 55 eFlagsReg cr) 56%{ 57 match(Set oldval (ShenandoahCompareAndExchangeP mem_ptr (Binary oldval newval))); 58 effect(KILL cr, TEMP tmp1, TEMP tmp2); 59 ins_cost(1000); 60 61 format %{ "shenandoah_cas_oop $mem_ptr,$newval" %} 62 63 ins_encode %{ 64 ShenandoahBarrierSet::assembler()->cmpxchg_oop(&_masm, 65 NULL, $mem_ptr$$Address, $oldval$$Register, $newval$$Register, 66 true, // exchange 67 $tmp1$$Register, $tmp2$$Register 68 ); 69 %} 70 ins_pipe( pipe_cmpxchg ); 71%} 72