8165858: heapRegionManager is missing volatile specifier for _claims.
authoreosterlund
Sat, 24 Sep 2016 16:02:29 -0400
changeset 41311 92d8edabd52c
parent 41310 28c707fe71ce
child 41312 90c5e4348212
8165858: heapRegionManager is missing volatile specifier for _claims. Summary: Added volatile specifier. Reviewed-by: kbarrett, tschatzl
hotspot/src/share/vm/gc/g1/heapRegionManager.cpp
hotspot/src/share/vm/gc/g1/heapRegionManager.hpp
--- a/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp	Fri Sep 23 18:23:12 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp	Sat Sep 24 16:02:29 2016 -0400
@@ -482,8 +482,9 @@
 HeapRegionClaimer::HeapRegionClaimer(uint n_workers) :
     _n_workers(n_workers), _n_regions(G1CollectedHeap::heap()->_hrm._allocated_heapregions_length), _claims(NULL) {
   assert(n_workers > 0, "Need at least one worker.");
-  _claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
-  memset(_claims, Unclaimed, sizeof(*_claims) * _n_regions);
+  uint* new_claims = NEW_C_HEAP_ARRAY(uint, _n_regions, mtGC);
+  memset(new_claims, Unclaimed, sizeof(*_claims) * _n_regions);
+  _claims = new_claims;
 }
 
 HeapRegionClaimer::~HeapRegionClaimer() {
--- a/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp	Fri Sep 23 18:23:12 2016 -0400
+++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp	Sat Sep 24 16:02:29 2016 -0400
@@ -259,9 +259,9 @@
 // The HeapRegionClaimer is used during parallel iteration over heap regions,
 // allowing workers to claim heap regions, gaining exclusive rights to these regions.
 class HeapRegionClaimer : public StackObj {
-  uint  _n_workers;
-  uint  _n_regions;
-  uint* _claims;
+  uint           _n_workers;
+  uint           _n_regions;
+  volatile uint* _claims;
 
   static const uint Unclaimed = 0;
   static const uint Claimed   = 1;
@@ -285,4 +285,3 @@
   bool claim_region(uint region_index);
 };
 #endif // SHARE_VM_GC_G1_HEAPREGIONMANAGER_HPP
-