< prev index next >

src/share/vm/runtime/java.cpp

Print this page




 495 
 496   if (VerifyStringTableAtExit) {
 497     int fail_cnt = 0;
 498     {
 499       MutexLocker ml(StringTable_lock);
 500       fail_cnt = StringTable::verify_and_compare_entries();
 501     }
 502 
 503     if (fail_cnt != 0) {
 504       tty->print_cr("ERROR: fail_cnt=%d", fail_cnt);
 505       guarantee(fail_cnt == 0, "unexpected StringTable verification failures");
 506     }
 507   }
 508 
 509   #undef BEFORE_EXIT_NOT_RUN
 510   #undef BEFORE_EXIT_RUNNING
 511   #undef BEFORE_EXIT_DONE
 512 }
 513 
 514 void vm_exit(int code) {
 515   Thread* thread = ThreadLocalStorage::is_initialized() ?
 516     ThreadLocalStorage::get_thread_slow() : NULL;
 517   if (thread == NULL) {
 518     // we have serious problems -- just exit
 519     vm_direct_exit(code);
 520   }
 521 
 522   if (VMThread::vm_thread() != NULL) {
 523     // Fire off a VM_Exit operation to bring VM to a safepoint and exit
 524     VM_Exit op(code);
 525     if (thread->is_Java_thread())
 526       ((JavaThread*)thread)->set_thread_state(_thread_in_vm);
 527     VMThread::execute(&op);
 528     // should never reach here; but in case something wrong with VM Thread.
 529     vm_direct_exit(code);
 530   } else {
 531     // VM thread is gone, just exit
 532     vm_direct_exit(code);
 533   }
 534   ShouldNotReachHere();
 535 }
 536 
 537 void notify_vm_shutdown() {
 538   // For now, just a dtrace probe.
 539   HOTSPOT_VM_SHUTDOWN();
 540   HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
 541 }
 542 
 543 void vm_direct_exit(int code) {
 544   notify_vm_shutdown();
 545   os::wait_for_keypress_at_exit();
 546   os::exit(code);
 547 }
 548 
 549 void vm_perform_shutdown_actions() {
 550   // Warning: do not call 'exit_globals()' here. All threads are still running.
 551   // Calling 'exit_globals()' will disable thread-local-storage and cause all
 552   // kinds of assertions to trigger in debug mode.
 553   if (is_init_completed()) {
 554     Thread* thread = ThreadLocalStorage::is_initialized() ?
 555                      ThreadLocalStorage::get_thread_slow() : NULL;
 556     if (thread != NULL && thread->is_Java_thread()) {
 557       // We are leaving the VM, set state to native (in case any OS exit
 558       // handlers call back to the VM)
 559       JavaThread* jt = (JavaThread*)thread;
 560       // Must always be walkable or have no last_Java_frame when in
 561       // thread_in_native
 562       jt->frame_anchor()->make_walkable(jt);
 563       jt->set_thread_state(_thread_in_native);
 564     }
 565   }
 566   notify_vm_shutdown();
 567 }
 568 
 569 void vm_shutdown()
 570 {
 571   vm_perform_shutdown_actions();
 572   os::wait_for_keypress_at_exit();
 573   os::shutdown();
 574 }
 575 


 589   if (error != NULL) {
 590     tty->print_cr("Error occurred during initialization of VM");
 591     tty->print("%s", error);
 592     if (message != NULL) {
 593       tty->print_cr(": %s", message);
 594     }
 595     else {
 596       tty->cr();
 597     }
 598   }
 599   if (ShowMessageBoxOnError && WizardMode) {
 600     fatal("Error occurred during initialization of VM");
 601   }
 602 }
 603 
 604 void vm_exit_during_initialization(Handle exception) {
 605   tty->print_cr("Error occurred during initialization of VM");
 606   // If there are exceptions on this thread it must be cleared
 607   // first and here. Any future calls to EXCEPTION_MARK requires
 608   // that no pending exceptions exist.
 609   Thread *THREAD = Thread::current();
 610   if (HAS_PENDING_EXCEPTION) {
 611     CLEAR_PENDING_EXCEPTION;
 612   }
 613   java_lang_Throwable::print(exception, tty);
 614   tty->cr();
 615   java_lang_Throwable::print_stack_trace(exception(), tty);
 616   tty->cr();
 617   vm_notify_during_shutdown(NULL, NULL);
 618 
 619   // Failure during initialization, we don't want to dump core
 620   vm_abort(false);
 621 }
 622 
 623 void vm_exit_during_initialization(Symbol* ex, const char* message) {
 624   ResourceMark rm;
 625   vm_notify_during_shutdown(ex->as_C_string(), message);
 626 
 627   // Failure during initialization, we don't want to dump core
 628   vm_abort(false);
 629 }




 495 
 496   if (VerifyStringTableAtExit) {
 497     int fail_cnt = 0;
 498     {
 499       MutexLocker ml(StringTable_lock);
 500       fail_cnt = StringTable::verify_and_compare_entries();
 501     }
 502 
 503     if (fail_cnt != 0) {
 504       tty->print_cr("ERROR: fail_cnt=%d", fail_cnt);
 505       guarantee(fail_cnt == 0, "unexpected StringTable verification failures");
 506     }
 507   }
 508 
 509   #undef BEFORE_EXIT_NOT_RUN
 510   #undef BEFORE_EXIT_RUNNING
 511   #undef BEFORE_EXIT_DONE
 512 }
 513 
 514 void vm_exit(int code) {
 515   Thread* thread = 
 516       ThreadLocalStorage::is_initialized() ? Thread::current_or_null() : NULL;
 517   if (thread == NULL) {
 518     // very early initialization failure -- just exit
 519     vm_direct_exit(code);
 520   }
 521 
 522   if (VMThread::vm_thread() != NULL) {
 523     // Fire off a VM_Exit operation to bring VM to a safepoint and exit
 524     VM_Exit op(code);
 525     if (thread->is_Java_thread())
 526       ((JavaThread*)thread)->set_thread_state(_thread_in_vm);
 527     VMThread::execute(&op);
 528     // should never reach here; but in case something wrong with VM Thread.
 529     vm_direct_exit(code);
 530   } else {
 531     // VM thread is gone, just exit
 532     vm_direct_exit(code);
 533   }
 534   ShouldNotReachHere();
 535 }
 536 
 537 void notify_vm_shutdown() {
 538   // For now, just a dtrace probe.
 539   HOTSPOT_VM_SHUTDOWN();
 540   HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
 541 }
 542 
 543 void vm_direct_exit(int code) {
 544   notify_vm_shutdown();
 545   os::wait_for_keypress_at_exit();
 546   os::exit(code);
 547 }
 548 
 549 void vm_perform_shutdown_actions() {
 550   // Warning: do not call 'exit_globals()' here. All threads are still running.
 551   // Calling 'exit_globals()' will disable thread-local-storage and cause all
 552   // kinds of assertions to trigger in debug mode.
 553   if (is_init_completed()) {
 554     Thread* thread = Thread::current_or_null();

 555     if (thread != NULL && thread->is_Java_thread()) {
 556       // We are leaving the VM, set state to native (in case any OS exit
 557       // handlers call back to the VM)
 558       JavaThread* jt = (JavaThread*)thread;
 559       // Must always be walkable or have no last_Java_frame when in
 560       // thread_in_native
 561       jt->frame_anchor()->make_walkable(jt);
 562       jt->set_thread_state(_thread_in_native);
 563     }
 564   }
 565   notify_vm_shutdown();
 566 }
 567 
 568 void vm_shutdown()
 569 {
 570   vm_perform_shutdown_actions();
 571   os::wait_for_keypress_at_exit();
 572   os::shutdown();
 573 }
 574 


 588   if (error != NULL) {
 589     tty->print_cr("Error occurred during initialization of VM");
 590     tty->print("%s", error);
 591     if (message != NULL) {
 592       tty->print_cr(": %s", message);
 593     }
 594     else {
 595       tty->cr();
 596     }
 597   }
 598   if (ShowMessageBoxOnError && WizardMode) {
 599     fatal("Error occurred during initialization of VM");
 600   }
 601 }
 602 
 603 void vm_exit_during_initialization(Handle exception) {
 604   tty->print_cr("Error occurred during initialization of VM");
 605   // If there are exceptions on this thread it must be cleared
 606   // first and here. Any future calls to EXCEPTION_MARK requires
 607   // that no pending exceptions exist.
 608   Thread *THREAD = Thread::current(); // can't be NULL
 609   if (HAS_PENDING_EXCEPTION) {
 610     CLEAR_PENDING_EXCEPTION;
 611   }
 612   java_lang_Throwable::print(exception, tty);
 613   tty->cr();
 614   java_lang_Throwable::print_stack_trace(exception(), tty);
 615   tty->cr();
 616   vm_notify_during_shutdown(NULL, NULL);
 617 
 618   // Failure during initialization, we don't want to dump core
 619   vm_abort(false);
 620 }
 621 
 622 void vm_exit_during_initialization(Symbol* ex, const char* message) {
 623   ResourceMark rm;
 624   vm_notify_during_shutdown(ex->as_C_string(), message);
 625 
 626   // Failure during initialization, we don't want to dump core
 627   vm_abort(false);
 628 }


< prev index next >