src/share/vm/runtime/java.cpp

Print this page
rev 2110 : [mq]: is-debugger-present


 526   if (thread == NULL) {
 527     // we have serious problems -- just exit
 528     vm_direct_exit(code);
 529   }
 530 
 531   if (VMThread::vm_thread() != NULL) {
 532     // Fire off a VM_Exit operation to bring VM to a safepoint and exit
 533     VM_Exit op(code);
 534     if (thread->is_Java_thread())
 535       ((JavaThread*)thread)->set_thread_state(_thread_in_vm);
 536     VMThread::execute(&op);
 537     // should never reach here; but in case something wrong with VM Thread.
 538     vm_direct_exit(code);
 539   } else {
 540     // VM thread is gone, just exit
 541     vm_direct_exit(code);
 542   }
 543   ShouldNotReachHere();
 544 }
 545 










 546 void notify_vm_shutdown() {
 547   // For now, just a dtrace probe.
 548   HS_DTRACE_PROBE(hotspot, vm__shutdown);
 549   HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();

 550 }
 551 
 552 void vm_direct_exit(int code) {
 553   notify_vm_shutdown();
 554   ::exit(code);
 555 }
 556 
 557 void vm_perform_shutdown_actions() {
 558   // Warning: do not call 'exit_globals()' here. All threads are still running.
 559   // Calling 'exit_globals()' will disable thread-local-storage and cause all
 560   // kinds of assertions to trigger in debug mode.
 561   if (is_init_completed()) {
 562     Thread* thread = ThreadLocalStorage::is_initialized() ?
 563                      ThreadLocalStorage::get_thread_slow() : NULL;
 564     if (thread != NULL && thread->is_Java_thread()) {
 565       // We are leaving the VM, set state to native (in case any OS exit
 566       // handlers call back to the VM)
 567       JavaThread* jt = (JavaThread*)thread;
 568       // Must always be walkable or have no last_Java_frame when in
 569       // thread_in_native




 526   if (thread == NULL) {
 527     // we have serious problems -- just exit
 528     vm_direct_exit(code);
 529   }
 530 
 531   if (VMThread::vm_thread() != NULL) {
 532     // Fire off a VM_Exit operation to bring VM to a safepoint and exit
 533     VM_Exit op(code);
 534     if (thread->is_Java_thread())
 535       ((JavaThread*)thread)->set_thread_state(_thread_in_vm);
 536     VMThread::execute(&op);
 537     // should never reach here; but in case something wrong with VM Thread.
 538     vm_direct_exit(code);
 539   } else {
 540     // VM thread is gone, just exit
 541     vm_direct_exit(code);
 542   }
 543   ShouldNotReachHere();
 544 }
 545 
 546 void wait_for_key_press(void) {
 547 #ifdef TARGET_OS_FAMILY_windows
 548   // if running in a debugger on windows, we want to pause before the console is closed
 549   if (Arguments::created_by_gamma_launcher() && PauseAtExit && os::is_debugger_attached()) {
 550     fprintf(stderr, "Press any key to continue...\n");
 551     fgetc(stdin);
 552   }
 553 #endif
 554 }
 555 
 556 void notify_vm_shutdown() {
 557   // For now, just a dtrace probe.
 558   HS_DTRACE_PROBE(hotspot, vm__shutdown);
 559   HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
 560   wait_for_key_press();
 561 }
 562 
 563 void vm_direct_exit(int code) {
 564   notify_vm_shutdown();
 565   ::exit(code);
 566 }
 567 
 568 void vm_perform_shutdown_actions() {
 569   // Warning: do not call 'exit_globals()' here. All threads are still running.
 570   // Calling 'exit_globals()' will disable thread-local-storage and cause all
 571   // kinds of assertions to trigger in debug mode.
 572   if (is_init_completed()) {
 573     Thread* thread = ThreadLocalStorage::is_initialized() ?
 574                      ThreadLocalStorage::get_thread_slow() : NULL;
 575     if (thread != NULL && thread->is_Java_thread()) {
 576       // We are leaving the VM, set state to native (in case any OS exit
 577       // handlers call back to the VM)
 578       JavaThread* jt = (JavaThread*)thread;
 579       // Must always be walkable or have no last_Java_frame when in
 580       // thread_in_native