170 // the contended write might have been NULL.
171 oop result = ShenandoahBarrierSet::resolve_forwarded(witness);
172 shenandoah_assert_not_forwarded_except(p, result, (result == NULL));
173 shenandoah_assert_not_in_cset_except(p, result, (result == NULL) || cancelled_gc());
174 return result;
175 } else {
176 // Success! We have updated with known to-space copy. We have already asserted it is sane.
177 return forwarded_oop;
178 }
179 } else {
180 shenandoah_assert_not_forwarded(p, heap_oop);
181 return heap_oop;
182 }
183 }
184
185 inline bool ShenandoahHeap::cancelled_gc() const {
186 return _cancelled_gc.get() == CANCELLED;
187 }
188
189 inline bool ShenandoahHeap::check_cancelled_gc_and_yield(bool sts_active) {
190 if (! (sts_active && ShenandoahSuspendibleWorkers)) {
191 return cancelled_gc();
192 }
193
194 jbyte prev = _cancelled_gc.cmpxchg(NOT_CANCELLED, CANCELLABLE);
195 if (prev == CANCELLABLE || prev == NOT_CANCELLED) {
196 if (SuspendibleThreadSet::should_yield()) {
197 SuspendibleThreadSet::yield();
198 }
199
200 // Back to CANCELLABLE. The thread that poked NOT_CANCELLED first gets
201 // to restore to CANCELLABLE.
202 if (prev == CANCELLABLE) {
203 _cancelled_gc.set(CANCELLABLE);
204 }
205 return false;
206 } else {
207 return true;
208 }
209 }
210
|
170 // the contended write might have been NULL.
171 oop result = ShenandoahBarrierSet::resolve_forwarded(witness);
172 shenandoah_assert_not_forwarded_except(p, result, (result == NULL));
173 shenandoah_assert_not_in_cset_except(p, result, (result == NULL) || cancelled_gc());
174 return result;
175 } else {
176 // Success! We have updated with known to-space copy. We have already asserted it is sane.
177 return forwarded_oop;
178 }
179 } else {
180 shenandoah_assert_not_forwarded(p, heap_oop);
181 return heap_oop;
182 }
183 }
184
185 inline bool ShenandoahHeap::cancelled_gc() const {
186 return _cancelled_gc.get() == CANCELLED;
187 }
188
189 inline bool ShenandoahHeap::check_cancelled_gc_and_yield(bool sts_active) {
190 if (!sts_active) {
191 return cancelled_gc();
192 }
193
194 jbyte prev = _cancelled_gc.cmpxchg(NOT_CANCELLED, CANCELLABLE);
195 if (prev == CANCELLABLE || prev == NOT_CANCELLED) {
196 if (SuspendibleThreadSet::should_yield()) {
197 SuspendibleThreadSet::yield();
198 }
199
200 // Back to CANCELLABLE. The thread that poked NOT_CANCELLED first gets
201 // to restore to CANCELLABLE.
202 if (prev == CANCELLABLE) {
203 _cancelled_gc.set(CANCELLABLE);
204 }
205 return false;
206 } else {
207 return true;
208 }
209 }
210
|