src/hotspot/share/runtime/vmOperations.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File open Sdiff src/hotspot/share/runtime

src/hotspot/share/runtime/vmOperations.cpp

Print this page




 420   // better to terminate VM when current thread is the only active thread, so
 421   // wait for user threads too. Numbers are in 10 milliseconds.
 422   int max_wait_user_thread = 30;                  // at least 300 milliseconds
 423   int max_wait_compiler_thread = 1000;            // at least 10 seconds
 424 
 425   int max_wait = max_wait_compiler_thread;
 426 
 427   int attempts = 0;
 428   JavaThreadIteratorWithHandle jtiwh;
 429   while (true) {
 430     int num_active = 0;
 431     int num_active_compiler_thread = 0;
 432 
 433     jtiwh.rewind();
 434     for (; JavaThread *thr = jtiwh.next(); ) {
 435       if (thr!=thr_cur && thr->thread_state() == _thread_in_native) {
 436         num_active++;
 437         if (thr->is_Compiler_thread()) {
 438 #if INCLUDE_JVMCI
 439           CompilerThread* ct = (CompilerThread*) thr;
 440           if (ct->compiler() == NULL || !ct->compiler()->is_jvmci() || !UseJVMCINativeLibrary) {
 441             num_active_compiler_thread++;
 442           } else {
 443             // When using a compiler in a JVMCI shared library, it's possible
 444             // for one compiler thread to grab a lock in the shared library,
 445             // enter HotSpot and go to sleep on the shutdown safepoint. Another
 446             // JVMCI shared library compiler thread can then attempt to grab the
 447             // lock and thus never make progress.
 448           }
 449 #else
 450           num_active_compiler_thread++;
 451 #endif
 452         }
 453       }
 454     }
 455 
 456     if (num_active == 0) {
 457        return 0;
 458     } else if (attempts > max_wait) {
 459        return num_active;
 460     } else if (num_active_compiler_thread == 0 && attempts > max_wait_user_thread) {
 461        return num_active;
 462     }
 463 
 464     attempts++;
 465 
 466     MonitorLocker ml(&timer, Mutex::_no_safepoint_check_flag);
 467     ml.wait(10);




 420   // better to terminate VM when current thread is the only active thread, so
 421   // wait for user threads too. Numbers are in 10 milliseconds.
 422   int max_wait_user_thread = 30;                  // at least 300 milliseconds
 423   int max_wait_compiler_thread = 1000;            // at least 10 seconds
 424 
 425   int max_wait = max_wait_compiler_thread;
 426 
 427   int attempts = 0;
 428   JavaThreadIteratorWithHandle jtiwh;
 429   while (true) {
 430     int num_active = 0;
 431     int num_active_compiler_thread = 0;
 432 
 433     jtiwh.rewind();
 434     for (; JavaThread *thr = jtiwh.next(); ) {
 435       if (thr!=thr_cur && thr->thread_state() == _thread_in_native) {
 436         num_active++;
 437         if (thr->is_Compiler_thread()) {
 438 #if INCLUDE_JVMCI
 439           CompilerThread* ct = (CompilerThread*) thr;
 440           if (ct->compiler() == NULL || !ct->compiler()->is_jvmci()) {
 441             num_active_compiler_thread++;
 442           } else {
 443             // A JVMCI compiler thread never accesses VM data structures
 444             // while in _thread_in_native state so there's no need to wait
 445             // for it and potentially add a 300 millisecond delay to VM
 446             // shutdown.
 447             num_active--;
 448           }
 449 #else
 450           num_active_compiler_thread++;
 451 #endif
 452         }
 453       }
 454     }
 455 
 456     if (num_active == 0) {
 457        return 0;
 458     } else if (attempts > max_wait) {
 459        return num_active;
 460     } else if (num_active_compiler_thread == 0 && attempts > max_wait_user_thread) {
 461        return num_active;
 462     }
 463 
 464     attempts++;
 465 
 466     MonitorLocker ml(&timer, Mutex::_no_safepoint_check_flag);
 467     ml.wait(10);


src/hotspot/share/runtime/vmOperations.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File