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 */
89 }
90 }
91 return BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);
92 }
93
94 LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value) {
95 LIRGenerator* gen = access.gen();
96 BasicType type = access.type();
97
98 LIR_Opr result = gen->new_register(type);
99 value.load_item();
100 LIR_Opr value_opr = value.result();
101
102 if (access.is_oop()) {
103 value_opr = storeval_barrier(access.gen(), value_opr, access.access_emit_info(), access.decorators());
104 }
105
106 // Because we want a 2-arg form of xchg and xadd
107 __ move(value_opr, result);
108
109 assert(type == T_INT || type == T_OBJECT || type == T_ARRAY LP64_ONLY( || type == T_LONG ), "unexpected type");
110 __ xchg(access.resolved_addr(), result, result, LIR_OprFact::illegalOpr);
111
112 if (access.is_oop()) {
113 result = load_reference_barrier(access.gen(), result);
114 LIR_Opr tmp = gen->new_register(type);
115 __ move(result, tmp);
116 result = tmp;
117 if (ShenandoahSATBBarrier) {
118 pre_barrier(access.gen(), access.access_emit_info(), access.decorators(), LIR_OprFact::illegalOpr,
119 result /* pre_val */);
120 }
121 }
122
123 return result;
124 }
|
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 */
89 }
90 }
91 return BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);
92 }
93
94 LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value) {
95 LIRGenerator* gen = access.gen();
96 BasicType type = access.type();
97
98 LIR_Opr result = gen->new_register(type);
99 value.load_item();
100 LIR_Opr value_opr = value.result();
101
102 if (access.is_oop()) {
103 value_opr = storeval_barrier(access.gen(), value_opr, access.access_emit_info(), access.decorators());
104 }
105
106 // Because we want a 2-arg form of xchg and xadd
107 __ move(value_opr, result);
108
109 assert(type == T_INT || is_reference_type(type) LP64_ONLY( || type == T_LONG ), "unexpected type");
110 __ xchg(access.resolved_addr(), result, result, LIR_OprFact::illegalOpr);
111
112 if (access.is_oop()) {
113 result = load_reference_barrier(access.gen(), result);
114 LIR_Opr tmp = gen->new_register(type);
115 __ move(result, tmp);
116 result = tmp;
117 if (ShenandoahSATBBarrier) {
118 pre_barrier(access.gen(), access.access_emit_info(), access.decorators(), LIR_OprFact::illegalOpr,
119 result /* pre_val */);
120 }
121 }
122
123 return result;
124 }
|