8025728: Missing volatile specifier for field G1AllocRegion::_alloc_region
authortschatzl
Wed, 23 Oct 2013 10:23:06 +0200
changeset 21119 ca1c9dd0e277
parent 21118 dcb003e61977
child 21120 96752cc31d9a
8025728: Missing volatile specifier for field G1AllocRegion::_alloc_region Summary: The field G1AllocRegion::_alloc_region needs to be declared volatile as it is used with that intention. Otherwise the compiler may generate the code that reloads the value which might have changed in the meantime, leading to spurious crashes. Reviewed-by: iveresov, simonis, tschatzl Contributed-by: Axel Siebenborn <axel.siebenborn@sap.com>
hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp	Tue Oct 22 12:03:50 2013 -0700
+++ b/hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.hpp	Wed Oct 23 10:23:06 2013 +0200
@@ -55,7 +55,7 @@
   // then _alloc_region is NULL and this object should not be used to
   // satisfy allocation requests (it was done this way to force the
   // correct use of init() and release()).
-  HeapRegion* _alloc_region;
+  HeapRegion* volatile _alloc_region;
 
   // It keeps track of the distinct number of regions that are used
   // for allocation in the active interval of this object, i.e.,
@@ -132,8 +132,9 @@
   static void setup(G1CollectedHeap* g1h, HeapRegion* dummy_region);
 
   HeapRegion* get() const {
+    HeapRegion * hr = _alloc_region;
     // Make sure that the dummy region does not escape this class.
-    return (_alloc_region == _dummy_region) ? NULL : _alloc_region;
+    return (hr == _dummy_region) ? NULL : hr;
   }
 
   uint count() { return _count; }