# HG changeset patch # User rkennke # Date 1490030616 -3600 # Mon Mar 20 18:23:36 2017 +0100 # Node ID e2520db375025569d3b256ea046e0c17c57f5e3a # Parent 821c63f347b7f35b03526b3975e4ad8c251fb184 Offer termination before leaving on cancelled GC. diff --git a/src/share/vm/gc/shenandoah/shenandoahPartialGC.cpp b/src/share/vm/gc/shenandoah/shenandoahPartialGC.cpp --- a/src/share/vm/gc/shenandoah/shenandoahPartialGC.cpp +++ b/src/share/vm/gc/shenandoah/shenandoahPartialGC.cpp @@ -96,7 +96,7 @@ MarkingCodeBlobClosure code_cl(&roots_cl, CodeBlobToOopClosure::FixRelocations); _rp->process_all_roots(&roots_cl, &roots_cl, &cld_cl, &code_cl, worker_id); } - if (_heap->cancelled_concgc()) return; + if (check_and_handle_cancelled_gc()) return; PartialEvacuateUpdateHeapClosure cl(q); @@ -111,11 +111,11 @@ assert(r->is_root(), "must be root region"); r->oop_iterate(&cl); r->set_root(false); - if (_heap->cancelled_concgc()) return; + if (check_and_handle_cancelled_gc()) return; r = _root_regions->claim_next(); } } - if (_heap->cancelled_concgc()) return; + if (check_and_handle_cancelled_gc()) return; // Step 3: Drain all outstanding work in queues. { @@ -125,7 +125,7 @@ uint stride = ShenandoahMarkLoopStride; while (true) { - if (_heap->cancelled_concgc()) return; + if (check_and_handle_cancelled_gc()) return; for (uint i = 0; i < stride; i++) { if ((q->pop_buffer(task) || @@ -143,6 +143,15 @@ } } +private: + bool check_and_handle_cancelled_gc() { + if (_heap->cancelled_concgc()) { + ShenandoahCancelledTerminatorTerminator tt; + while (! _terminator->offer_termination(&tt)); + return true; + } + return false; + } }; ShenandoahPartialGC::ShenandoahPartialGC(ShenandoahHeap* heap, uint max_regions) :