1.1 --- a/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp Thu Dec 08 15:12:58 2016 +0300 1.2 +++ b/src/share/vm/gc_implementation/parNew/parCardTableModRefBS.cpp Fri Dec 02 11:07:27 2016 +0100 1.3 @@ -452,9 +452,13 @@ 1.4 // event lock and do the read again in case some other thread had already 1.5 // succeeded and done the resize. 1.6 int cur_collection = Universe::heap()->total_collections(); 1.7 - if (_last_LNC_resizing_collection[i] != cur_collection) { 1.8 + // Updated _last_LNC_resizing_collection[i] must not be visible before 1.9 + // _lowest_non_clean and friends are visible. Therefore use acquire/release 1.10 + // to guarantee this on non TSO architecures. 1.11 + if (OrderAccess::load_acquire(&_last_LNC_resizing_collection[i]) != cur_collection) { 1.12 MutexLocker x(ParGCRareEvent_lock); 1.13 - if (_last_LNC_resizing_collection[i] != cur_collection) { 1.14 + // This load_acquire is here for clarity only. The MutexLocker already fences. 1.15 + if (OrderAccess::load_acquire(&_last_LNC_resizing_collection[i]) != cur_collection) { 1.16 if (_lowest_non_clean[i] == NULL || 1.17 n_chunks != _lowest_non_clean_chunk_size[i]) { 1.18 1.19 @@ -474,7 +478,8 @@ 1.20 _lowest_non_clean[i][j] = NULL; 1.21 } 1.22 } 1.23 - _last_LNC_resizing_collection[i] = cur_collection; 1.24 + // Make sure this gets visible only after _lowest_non_clean* was initialized 1.25 + OrderAccess::release_store(&_last_LNC_resizing_collection[i], cur_collection); 1.26 } 1.27 } 1.28 // In any case, now do the initialization.