513 #undef BEFORE_EXIT_RUNNING |
513 #undef BEFORE_EXIT_RUNNING |
514 #undef BEFORE_EXIT_DONE |
514 #undef BEFORE_EXIT_DONE |
515 } |
515 } |
516 |
516 |
517 void vm_exit(int code) { |
517 void vm_exit(int code) { |
518 Thread* thread = ThreadLocalStorage::thread_index() == -1 ? NULL |
518 Thread* thread = ThreadLocalStorage::is_initialized() ? |
519 : ThreadLocalStorage::get_thread_slow(); |
519 ThreadLocalStorage::get_thread_slow() : NULL; |
520 if (thread == NULL) { |
520 if (thread == NULL) { |
521 // we have serious problems -- just exit |
521 // we have serious problems -- just exit |
522 vm_direct_exit(code); |
522 vm_direct_exit(code); |
523 } |
523 } |
524 |
524 |
551 void vm_perform_shutdown_actions() { |
551 void vm_perform_shutdown_actions() { |
552 // Warning: do not call 'exit_globals()' here. All threads are still running. |
552 // Warning: do not call 'exit_globals()' here. All threads are still running. |
553 // Calling 'exit_globals()' will disable thread-local-storage and cause all |
553 // Calling 'exit_globals()' will disable thread-local-storage and cause all |
554 // kinds of assertions to trigger in debug mode. |
554 // kinds of assertions to trigger in debug mode. |
555 if (is_init_completed()) { |
555 if (is_init_completed()) { |
556 Thread* thread = Thread::current(); |
556 Thread* thread = ThreadLocalStorage::is_initialized() ? |
557 if (thread->is_Java_thread()) { |
557 ThreadLocalStorage::get_thread_slow() : NULL; |
|
558 if (thread != NULL && thread->is_Java_thread()) { |
558 // We are leaving the VM, set state to native (in case any OS exit |
559 // We are leaving the VM, set state to native (in case any OS exit |
559 // handlers call back to the VM) |
560 // handlers call back to the VM) |
560 JavaThread* jt = (JavaThread*)thread; |
561 JavaThread* jt = (JavaThread*)thread; |
561 // Must always be walkable or have no last_Java_frame when in |
562 // Must always be walkable or have no last_Java_frame when in |
562 // thread_in_native |
563 // thread_in_native |