2423 // block if a safepoint is in progress. 2424 // Also check for pending async exception (not including unsafe access error). 2425 // Note only the native==>VM/Java barriers can call this function and when 2426 // thread state is _thread_in_native_trans. 2427 void JavaThread::check_special_condition_for_native_trans(JavaThread *thread) { 2428 check_safepoint_and_suspend_for_native_trans(thread); 2429 2430 if (thread->has_async_exception()) { 2431 // We are in _thread_in_native_trans state, don't handle unsafe 2432 // access error since that may block. 2433 thread->check_and_handle_async_exceptions(false); 2434 } 2435 } 2436 2437 // This is a variant of the normal 2438 // check_special_condition_for_native_trans with slightly different 2439 // semantics for use by critical native wrappers. It does all the 2440 // normal checks but also performs the transition back into 2441 // thread_in_Java state. This is required so that critical natives 2442 // can potentially block and perform a GC if they are the last thread 2443 // exiting the GC_locker. 2444 void JavaThread::check_special_condition_for_native_trans_and_transition(JavaThread *thread) { 2445 check_special_condition_for_native_trans(thread); 2446 2447 // Finish the transition 2448 thread->set_thread_state(_thread_in_Java); 2449 2450 if (thread->do_critical_native_unlock()) { 2451 ThreadInVMfromJavaNoAsyncException tiv(thread); 2452 GC_locker::unlock_critical(thread); 2453 thread->clear_critical_native_unlock(); 2454 } 2455 } 2456 2457 // We need to guarantee the Threads_lock here, since resumes are not 2458 // allowed during safepoint synchronization 2459 // Can only resume from an external suspension 2460 void JavaThread::java_resume() { 2461 assert_locked_or_safepoint(Threads_lock); 2462 2463 // Sanity check: thread is gone, has started exiting or the thread 2464 // was not externally suspended. 2465 if (!Threads::includes(this) || is_exiting() || !is_external_suspend()) { 2466 return; 2467 } 2468 2469 MutexLockerEx ml(SR_lock(), Mutex::_no_safepoint_check_flag); 2470 2471 clear_external_suspend(); 2472 | 2423 // block if a safepoint is in progress. 2424 // Also check for pending async exception (not including unsafe access error). 2425 // Note only the native==>VM/Java barriers can call this function and when 2426 // thread state is _thread_in_native_trans. 2427 void JavaThread::check_special_condition_for_native_trans(JavaThread *thread) { 2428 check_safepoint_and_suspend_for_native_trans(thread); 2429 2430 if (thread->has_async_exception()) { 2431 // We are in _thread_in_native_trans state, don't handle unsafe 2432 // access error since that may block. 2433 thread->check_and_handle_async_exceptions(false); 2434 } 2435 } 2436 2437 // This is a variant of the normal 2438 // check_special_condition_for_native_trans with slightly different 2439 // semantics for use by critical native wrappers. It does all the 2440 // normal checks but also performs the transition back into 2441 // thread_in_Java state. This is required so that critical natives 2442 // can potentially block and perform a GC if they are the last thread 2443 // exiting the GCLocker. 2444 void JavaThread::check_special_condition_for_native_trans_and_transition(JavaThread *thread) { 2445 check_special_condition_for_native_trans(thread); 2446 2447 // Finish the transition 2448 thread->set_thread_state(_thread_in_Java); 2449 2450 if (thread->do_critical_native_unlock()) { 2451 ThreadInVMfromJavaNoAsyncException tiv(thread); 2452 GCLocker::unlock_critical(thread); 2453 thread->clear_critical_native_unlock(); 2454 } 2455 } 2456 2457 // We need to guarantee the Threads_lock here, since resumes are not 2458 // allowed during safepoint synchronization 2459 // Can only resume from an external suspension 2460 void JavaThread::java_resume() { 2461 assert_locked_or_safepoint(Threads_lock); 2462 2463 // Sanity check: thread is gone, has started exiting or the thread 2464 // was not externally suspended. 2465 if (!Threads::includes(this) || is_exiting() || !is_external_suspend()) { 2466 return; 2467 } 2468 2469 MutexLockerEx ml(SR_lock(), Mutex::_no_safepoint_check_flag); 2470 2471 clear_external_suspend(); 2472 |