Skip to content

Commit

Permalink
8254672: ZGC: ZParallelOopsDo/ZSerialWeakOopsDo should use atomic loa…
Browse files Browse the repository at this point in the history
…d/store

Reviewed-by: stefank
  • Loading branch information
pliden committed Oct 13, 2020
1 parent 65393a0 commit 02d9c29
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/hotspot/share/gc/z/zRootsIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ ZParallelOopsDo<T, F>::ZParallelOopsDo(T* iter) :

template <typename T, void (T::*F)(ZRootsIteratorClosure*)>
void ZParallelOopsDo<T, F>::oops_do(ZRootsIteratorClosure* cl) {
if (!_completed) {
if (!Atomic::load(&_completed)) {
(_iter->*F)(cl);
if (!_completed) {
_completed = true;
if (!Atomic::load(&_completed)) {
Atomic::store(&_completed, true);
}
}
}
Expand All @@ -83,7 +83,7 @@ ZSerialWeakOopsDo<T, F>::ZSerialWeakOopsDo(T* iter) :

template <typename T, void (T::*F)(BoolObjectClosure*, ZRootsIteratorClosure*)>
void ZSerialWeakOopsDo<T, F>::weak_oops_do(BoolObjectClosure* is_alive, ZRootsIteratorClosure* cl) {
if (!_claimed && Atomic::cmpxchg(&_claimed, false, true) == false) {
if (!Atomic::load(&_claimed) && Atomic::cmpxchg(&_claimed, false, true) == false) {
(_iter->*F)(is_alive, cl);
}
}
Expand Down

1 comment on commit 02d9c29

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 02d9c29 Oct 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.