changeset 9622:263be3296c38

Use StoreLoad barrier after setting _do_full_gc flag. Makes sure that other threads see it when they ought to.
author rkennke
date Wed, 16 Sep 2015 17:22:25 +0200
parents b00a25e45cd9
children 261ef52a9f2f
files src/share/vm/gc/shenandoah/shenandoahConcurrentThread.cpp src/share/vm/gc/shenandoah/shenandoahConcurrentThread.hpp
diffstat 2 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/shenandoah/shenandoahConcurrentThread.cpp	Wed Sep 16 17:21:59 2015 +0200
+++ b/src/share/vm/gc/shenandoah/shenandoahConcurrentThread.cpp	Wed Sep 16 17:22:25 2015 +0200
@@ -43,7 +43,7 @@
   ShenandoahHeap* heap = ShenandoahHeap::heap();
 
   while (!_should_terminate) {
-    if (OrderAccess::load_acquire(&_do_full_gc)) {
+    if (_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);
-      OrderAccess::release_store(&_do_full_gc, false);
+      _do_full_gc = false;
       ml.notify_all();
     } else if (heap->shenandoahPolicy()->should_start_concurrent_mark(heap->used(),
 							       heap->capacity())) 
@@ -111,6 +111,8 @@
       // yield();
     }
     heap->clear_cancelled_concgc();
+    // Make sure the _do_full_gc flag changes are seen.
+    OrderAccess::storeload();
   }
 }
 
@@ -121,14 +123,15 @@
   MonitorLockerEx ml(ShenandoahFullGC_lock);
   schedule_full_gc();
   _full_gc_cause = cause;
-  while (OrderAccess::load_acquire(&_do_full_gc)) {
+  while (_do_full_gc) {
     ml.wait();
+    OrderAccess::storeload();
   }
-  assert(OrderAccess::load_acquire(&_do_full_gc) == false, "expect full GC to have completed");
+  assert(_do_full_gc == false, "expect full GC to have completed");
 }
 
 void ShenandoahConcurrentThread::schedule_full_gc() {
-  OrderAccess::release_store(&_do_full_gc, true);
+  _do_full_gc = true;
 }
 
 void ShenandoahConcurrentThread::print() const {
--- a/src/share/vm/gc/shenandoah/shenandoahConcurrentThread.hpp	Wed Sep 16 17:21:59 2015 +0200
+++ b/src/share/vm/gc/shenandoah/shenandoahConcurrentThread.hpp	Wed Sep 16 17:22:25 2015 +0200
@@ -28,7 +28,7 @@
   static SurrogateLockerThread* _slt;
   static SuspendibleThreadSet _sts;
 
-  jbyte _do_full_gc;
+  bool _do_full_gc;
   GCCause::Cause _full_gc_cause;
 
   void sleepBeforeNextCycle();