Skip to content

Commit

Permalink
[GC] Backport 8164948: Initializing stores of HeapRegions are not ord…
Browse files Browse the repository at this point in the history
…ered 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. (http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/cd2c49a02a4c)

Test Plan: hotspot/test/gc/g1

Reviewed-by: linade, mmyxym

Issue: dragonwell-project/dragonwell8#155
  • Loading branch information
Hao Tang authored and tanghaoth90 committed Dec 15, 2020
1 parent d8f1834 commit a967f19
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/share/vm/gc_implementation/g1/concurrentMark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3006,6 +3006,9 @@ ConcurrentMark::claim_region(uint worker_id) {
// iterations) but it should not introduce and correctness issues.
HeapRegion* curr_region = _g1h->heap_region_containing_raw(finger);

// Make sure that the reads below do not float before loading curr_region.
OrderAccess::loadload();

// Above heap_region_containing_raw 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;
Expand Down
1 change: 1 addition & 0 deletions src/share/vm/gc_implementation/g1/heapRegionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ void HeapRegionManager::make_regions_available(uint start, uint num_regions) {
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);
}
Expand Down

0 comments on commit a967f19

Please sign in to comment.