< prev index next >

src/share/vm/runtime/java.cpp

Print this page




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




 494 
 495   if (VerifyStringTableAtExit) {
 496     int fail_cnt = 0;
 497     {
 498       MutexLocker ml(StringTable_lock);
 499       fail_cnt = StringTable::verify_and_compare_entries();
 500     }
 501 
 502     if (fail_cnt != 0) {
 503       tty->print_cr("ERROR: fail_cnt=%d", fail_cnt);
 504       guarantee(fail_cnt == 0, "unexpected StringTable verification failures");
 505     }
 506   }
 507 
 508   #undef BEFORE_EXIT_NOT_RUN
 509   #undef BEFORE_EXIT_RUNNING
 510   #undef BEFORE_EXIT_DONE
 511 }
 512 
 513 void vm_exit(int code) {
 514   Thread* thread = Thread::current_or_null();

 515   if (thread == NULL) {
 516     // we have serious problems -- just exit
 517     vm_direct_exit(code);
 518   }
 519 
 520   if (VMThread::vm_thread() != NULL) {
 521     // Fire off a VM_Exit operation to bring VM to a safepoint and exit
 522     VM_Exit op(code);
 523     if (thread->is_Java_thread())
 524       ((JavaThread*)thread)->set_thread_state(_thread_in_vm);
 525     VMThread::execute(&op);
 526     // should never reach here; but in case something wrong with VM Thread.
 527     vm_direct_exit(code);
 528   } else {
 529     // VM thread is gone, just exit
 530     vm_direct_exit(code);
 531   }
 532   ShouldNotReachHere();
 533 }
 534 
 535 void notify_vm_shutdown() {
 536   // For now, just a dtrace probe.
 537   HOTSPOT_VM_SHUTDOWN();
 538   HS_DTRACE_WORKAROUND_TAIL_CALL_BUG();
 539 }
 540 
 541 void vm_direct_exit(int code) {
 542   notify_vm_shutdown();
 543   os::wait_for_keypress_at_exit();
 544   os::exit(code);
 545 }
 546 
 547 void vm_perform_shutdown_actions() {
 548   // Warning: do not call 'exit_globals()' here. All threads are still running.
 549   // Calling 'exit_globals()' will disable thread-local-storage and cause all
 550   // kinds of assertions to trigger in debug mode.
 551   if (is_init_completed()) {
 552     Thread* thread = Thread::current_or_null();

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


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


< prev index next >