8227101: Shenandoah: Use ShenandoahSharedFlag for claimed flag in ShenandoahSerialRoot
authorzgu
Tue, 02 Jul 2019 10:21:23 -0400
changeset 55547 c7a7728eeddc
parent 55546 3ae57bbf9585
child 55548 1ba68bf27e27
8227101: Shenandoah: Use ShenandoahSharedFlag for claimed flag in ShenandoahSerialRoot Reviewed-by: shade
src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp
src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp	Tue Jul 02 13:25:51 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp	Tue Jul 02 10:21:23 2019 -0400
@@ -41,11 +41,11 @@
 #include "services/management.hpp"
 
 ShenandoahSerialRoot::ShenandoahSerialRoot(ShenandoahSerialRoot::OopsDo oops_do, ShenandoahPhaseTimings::GCParPhases phase) :
-  _claimed(false), _oops_do(oops_do), _phase(phase) {
+  _oops_do(oops_do), _phase(phase) {
 }
 
 void ShenandoahSerialRoot::oops_do(OopClosure* cl, uint worker_id) {
-  if (!_claimed && Atomic::cmpxchg(true, &_claimed, false) == false) {
+  if (_claimed.try_set()) {
     ShenandoahWorkerTimings* worker_times = ShenandoahHeap::heap()->phase_timings()->worker_times();
     ShenandoahWorkerTimingsTracker timer(worker_times, _phase, worker_id);
     _oops_do(cl);
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp	Tue Jul 02 13:25:51 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp	Tue Jul 02 10:21:23 2019 -0400
@@ -36,7 +36,7 @@
 public:
   typedef void (*OopsDo)(OopClosure*);
 private:
-  volatile bool                             _claimed;
+  ShenandoahSharedFlag                      _claimed;
   const OopsDo                              _oops_do;
   const ShenandoahPhaseTimings::GCParPhases _phase;