changeset 9612:06740c15a2b5

Use release-store and load-acquire to read/write _do_full_gc field, to ensure consistency between GC and Java threads.
author rkennke
date Tue, 08 Sep 2015 20:59:48 +0200
parents abd7e1819ef1
children 9c265a9a7251
files src/share/vm/gc/shenandoah/shenandoahConcurrentThread.cpp src/share/vm/gc/shenandoah/shenandoahConcurrentThread.hpp
diffstat 2 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/shenandoah/shenandoahConcurrentThread.cpp	Tue Sep 08 12:15:42 2015 +0200
+++ b/src/share/vm/gc/shenandoah/shenandoahConcurrentThread.cpp	Tue Sep 08 20:59:48 2015 +0200
@@ -43,7 +43,7 @@
   ShenandoahHeap* heap = ShenandoahHeap::heap();
 
   while (!_should_terminate) {
-    if (_do_full_gc) {
+    if (OrderAccess::load_acquire(&_do_full_gc)) {
       {
         if (_full_gc_cause == GCCause::_allocation_failure) {
           heap->shenandoahPolicy()->record_allocation_failure_gc();
@@ -55,7 +55,7 @@
 	heap->jni_critical()->execute_in_vm_thread(&full_gc);
       }
       MonitorLockerEx ml(ShenandoahFullGC_lock);
-      _do_full_gc = false;
+      OrderAccess::release_store(&_do_full_gc, false);
       ml.notify_all();
     } else if (heap->shenandoahPolicy()->should_start_concurrent_mark(heap->used(),
 							       heap->capacity())) 
@@ -121,15 +121,14 @@
   MonitorLockerEx ml(ShenandoahFullGC_lock);
   schedule_full_gc();
   _full_gc_cause = cause;
-  while (_do_full_gc) {
+  while (OrderAccess::load_acquire(&_do_full_gc)) {
     ml.wait();
   }
-  assert(_do_full_gc == false, "expect full GC to have completed");
+  assert(OrderAccess::load_acquire(&_do_full_gc) == false, "expect full GC to have completed");
 }
 
 void ShenandoahConcurrentThread::schedule_full_gc() {
-  _do_full_gc = true;
-  OrderAccess::fence();
+  OrderAccess::release_store(&_do_full_gc, true);
 }
 
 void ShenandoahConcurrentThread::print() const {
--- a/src/share/vm/gc/shenandoah/shenandoahConcurrentThread.hpp	Tue Sep 08 12:15:42 2015 +0200
+++ b/src/share/vm/gc/shenandoah/shenandoahConcurrentThread.hpp	Tue Sep 08 20:59:48 2015 +0200
@@ -28,7 +28,7 @@
   static SurrogateLockerThread* _slt;
   static SuspendibleThreadSet _sts;
 
-  bool _do_full_gc;
+  jbyte _do_full_gc;
   GCCause::Cause _full_gc_cause;
 
   void sleepBeforeNextCycle();