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 24source_hpp %{ 25#include "gc/shenandoah/shenandoahBarrierSetAssembler.hpp" 26#include "gc/shenandoah/c2/shenandoahSupport.hpp" 27%} 28 29instruct compareAndSwapP_shenandoah(rRegI res, 30 memory mem_ptr, 31 rRegP tmp1, rRegP tmp2, 32 rax_RegP oldval, rRegP newval, 33 rFlagsReg cr) 34%{ 35 predicate(VM_Version::supports_cx8()); 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 compareAndSwapN_shenandoah(rRegI res, 53 memory mem_ptr, 54 rRegP tmp1, rRegP tmp2, 55 rax_RegN oldval, rRegN newval, 56 rFlagsReg cr) %{ 57 match(Set res (ShenandoahCompareAndSwapN mem_ptr (Binary oldval newval))); 58 match(Set res (ShenandoahWeakCompareAndSwapN mem_ptr (Binary oldval newval))); 59 effect(TEMP tmp1, TEMP tmp2, KILL cr, KILL oldval); 60 61 format %{ "shenandoah_cas_oop $mem_ptr,$newval" %} 62 63 ins_encode %{ 64 ShenandoahBarrierSet::assembler()->cmpxchg_oop(&_masm, 65 $res$$Register, $mem_ptr$$Address, $oldval$$Register, $newval$$Register, 66 false, // swap 67 $tmp1$$Register, $tmp2$$Register 68 ); 69 %} 70 ins_pipe( pipe_cmpxchg ); 71%} 72 73instruct compareAndExchangeN_shenandoah(memory mem_ptr, 74 rax_RegN oldval, rRegN newval, 75 rRegP tmp1, rRegP tmp2, 76 rFlagsReg cr) %{ 77 match(Set oldval (ShenandoahCompareAndExchangeN mem_ptr (Binary oldval newval))); 78 effect(TEMP tmp1, TEMP tmp2, KILL cr); 79 80 format %{ "shenandoah_cas_oop $mem_ptr,$newval" %} 81 82 ins_encode %{ 83 ShenandoahBarrierSet::assembler()->cmpxchg_oop(&_masm, 84 NULL, $mem_ptr$$Address, $oldval$$Register, $newval$$Register, 85 true, // exchange 86 $tmp1$$Register, $tmp2$$Register 87 ); 88 %} 89 ins_pipe( pipe_cmpxchg ); 90%} 91 92instruct compareAndExchangeP_shenandoah(memory mem_ptr, 93 rax_RegP oldval, rRegP newval, 94 rRegP tmp1, rRegP tmp2, 95 rFlagsReg cr) 96%{ 97 predicate(VM_Version::supports_cx8()); 98 match(Set oldval (ShenandoahCompareAndExchangeP mem_ptr (Binary oldval newval))); 99 effect(KILL cr, TEMP tmp1, TEMP tmp2); 100 ins_cost(1000); 101 102 format %{ "shenandoah_cas_oop $mem_ptr,$newval" %} 103 104 ins_encode %{ 105 ShenandoahBarrierSet::assembler()->cmpxchg_oop(&_masm, 106 NULL, $mem_ptr$$Address, $oldval$$Register, $newval$$Register, 107 true, // exchange 108 $tmp1$$Register, $tmp2$$Register 109 ); 110 %} 111 ins_pipe( pipe_cmpxchg ); 112%} 113