Skip to content
Permalink
Browse files

8235982: AArch64: Insufficient memory barriers in shadow region algor…

…ithm

The memory barriers used for synchronizing ParallelCompactData::RegionData::_shadow_state and ParallelCompactData::RegionData::shadow_region are insufficient to prevent reordering of loads.

Reviewed-by: tschatzl, sjohanss
  • Loading branch information
nick-arm committed Dec 18, 2019
1 parent 079db54 commit 995fbebd8143db5df33788660cf2173c854ef989
Showing with 5 additions and 5 deletions.
  1. +5 −5 src/hotspot/share/gc/parallel/psParallelCompact.hpp
@@ -630,25 +630,25 @@ inline bool ParallelCompactData::RegionData::claim()
}

inline bool ParallelCompactData::RegionData::mark_normal() {
return Atomic::cmpxchg(&_shadow_state, UnusedRegion, NormalRegion, memory_order_relaxed) == UnusedRegion;
return Atomic::cmpxchg(&_shadow_state, UnusedRegion, NormalRegion) == UnusedRegion;
}

inline bool ParallelCompactData::RegionData::mark_shadow() {
if (_shadow_state != UnusedRegion) return false;
return Atomic::cmpxchg(&_shadow_state, UnusedRegion, ShadowRegion, memory_order_relaxed) == UnusedRegion;
return Atomic::cmpxchg(&_shadow_state, UnusedRegion, ShadowRegion) == UnusedRegion;
}

inline void ParallelCompactData::RegionData::mark_filled() {
int old = Atomic::cmpxchg(&_shadow_state, ShadowRegion, FilledShadow, memory_order_relaxed);
int old = Atomic::cmpxchg(&_shadow_state, ShadowRegion, FilledShadow);
assert(old == ShadowRegion, "Fail to mark the region as filled");
}

inline bool ParallelCompactData::RegionData::mark_copied() {
return Atomic::cmpxchg(&_shadow_state, FilledShadow, CopiedShadow, memory_order_relaxed) == FilledShadow;
return Atomic::cmpxchg(&_shadow_state, FilledShadow, CopiedShadow) == FilledShadow;
}

void ParallelCompactData::RegionData::shadow_to_normal() {
int old = Atomic::cmpxchg(&_shadow_state, ShadowRegion, NormalRegion, memory_order_relaxed);
int old = Atomic::cmpxchg(&_shadow_state, ShadowRegion, NormalRegion);
assert(old == ShadowRegion, "Fail to mark the region as finish");
}

0 comments on commit 995fbeb

Please sign in to comment.
You can’t perform that action at this time.