90
91 if (access.is_oop()) {
92 LIRGenerator* gen = access.gen();
93
94 if (ShenandoahSATBBarrier) {
95 pre_barrier(gen, access.access_emit_info(), access.decorators(), access.resolved_addr(),
96 LIR_OprFact::illegalOpr);
97 }
98
99 if (ShenandoahCASBarrier) {
100 cmp_value.load_item();
101 new_value.load_item();
102
103 LIR_Opr t1 = gen->new_register(T_OBJECT);
104 LIR_Opr t2 = gen->new_register(T_OBJECT);
105 LIR_Opr addr = access.resolved_addr()->as_address_ptr()->base();
106 LIR_Opr result = gen->new_register(T_INT);
107
108 __ append(new LIR_OpShenandoahCompareAndSwap(addr, cmp_value.result(), new_value.result(), t1, t2, result));
109
110 return result;
111 }
112 }
113
114 return BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);
115 }
116
117 LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess &access, LIRItem &value) {
118 LIRGenerator* gen = access.gen();
119 BasicType type = access.type();
120
121 LIR_Opr result = gen->new_register(type);
122 value.load_item();
123 LIR_Opr value_opr = value.result();
124
125 if (access.is_oop()) {
126 value_opr = iu_barrier(access.gen(), value_opr, access.access_emit_info(), access.decorators());
127 }
128
129 assert(type == T_INT || is_reference_type(type) LP64_ONLY( || type == T_LONG ), "unexpected type");
130 LIR_Opr tmp_xchg = gen->new_register(T_INT);
131 __ xchg(access.resolved_addr(), value_opr, result, tmp_xchg);
132
133 if (access.is_oop()) {
134 result = load_reference_barrier_impl(access.gen(), result, LIR_OprFact::addressConst(0),
135 access.decorators());
136
137 LIR_Opr tmp_barrier = gen->new_register(type);
138 __ move(result, tmp_barrier);
139 result = tmp_barrier;
140
141 if (ShenandoahSATBBarrier) {
142 pre_barrier(access.gen(), access.access_emit_info(), access.decorators(), LIR_OprFact::illegalOpr, result);
143 }
144 }
145
146 return result;
147 }
|
90
91 if (access.is_oop()) {
92 LIRGenerator* gen = access.gen();
93
94 if (ShenandoahSATBBarrier) {
95 pre_barrier(gen, access.access_emit_info(), access.decorators(), access.resolved_addr(),
96 LIR_OprFact::illegalOpr);
97 }
98
99 if (ShenandoahCASBarrier) {
100 cmp_value.load_item();
101 new_value.load_item();
102
103 LIR_Opr t1 = gen->new_register(T_OBJECT);
104 LIR_Opr t2 = gen->new_register(T_OBJECT);
105 LIR_Opr addr = access.resolved_addr()->as_address_ptr()->base();
106 LIR_Opr result = gen->new_register(T_INT);
107
108 __ append(new LIR_OpShenandoahCompareAndSwap(addr, cmp_value.result(), new_value.result(), t1, t2, result));
109
110 if (ShenandoahCardBarrier) {
111 post_barrier(access, access.resolved_addr(), new_value.result());
112 }
113
114 return result;
115 }
116 }
117
118 return BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);
119 }
120
121 LIR_Opr ShenandoahBarrierSetC1::atomic_xchg_at_resolved(LIRAccess &access, LIRItem &value) {
122 LIRGenerator* gen = access.gen();
123 BasicType type = access.type();
124
125 LIR_Opr result = gen->new_register(type);
126 value.load_item();
127 LIR_Opr value_opr = value.result();
128
129 if (access.is_oop()) {
130 value_opr = iu_barrier(access.gen(), value_opr, access.access_emit_info(), access.decorators());
131 }
132
133 assert(type == T_INT || is_reference_type(type) LP64_ONLY( || type == T_LONG ), "unexpected type");
134 LIR_Opr tmp_xchg = gen->new_register(T_INT);
135 __ xchg(access.resolved_addr(), value_opr, result, tmp_xchg);
136
137 if (access.is_oop()) {
138 result = load_reference_barrier_impl(access.gen(), result, LIR_OprFact::addressConst(0),
139 access.decorators());
140
141 LIR_Opr tmp_barrier = gen->new_register(type);
142 __ move(result, tmp_barrier);
143 result = tmp_barrier;
144
145 if (ShenandoahSATBBarrier) {
146 pre_barrier(access.gen(), access.access_emit_info(), access.decorators(), LIR_OprFact::illegalOpr, result);
147 }
148
149 if (ShenandoahCardBarrier) {
150 post_barrier(access, access.resolved_addr(), result);
151 }
152 }
153
154 return result;
155 }
|