changeset 12564:cd2c49a02a4c

8164948: Initializing stores of HeapRegions are not ordered with regards to their use in G1ConcurrentMark Summary: Add a storestore barrier before publishing newly initialized HeapRegion instances, and place a loadload barrier before use of members. Reviewed-by: sjohanss, sangheki
author tschatzl
date Tue, 13 Sep 2016 11:32:45 +0200
parents 0cf03b9d9b1f
children dd344d3c057b 4e4dcd18c567 893d1d2ccb50
files src/share/vm/gc/g1/g1ConcurrentMark.cpp src/share/vm/gc/g1/heapRegionManager.cpp
diffstat 2 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/g1/g1ConcurrentMark.cpp	Mon Sep 12 18:59:13 2016 +0000
+++ b/src/share/vm/gc/g1/g1ConcurrentMark.cpp	Tue Sep 13 11:32:45 2016 +0200
@@ -1904,7 +1904,8 @@
     assert(_g1h->is_in_g1_reserved(finger), "invariant");
 
     HeapRegion* curr_region = _g1h->heap_region_containing(finger);
-
+    // Make sure that the reads below do not float before loading curr_region.
+    OrderAccess::loadload();
     // Above heap_region_containing may return NULL as we always scan claim
     // until the end of the heap. In this case, just jump to the next region.
     HeapWord* end = curr_region != NULL ? curr_region->end() : finger + HeapRegion::GrainWords;
--- a/src/share/vm/gc/g1/heapRegionManager.cpp	Mon Sep 12 18:59:13 2016 +0000
+++ b/src/share/vm/gc/g1/heapRegionManager.cpp	Tue Sep 13 11:32:45 2016 +0200
@@ -123,6 +123,7 @@
   for (uint i = start; i < start + num_regions; i++) {
     if (_regions.get_by_index(i) == NULL) {
       HeapRegion* new_hr = new_heap_region(i);
+      OrderAccess::storestore();
       _regions.set_by_index(i, new_hr);
       _allocated_heapregions_length = MAX2(_allocated_heapregions_length, i + 1);
     }