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 rRegP tmp1, rRegP tmp2, 33 rax_RegP oldval, rRegP newval, 34 rFlagsReg cr) 35%{ 36 predicate(VM_Version::supports_cx8()); 37 match(Set res (ShenandoahCompareAndSwapP mem_ptr (Binary oldval newval))); 38 match(Set res (ShenandoahWeakCompareAndSwapP mem_ptr (Binary oldval newval))); 39 effect(TEMP tmp1, TEMP tmp2, KILL cr, KILL oldval); 40 41 format %{ "shenandoah_cas_oop $mem_ptr,$newval" %} 42 43 ins_encode %{ 44 ShenandoahBarrierSet::assembler()->cmpxchg_oop(&_masm, 45 $res$$Register, $mem_ptr$$Address, $oldval$$Register, $newval$$Register, 46 false, // swap 47 $tmp1$$Register, $tmp2$$Register 48 ); 49 %} 50 ins_pipe( pipe_cmpxchg ); 51%} 52 53instruct compareAndSwapN_shenandoah(rRegI res, 54 memory mem_ptr, 55 rRegP tmp1, rRegP tmp2, 56 rax_RegN oldval, rRegN newval, 57 rFlagsReg cr) %{ 58 match(Set res (ShenandoahCompareAndSwapN mem_ptr (Binary oldval newval))); 59 match(Set res (ShenandoahWeakCompareAndSwapN mem_ptr (Binary oldval newval))); 60 effect(TEMP tmp1, TEMP tmp2, KILL cr, KILL oldval); 61 62 format %{ "shenandoah_cas_oop $mem_ptr,$newval" %} 63 64 ins_encode %{ 65 ShenandoahBarrierSet::assembler()->cmpxchg_oop(&_masm, 66 $res$$Register, $mem_ptr$$Address, $oldval$$Register, $newval$$Register, 67 false, // swap 68 $tmp1$$Register, $tmp2$$Register 69 ); 70 %} 71 ins_pipe( pipe_cmpxchg ); 72%} 73 74instruct compareAndExchangeN_shenandoah(memory mem_ptr, 75 rax_RegN oldval, rRegN newval, 76 rRegP tmp1, rRegP tmp2, 77 rFlagsReg cr) %{ 78 match(Set oldval (ShenandoahCompareAndExchangeN mem_ptr (Binary oldval newval))); 79 effect(TEMP tmp1, TEMP tmp2, KILL cr); 80 81 format %{ "shenandoah_cas_oop $mem_ptr,$newval" %} 82 83 ins_encode %{ 84 ShenandoahBarrierSet::assembler()->cmpxchg_oop(&_masm, 85 NULL, $mem_ptr$$Address, $oldval$$Register, $newval$$Register, 86 true, // exchange 87 $tmp1$$Register, $tmp2$$Register 88 ); 89 %} 90 ins_pipe( pipe_cmpxchg ); 91%} 92 93instruct compareAndExchangeP_shenandoah(memory mem_ptr, 94 rax_RegP oldval, rRegP newval, 95 rRegP tmp1, rRegP tmp2, 96 rFlagsReg cr) 97%{ 98 predicate(VM_Version::supports_cx8()); 99 match(Set oldval (ShenandoahCompareAndExchangeP mem_ptr (Binary oldval newval))); 100 effect(KILL cr, TEMP tmp1, TEMP tmp2); 101 ins_cost(1000); 102 103 format %{ "shenandoah_cas_oop $mem_ptr,$newval" %} 104 105 ins_encode %{ 106 ShenandoahBarrierSet::assembler()->cmpxchg_oop(&_masm, 107 NULL, $mem_ptr$$Address, $oldval$$Register, $newval$$Register, 108 true, // exchange 109 $tmp1$$Register, $tmp2$$Register 110 ); 111 %} 112 ins_pipe( pipe_cmpxchg ); 113%} 114