< prev index next >

src/hotspot/share/gc/z/zMarkTerminate.inline.hpp

Print this page




  32     _nworking_stage0(0),
  33     _nworking_stage1(0) {}
  34 
  35 inline bool ZMarkTerminate::enter_stage(volatile uint* nworking_stage) {
  36   return Atomic::sub(nworking_stage, 1u) == 0;
  37 }
  38 
  39 inline void ZMarkTerminate::exit_stage(volatile uint* nworking_stage) {
  40   Atomic::add(nworking_stage, 1u);
  41 }
  42 
  43 inline bool ZMarkTerminate::try_exit_stage(volatile uint* nworking_stage) {
  44   uint nworking = Atomic::load(nworking_stage);
  45 
  46   for (;;) {
  47     if (nworking == 0) {
  48       return false;
  49     }
  50 
  51     const uint new_nworking = nworking + 1;
  52     const uint prev_nworking = Atomic::cmpxchg(new_nworking, nworking_stage, nworking);
  53     if (prev_nworking == nworking) {
  54       // Success
  55       return true;
  56     }
  57 
  58     // Retry
  59     nworking = prev_nworking;
  60   }
  61 }
  62 
  63 inline void ZMarkTerminate::reset(uint nworkers) {
  64   _nworkers = _nworking_stage0 = _nworking_stage1 = nworkers;
  65 }
  66 
  67 inline bool ZMarkTerminate::enter_stage0() {
  68   return enter_stage(&_nworking_stage0);
  69 }
  70 
  71 inline void ZMarkTerminate::exit_stage0() {
  72   exit_stage(&_nworking_stage0);


  32     _nworking_stage0(0),
  33     _nworking_stage1(0) {}
  34 
  35 inline bool ZMarkTerminate::enter_stage(volatile uint* nworking_stage) {
  36   return Atomic::sub(nworking_stage, 1u) == 0;
  37 }
  38 
  39 inline void ZMarkTerminate::exit_stage(volatile uint* nworking_stage) {
  40   Atomic::add(nworking_stage, 1u);
  41 }
  42 
  43 inline bool ZMarkTerminate::try_exit_stage(volatile uint* nworking_stage) {
  44   uint nworking = Atomic::load(nworking_stage);
  45 
  46   for (;;) {
  47     if (nworking == 0) {
  48       return false;
  49     }
  50 
  51     const uint new_nworking = nworking + 1;
  52     const uint prev_nworking = Atomic::cmpxchg(nworking_stage, nworking, new_nworking);
  53     if (prev_nworking == nworking) {
  54       // Success
  55       return true;
  56     }
  57 
  58     // Retry
  59     nworking = prev_nworking;
  60   }
  61 }
  62 
  63 inline void ZMarkTerminate::reset(uint nworkers) {
  64   _nworkers = _nworking_stage0 = _nworking_stage1 = nworkers;
  65 }
  66 
  67 inline bool ZMarkTerminate::enter_stage0() {
  68   return enter_stage(&_nworking_stage0);
  69 }
  70 
  71 inline void ZMarkTerminate::exit_stage0() {
  72   exit_stage(&_nworking_stage0);
< prev index next >