# HG changeset patch # User Roman Kennke # Date 1418133424 -3600 # Node ID e9e008ff4e73a753feccba225c2dc70975f34ee2 # Parent 9e06c024409cb0f33bf8a4143fee9820b8ae17c6 Cleanup properly if full-GC is requested while waiting for JNI critical regions to finish. diff -r 9e06c024409c -r e9e008ff4e73 src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentThread.cpp --- a/src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentThread.cpp Mon Dec 08 23:15:17 2014 +0100 +++ b/src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentThread.cpp Tue Dec 09 14:57:04 2014 +0100 @@ -35,8 +35,25 @@ ShenandoahHeap* heap = ShenandoahHeap::heap(); if (_do_full_gc) { - VM_ShenandoahFullGC full_gc; - VMThread::execute(&full_gc); + if (heap->concurrent_mark_in_progress()) { + // If we get here, we've been sent into jni-critical-wait at the end of marking, + // and in the meantime got a full-gc scheduled. Clean up the marking stuff, and + // do full-gc. + heap->reset_mark_bitmap(); + heap->stop_concurrent_marking(); + + cm_abort(); + + VM_ShenandoahFullGC full_gc; + VMThread::execute(&full_gc); + + MonitorLockerEx ml(ShenandoahFullGC_lock); + _do_full_gc = false; + ml.notify_all(); + } else { + VM_ShenandoahFullGC full_gc; + VMThread::execute(&full_gc); + } } else { VM_ShenandoahStartEvacuation start_evacuation; VMThread::execute(&start_evacuation); @@ -102,6 +119,12 @@ } } + if (cm_has_aborted()) { + clear_cm_aborted(); + assert(heap->is_bitmap_clear(), "need to continue with clear mark bitmap"); + assert(! heap->concurrent_mark_in_progress(), "concurrent mark must have terminated"); + continue; + } if (! _should_terminate) { // If we're not concurrently evacuating, evacuation is done // from VM_ShenandoahFinishMark within the VMThread above.