506 JvmtiExport::post_thread_end(thread);
507 }
508
509 // Always call even when there are not JVMTI environments yet, since environments
510 // may be attached late and JVMTI must track phases of VM execution
511 JvmtiExport::post_vm_death();
512 Threads::shutdown_vm_agents();
513
514 // Terminate the signal thread
515 // Note: we don't wait until it actually dies.
516 os::terminate_signal_thread();
517
518 print_statistics();
519 Universe::heap()->print_tracing_info();
520
521 { MutexLocker ml(BeforeExit_lock);
522 _before_exit_status = BEFORE_EXIT_DONE;
523 BeforeExit_lock->notify_all();
524 }
525
526 if (VerifyStringTableAtExit) {
527 int fail_cnt = 0;
528 {
529 MutexLocker ml(StringTable_lock);
530 fail_cnt = StringTable::verify_and_compare_entries();
531 }
532
533 if (fail_cnt != 0) {
534 tty->print_cr("ERROR: fail_cnt=%d", fail_cnt);
535 guarantee(fail_cnt == 0, "unexpected StringTable verification failures");
536 }
537 }
538
539 #undef BEFORE_EXIT_NOT_RUN
540 #undef BEFORE_EXIT_RUNNING
541 #undef BEFORE_EXIT_DONE
542 }
543
544 void vm_exit(int code) {
545 Thread* thread =
546 ThreadLocalStorage::is_initialized() ? Thread::current_or_null() : NULL;
547 if (thread == NULL) {
548 // very early initialization failure -- just exit
549 vm_direct_exit(code);
550 }
551
552 if (VMThread::vm_thread() != NULL) {
553 // Fire off a VM_Exit operation to bring VM to a safepoint and exit
554 VM_Exit op(code);
555 if (thread->is_Java_thread())
556 ((JavaThread*)thread)->set_thread_state(_thread_in_vm);
557 VMThread::execute(&op);
558 // should never reach here; but in case something wrong with VM Thread.
|
506 JvmtiExport::post_thread_end(thread);
507 }
508
509 // Always call even when there are not JVMTI environments yet, since environments
510 // may be attached late and JVMTI must track phases of VM execution
511 JvmtiExport::post_vm_death();
512 Threads::shutdown_vm_agents();
513
514 // Terminate the signal thread
515 // Note: we don't wait until it actually dies.
516 os::terminate_signal_thread();
517
518 print_statistics();
519 Universe::heap()->print_tracing_info();
520
521 { MutexLocker ml(BeforeExit_lock);
522 _before_exit_status = BEFORE_EXIT_DONE;
523 BeforeExit_lock->notify_all();
524 }
525
526 #undef BEFORE_EXIT_NOT_RUN
527 #undef BEFORE_EXIT_RUNNING
528 #undef BEFORE_EXIT_DONE
529 }
530
531 void vm_exit(int code) {
532 Thread* thread =
533 ThreadLocalStorage::is_initialized() ? Thread::current_or_null() : NULL;
534 if (thread == NULL) {
535 // very early initialization failure -- just exit
536 vm_direct_exit(code);
537 }
538
539 if (VMThread::vm_thread() != NULL) {
540 // Fire off a VM_Exit operation to bring VM to a safepoint and exit
541 VM_Exit op(code);
542 if (thread->is_Java_thread())
543 ((JavaThread*)thread)->set_thread_state(_thread_in_vm);
544 VMThread::execute(&op);
545 // should never reach here; but in case something wrong with VM Thread.
|