# HG changeset patch # User rkennke # Date 1478700740 -3600 # Wed Nov 09 15:12:20 2016 +0100 # Node ID ecb98dca731785990ecbb03b1bbec39f6b84e61e # Parent c8138d5377a44ccbab3ea757e16d8ca58d16c23a [mq]: cancel.patch diff --git a/src/share/vm/gc/shenandoah/shenandoahConcurrentMark.cpp b/src/share/vm/gc/shenandoah/shenandoahConcurrentMark.cpp --- a/src/share/vm/gc/shenandoah/shenandoahConcurrentMark.cpp +++ b/src/share/vm/gc/shenandoah/shenandoahConcurrentMark.cpp @@ -882,14 +882,19 @@ ParallelTaskTerminator* terminator) { ShenandoahHeap* heap = ShenandoahHeap::heap(); int seed = 17; - while (true) { - if (heap->cancelled_concgc()) clear_queue(q); - if (heap->cancelled_concgc() || - (!try_queue(q, cl) && - !try_draining_an_satb_buffer(q) && - !try_to_steal(worker_id, cl, &seed)) - ) { - if (terminator->offer_termination()) break; + bool terminate = false; + while (! terminate) { + if (heap->cancelled_concgc()) { + clear_queue(q); + break; + } + for (uint i = 0; i < 10000 && ! terminate; i++) { + if (!try_queue(q, cl) && + !try_draining_an_satb_buffer(q) && + !try_to_steal(worker_id, cl, &seed) + ) { + if (terminator->offer_termination()) terminate = true; + } } } } diff --git a/src/share/vm/gc/shenandoah/shenandoahHeap.cpp b/src/share/vm/gc/shenandoah/shenandoahHeap.cpp --- a/src/share/vm/gc/shenandoah/shenandoahHeap.cpp +++ b/src/share/vm/gc/shenandoah/shenandoahHeap.cpp @@ -2052,8 +2052,7 @@ // only report it once if (!_cancelled_concgc) { log_info(gc)("Cancelling GC"); - _cancelled_concgc = true; - OrderAccess::fence(); + OrderAccess::release_store(&_cancelled_concgc, true); _shenandoah_policy->report_concgc_cancelled(); } diff --git a/src/share/vm/gc/shenandoah/shenandoahHeap.hpp b/src/share/vm/gc/shenandoah/shenandoahHeap.hpp --- a/src/share/vm/gc/shenandoah/shenandoahHeap.hpp +++ b/src/share/vm/gc/shenandoah/shenandoahHeap.hpp @@ -124,7 +124,7 @@ HeapWord** _top_at_mark_starts; HeapWord** _top_at_mark_starts_base; - bool _cancelled_concgc; + volatile jbyte _cancelled_concgc; jbyte _growing_heap; diff --git a/src/share/vm/gc/shenandoah/shenandoahHeap.inline.hpp b/src/share/vm/gc/shenandoah/shenandoahHeap.inline.hpp --- a/src/share/vm/gc/shenandoah/shenandoahHeap.inline.hpp +++ b/src/share/vm/gc/shenandoah/shenandoahHeap.inline.hpp @@ -188,7 +188,7 @@ } inline bool ShenandoahHeap::cancelled_concgc() const { - bool cancelled = _cancelled_concgc; + bool cancelled = (bool) OrderAccess::load_acquire((jbyte*) &_cancelled_concgc); return cancelled; }