< prev index next >

src/hotspot/share/runtime/handshake.cpp

Print this page
rev 50896 : 8206003: SafepointSynchronize with TLH: StoreStore barriers should be moved out of the loop
Reviewed-by: eosterlund, rehn, dholmes


 280   }
 281 }
 282 
 283 bool Handshake::execute(ThreadClosure* thread_cl, JavaThread* target) {
 284   if (ThreadLocalHandshakes) {
 285     HandshakeThreadsOperation cto(thread_cl);
 286     VM_HandshakeOneThread handshake(&cto, target);
 287     VMThread::execute(&handshake);
 288     return handshake.thread_alive();
 289   } else {
 290     VM_HandshakeFallbackOperation op(thread_cl, target);
 291     VMThread::execute(&op);
 292     return op.thread_alive();
 293   }
 294 }
 295 
 296 HandshakeState::HandshakeState() : _operation(NULL), _semaphore(1), _thread_in_process_handshake(false) {}
 297 
 298 void HandshakeState::set_operation(JavaThread* target, HandshakeOperation* op) {
 299   _operation = op;
 300   SafepointMechanism::arm_local_poll(target);
 301 }
 302 
 303 void HandshakeState::clear_handshake(JavaThread* target) {
 304   _operation = NULL;
 305   SafepointMechanism::disarm_local_poll(target);
 306 }
 307 
 308 void HandshakeState::process_self_inner(JavaThread* thread) {
 309   assert(Thread::current() == thread, "should call from thread");
 310 
 311   if (thread->is_terminated()) {
 312     // If thread is not on threads list but armed, cancel.
 313     thread->cancel_handshake();
 314     return;
 315   }
 316 
 317   CautiouslyPreserveExceptionMark pem(thread);
 318   ThreadInVMForHandshake tivm(thread);
 319   if (!_semaphore.trywait()) {
 320     _semaphore.wait_with_safepoint_check(thread);
 321   }
 322   HandshakeOperation* op = OrderAccess::load_acquire(&_operation);
 323   if (op != NULL) {
 324     // Disarm before execute the operation
 325     clear_handshake(thread);




 280   }
 281 }
 282 
 283 bool Handshake::execute(ThreadClosure* thread_cl, JavaThread* target) {
 284   if (ThreadLocalHandshakes) {
 285     HandshakeThreadsOperation cto(thread_cl);
 286     VM_HandshakeOneThread handshake(&cto, target);
 287     VMThread::execute(&handshake);
 288     return handshake.thread_alive();
 289   } else {
 290     VM_HandshakeFallbackOperation op(thread_cl, target);
 291     VMThread::execute(&op);
 292     return op.thread_alive();
 293   }
 294 }
 295 
 296 HandshakeState::HandshakeState() : _operation(NULL), _semaphore(1), _thread_in_process_handshake(false) {}
 297 
 298 void HandshakeState::set_operation(JavaThread* target, HandshakeOperation* op) {
 299   _operation = op;
 300   SafepointMechanism::arm_local_poll_release(target);
 301 }
 302 
 303 void HandshakeState::clear_handshake(JavaThread* target) {
 304   _operation = NULL;
 305   SafepointMechanism::disarm_local_poll_release(target);
 306 }
 307 
 308 void HandshakeState::process_self_inner(JavaThread* thread) {
 309   assert(Thread::current() == thread, "should call from thread");
 310 
 311   if (thread->is_terminated()) {
 312     // If thread is not on threads list but armed, cancel.
 313     thread->cancel_handshake();
 314     return;
 315   }
 316 
 317   CautiouslyPreserveExceptionMark pem(thread);
 318   ThreadInVMForHandshake tivm(thread);
 319   if (!_semaphore.trywait()) {
 320     _semaphore.wait_with_safepoint_check(thread);
 321   }
 322   HandshakeOperation* op = OrderAccess::load_acquire(&_operation);
 323   if (op != NULL) {
 324     // Disarm before execute the operation
 325     clear_handshake(thread);


< prev index next >