< prev index next >

src/hotspot/cpu/aarch64/gc/shenandoah/c1/shenandoahBarrierSetC1_aarch64.cpp

Print this page

  1 /*
  2  * Copyright (c) 2018, 2021, 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  *

 71 #endif
 72 
 73 LIR_Opr ShenandoahBarrierSetC1::atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value) {
 74   BasicType bt = access.type();
 75   if (access.is_oop()) {
 76     LIRGenerator *gen = access.gen();
 77     if (ShenandoahSATBBarrier) {
 78       pre_barrier(gen, access.access_emit_info(), access.decorators(), access.resolved_addr(),
 79                   LIR_OprFact::illegalOpr /* pre_val */);
 80     }
 81     if (ShenandoahCASBarrier) {
 82       cmp_value.load_item();
 83       new_value.load_item();
 84 
 85       LIR_Opr t1 = gen->new_register(T_OBJECT);
 86       LIR_Opr t2 = gen->new_register(T_OBJECT);
 87       LIR_Opr addr = access.resolved_addr()->as_address_ptr()->base();
 88       LIR_Opr result = gen->new_register(T_INT);
 89 
 90       __ append(new LIR_OpShenandoahCompareAndSwap(addr, cmp_value.result(), new_value.result(), t1, t2, result));




 91       return result;
 92     }
 93   }
 94   return BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);
 95 }
 96 
 97 LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value) {
 98   LIRGenerator* gen = access.gen();
 99   BasicType type = access.type();
100 
101   LIR_Opr result = gen->new_register(type);
102   value.load_item();
103   LIR_Opr value_opr = value.result();
104 
105   if (access.is_oop()) {
106     value_opr = iu_barrier(access.gen(), value_opr, access.access_emit_info(), access.decorators());
107   }
108 
109   assert(type == T_INT || is_reference_type(type) LP64_ONLY( || type == T_LONG ), "unexpected type");
110   LIR_Opr tmp = gen->new_register(T_INT);
111   __ xchg(access.resolved_addr(), value_opr, result, tmp);
112 
113   if (access.is_oop()) {
114     result = load_reference_barrier(access.gen(), result, LIR_OprFact::addressConst(0), access.decorators());
115     LIR_Opr tmp = gen->new_register(type);
116     __ move(result, tmp);
117     result = tmp;
118     if (ShenandoahSATBBarrier) {
119       pre_barrier(access.gen(), access.access_emit_info(), access.decorators(), LIR_OprFact::illegalOpr,
120                   result /* pre_val */);
121     }



122   }
123 
124   return result;
125 }

  1 /*
  2  * Copyright (c) 2018, 2021, Red Hat, Inc. All rights reserved.
  3  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *

 72 #endif
 73 
 74 LIR_Opr ShenandoahBarrierSetC1::atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value) {
 75   BasicType bt = access.type();
 76   if (access.is_oop()) {
 77     LIRGenerator *gen = access.gen();
 78     if (ShenandoahSATBBarrier) {
 79       pre_barrier(gen, access.access_emit_info(), access.decorators(), access.resolved_addr(),
 80                   LIR_OprFact::illegalOpr /* pre_val */);
 81     }
 82     if (ShenandoahCASBarrier) {
 83       cmp_value.load_item();
 84       new_value.load_item();
 85 
 86       LIR_Opr t1 = gen->new_register(T_OBJECT);
 87       LIR_Opr t2 = gen->new_register(T_OBJECT);
 88       LIR_Opr addr = access.resolved_addr()->as_address_ptr()->base();
 89       LIR_Opr result = gen->new_register(T_INT);
 90 
 91       __ append(new LIR_OpShenandoahCompareAndSwap(addr, cmp_value.result(), new_value.result(), t1, t2, result));
 92 
 93       if (ShenandoahCardBarrier) {
 94         post_barrier(access, access.resolved_addr(), new_value.result());
 95       }
 96       return result;
 97     }
 98   }
 99   return BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);
100 }
101 
102 LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value) {
103   LIRGenerator* gen = access.gen();
104   BasicType type = access.type();
105 
106   LIR_Opr result = gen->new_register(type);
107   value.load_item();
108   LIR_Opr value_opr = value.result();
109 
110   if (access.is_oop()) {
111     value_opr = iu_barrier(access.gen(), value_opr, access.access_emit_info(), access.decorators());
112   }
113 
114   assert(type == T_INT || is_reference_type(type) LP64_ONLY( || type == T_LONG ), "unexpected type");
115   LIR_Opr tmp = gen->new_register(T_INT);
116   __ xchg(access.resolved_addr(), value_opr, result, tmp);
117 
118   if (access.is_oop()) {
119     result = load_reference_barrier(access.gen(), result, LIR_OprFact::addressConst(0), access.decorators());
120     LIR_Opr tmp = gen->new_register(type);
121     __ move(result, tmp);
122     result = tmp;
123     if (ShenandoahSATBBarrier) {
124       pre_barrier(access.gen(), access.access_emit_info(), access.decorators(), LIR_OprFact::illegalOpr,
125                   result /* pre_val */);
126     }
127     if (ShenandoahCardBarrier) {
128       post_barrier(access, access.resolved_addr(), result);
129     }
130   }
131 
132   return result;
133 }
< prev index next >