@@ -76,6 +76,29 @@ inline oop ShenandoahBarrierSet::load_reference_barrier_mutator(oop obj, T* load
76
76
return fwd;
77
77
}
78
78
79
+ inline oop ShenandoahBarrierSet::load_reference_barrier (oop obj) {
80
+ if (!ShenandoahLoadRefBarrier) {
81
+ return obj;
82
+ }
83
+ if (_heap->has_forwarded_objects () &&
84
+ _heap->in_collection_set (obj)) { // Subsumes NULL-check
85
+ assert (obj != NULL , " cset check must have subsumed NULL-check" );
86
+ oop fwd = resolve_forwarded_not_null (obj);
87
+ // TODO: It should not be necessary to check evac-in-progress here.
88
+ // We do it for mark-compact, which may have forwarded objects,
89
+ // and objects in cset and gets here via runtime barriers.
90
+ // We can probably fix this as soon as mark-compact has its own
91
+ // marking phase.
92
+ if (obj == fwd && _heap->is_evacuation_in_progress ()) {
93
+ Thread* t = Thread::current ();
94
+ ShenandoahEvacOOMScope oom_evac_scope (t);
95
+ return _heap->evacuate_object (obj, t);
96
+ }
97
+ return fwd;
98
+ }
99
+ return obj;
100
+ }
101
+
79
102
template <class T >
80
103
inline oop ShenandoahBarrierSet::load_reference_barrier_native (oop obj, T* load_addr) {
81
104
if (CompressedOops::is_null (obj)) {
@@ -92,7 +115,7 @@ inline oop ShenandoahBarrierSet::load_reference_barrier_native(oop obj, T* load_
92
115
}
93
116
}
94
117
95
- oop fwd = load_reference_barrier_not_null (obj);
118
+ oop fwd = load_reference_barrier (obj);
96
119
if (ShenandoahSelfFixing && load_addr != NULL && fwd != obj) {
97
120
// Since we are here and we know the load address, update the reference.
98
121
ShenandoahHeap::cas_oop (fwd, load_addr, obj);
@@ -128,8 +151,7 @@ inline void ShenandoahBarrierSet::satb_barrier(T *field) {
128
151
}
129
152
130
153
inline void ShenandoahBarrierSet::satb_enqueue (oop value) {
131
- assert (value != NULL , " checked before" );
132
- if (ShenandoahSATBBarrier && _heap->is_concurrent_mark_in_progress ()) {
154
+ if (value != NULL && ShenandoahSATBBarrier && _heap->is_concurrent_mark_in_progress ()) {
133
155
enqueue (value);
134
156
}
135
157
}
@@ -142,7 +164,6 @@ inline void ShenandoahBarrierSet::storeval_barrier(oop obj) {
142
164
143
165
inline void ShenandoahBarrierSet::keep_alive_if_weak (DecoratorSet decorators, oop value) {
144
166
assert ((decorators & ON_UNKNOWN_OOP_REF) == 0 , " Reference strength must be known" );
145
- assert (value != NULL , " checked by caller" );
146
167
const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0 ;
147
168
const bool peek = (decorators & AS_NO_KEEPALIVE) != 0 ;
148
169
if (!peek && !on_strong_oop_ref) {
@@ -152,7 +173,6 @@ inline void ShenandoahBarrierSet::keep_alive_if_weak(DecoratorSet decorators, oo
152
173
153
174
template <DecoratorSet decorators>
154
175
inline void ShenandoahBarrierSet::keep_alive_if_weak (oop value) {
155
- assert (value != NULL , " checked by caller" );
156
176
assert ((decorators & ON_UNKNOWN_OOP_REF) == 0 , " Reference strength must be known" );
157
177
if (!HasDecorator<decorators, ON_STRONG_OOP_REF>::value &&
158
178
!HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {
@@ -167,9 +187,7 @@ inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_loa
167
187
if (value != NULL ) {
168
188
ShenandoahBarrierSet *const bs = ShenandoahBarrierSet::barrier_set ();
169
189
value = bs->load_reference_barrier_native (value, addr);
170
- if (value != NULL ) {
171
- bs->keep_alive_if_weak <decorators>(value);
172
- }
190
+ bs->keep_alive_if_weak <decorators>(value);
173
191
}
174
192
return value;
175
193
}
@@ -178,23 +196,19 @@ template <DecoratorSet decorators, typename BarrierSetT>
178
196
template <typename T>
179
197
inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_load_in_heap(T* addr) {
180
198
oop value = Raw::oop_load_in_heap (addr);
181
- if (value != NULL ) {
182
- ShenandoahBarrierSet *const bs = ShenandoahBarrierSet::barrier_set ();
183
- value = bs->load_reference_barrier_not_null (value);
184
- bs->keep_alive_if_weak <decorators>(value);
185
- }
199
+ ShenandoahBarrierSet *const bs = ShenandoahBarrierSet::barrier_set ();
200
+ value = bs->load_reference_barrier (value);
201
+ bs->keep_alive_if_weak <decorators>(value);
186
202
return value;
187
203
}
188
204
189
205
template <DecoratorSet decorators, typename BarrierSetT>
190
206
inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_load_in_heap_at(oop base, ptrdiff_t offset) {
191
207
oop value = Raw::oop_load_in_heap_at (base, offset);
192
- if (value != NULL ) {
193
- ShenandoahBarrierSet *const bs = ShenandoahBarrierSet::barrier_set ();
194
- value = bs->load_reference_barrier_not_null (value);
195
- bs->keep_alive_if_weak (AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset),
196
- value);
197
- }
208
+ ShenandoahBarrierSet *const bs = ShenandoahBarrierSet::barrier_set ();
209
+ value = bs->load_reference_barrier (value);
210
+ bs->keep_alive_if_weak (AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset),
211
+ value);
198
212
return value;
199
213
}
200
214
@@ -239,10 +253,8 @@ inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_ato
239
253
240
254
// Note: We don't need a keep-alive-barrier here. We already enqueue any loaded reference for SATB anyway,
241
255
// because it must be the previous value.
242
- if (res != NULL ) {
243
- res = ShenandoahBarrierSet::barrier_set ()->load_reference_barrier_not_null (res);
244
- bs->satb_enqueue (res);
245
- }
256
+ res = ShenandoahBarrierSet::barrier_set ()->load_reference_barrier (res);
257
+ bs->satb_enqueue (res);
246
258
return res;
247
259
}
248
260
@@ -267,10 +279,8 @@ inline oop ShenandoahBarrierSet::AccessBarrier<decorators, BarrierSetT>::oop_ato
267
279
268
280
// Note: We don't need a keep-alive-barrier here. We already enqueue any loaded reference for SATB anyway,
269
281
// because it must be the previous value.
270
- if (previous != NULL ) {
271
- previous = ShenandoahBarrierSet::barrier_set ()->load_reference_barrier_not_null (previous);
272
- bs->satb_enqueue (previous);
273
- }
282
+ previous = ShenandoahBarrierSet::barrier_set ()->load_reference_barrier (previous);
283
+ bs->satb_enqueue (previous);
274
284
return previous;
275
285
}
276
286
0 commit comments