128 return 0; 129 } 130 } 131 132 void ConcurrentG1Refine::wait_for_ConcurrentG1Refine_enabled() { 133 G1ConcRefine_mon->lock(); 134 while (!_enabled) { 135 G1ConcRefine_mon->wait(Mutex::_no_safepoint_check_flag); 136 } 137 G1ConcRefine_mon->unlock(); 138 _traversals = 0; 139 }; 140 141 void ConcurrentG1Refine::set_pya_restart() { 142 // If we're using the log-based RS barrier, the above will cause 143 // in-progress traversals of completed log buffers to quit early; we will 144 // also abandon all other buffers. 145 if (G1RSBarrierUseQueue) { 146 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); 147 dcqs.abandon_logs(); 148 if (_cg1rThread->do_traversal()) { 149 _pya = PYA_restart; 150 } else { 151 _cg1rThread->set_do_traversal(true); 152 // Reset the post-yield actions. 153 _pya = PYA_continue; 154 _last_pya = PYA_continue; 155 } 156 } else { 157 _pya = PYA_restart; 158 } 159 } 160 161 void ConcurrentG1Refine::set_pya_cancel() { 162 _pya = PYA_cancel; 163 } 164 165 PostYieldAction ConcurrentG1Refine::get_pya() { 166 if (_pya != PYA_continue) { 167 jint val = _pya; 168 while (true) { 169 jint val_read = Atomic::cmpxchg(PYA_continue, &_pya, val); 170 if (val_read == val) { 171 PostYieldAction res = (PostYieldAction)val; 172 assert(res != PYA_continue, "Only the refine thread should reset."); 173 _last_pya = res; 174 return res; 175 } else { | 128 return 0; 129 } 130 } 131 132 void ConcurrentG1Refine::wait_for_ConcurrentG1Refine_enabled() { 133 G1ConcRefine_mon->lock(); 134 while (!_enabled) { 135 G1ConcRefine_mon->wait(Mutex::_no_safepoint_check_flag); 136 } 137 G1ConcRefine_mon->unlock(); 138 _traversals = 0; 139 }; 140 141 void ConcurrentG1Refine::set_pya_restart() { 142 // If we're using the log-based RS barrier, the above will cause 143 // in-progress traversals of completed log buffers to quit early; we will 144 // also abandon all other buffers. 145 if (G1RSBarrierUseQueue) { 146 DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); 147 dcqs.abandon_logs(); 148 // Reset the post-yield actions. 149 _pya = PYA_continue; 150 _last_pya = PYA_continue; 151 } else { 152 _pya = PYA_restart; 153 } 154 } 155 156 void ConcurrentG1Refine::set_pya_cancel() { 157 _pya = PYA_cancel; 158 } 159 160 PostYieldAction ConcurrentG1Refine::get_pya() { 161 if (_pya != PYA_continue) { 162 jint val = _pya; 163 while (true) { 164 jint val_read = Atomic::cmpxchg(PYA_continue, &_pya, val); 165 if (val_read == val) { 166 PostYieldAction res = (PostYieldAction)val; 167 assert(res != PYA_continue, "Only the refine thread should reset."); 168 _last_pya = res; 169 return res; 170 } else { |