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 */
77
78 __ append(new LIR_OpShenandoahCompareAndSwap(addr, cmp_value.result(), new_value.result(), t1, t2, result));
79 return result;
80 }
81 }
82 return BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);
83 }
84
85 LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value) {
86 LIRGenerator* gen = access.gen();
87 BasicType type = access.type();
88
89 LIR_Opr result = gen->new_register(type);
90 value.load_item();
91 LIR_Opr value_opr = value.result();
92
93 if (access.is_oop()) {
94 value_opr = storeval_barrier(access.gen(), value_opr, access.access_emit_info(), access.decorators());
95 }
96
97 assert(type == T_INT || type == T_OBJECT || type == T_ARRAY LP64_ONLY( || type == T_LONG ), "unexpected type");
98 LIR_Opr tmp = gen->new_register(T_INT);
99 __ xchg(access.resolved_addr(), value_opr, result, tmp);
100
101 if (access.is_oop()) {
102 result = load_reference_barrier(access.gen(), result);
103 LIR_Opr tmp = gen->new_register(type);
104 __ move(result, tmp);
105 result = tmp;
106 if (ShenandoahSATBBarrier) {
107 pre_barrier(access.gen(), access.access_emit_info(), access.decorators(), LIR_OprFact::illegalOpr,
108 result /* pre_val */);
109 }
110 }
111
112 return result;
113 }
|
1 /*
2 * Copyright (c) 2018, 2019, 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 */
77
78 __ append(new LIR_OpShenandoahCompareAndSwap(addr, cmp_value.result(), new_value.result(), t1, t2, result));
79 return result;
80 }
81 }
82 return BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);
83 }
84
85 LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value) {
86 LIRGenerator* gen = access.gen();
87 BasicType type = access.type();
88
89 LIR_Opr result = gen->new_register(type);
90 value.load_item();
91 LIR_Opr value_opr = value.result();
92
93 if (access.is_oop()) {
94 value_opr = storeval_barrier(access.gen(), value_opr, access.access_emit_info(), access.decorators());
95 }
96
97 assert(type == T_INT || is_reference_type(type) LP64_ONLY( || type == T_LONG ), "unexpected type");
98 LIR_Opr tmp = gen->new_register(T_INT);
99 __ xchg(access.resolved_addr(), value_opr, result, tmp);
100
101 if (access.is_oop()) {
102 result = load_reference_barrier(access.gen(), result);
103 LIR_Opr tmp = gen->new_register(type);
104 __ move(result, tmp);
105 result = tmp;
106 if (ShenandoahSATBBarrier) {
107 pre_barrier(access.gen(), access.access_emit_info(), access.decorators(), LIR_OprFact::illegalOpr,
108 result /* pre_val */);
109 }
110 }
111
112 return result;
113 }
|