changeset 7437:e9e008ff4e73

Cleanup properly if full-GC is requested while waiting for JNI critical regions to finish.
author Roman Kennke <rkennke@redhat.com>
date Tue, 09 Dec 2014 14:57:04 +0100
parents 9e06c024409c
children f93578332d69
files src/share/vm/gc_implementation/shenandoah/shenandoahConcurrentThread.cpp
diffstat 1 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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.