8229169: False failure of GenericTaskQueue::pop_local on architectures with weak memory model
authorjiefu
Wed, 07 Aug 2019 17:00:19 +0800
changeset 57672 167cb7b4cd81
parent 57670 cffcc4c5a5ba
child 57674 4e3a26572bb6
8229169: False failure of GenericTaskQueue::pop_local on architectures with weak memory model Reviewed-by: mdoerr, kbarrett, tschatzl
src/hotspot/share/gc/shared/taskqueue.inline.hpp
--- a/src/hotspot/share/gc/shared/taskqueue.inline.hpp	Wed Aug 07 14:04:10 2019 -0400
+++ b/src/hotspot/share/gc/shared/taskqueue.inline.hpp	Wed Aug 07 17:00:19 2019 +0800
@@ -184,6 +184,11 @@
   } else {
     // Otherwise, the queue contained exactly one element; we take the slow
     // path.
+
+    // The barrier is required to prevent reordering the two reads of _age:
+    // one is the _age.get() below, and the other is _age.top() above the if-stmt.
+    // The algorithm may fail if _age.get() reads an older value than _age.top().
+    OrderAccess::loadload();
     return pop_local_slow(localBot, _age.get());
   }
 }