void VM_Exit::doit() { CompileBroker::set_should_block(); // Wait for a short period for threads in native to block. Any thread // still executing native code after the wait will be stopped at // native==>Java/VM barriers. // Among 16276 JCK tests, 94% of them come here without any threads still // running in native; the other 6% are quiescent within 250ms (Ultra 80). wait_for_threads_in_native_to_block(); set_vm_exited(); // cleanup globals resources before exiting. exit_globals() currently // cleans up outputStream resources and PerfMemory resources. exit_globals(); // Check for exit hook exit_hook_t exit_hook = Arguments::exit_hook(); if (exit_hook != NULL) { // exit hook should exit. exit_hook(_exit_code); // ... but if it didn't, we must do it here vm_direct_exit(_exit_code); } else { vm_direct_exit(_exit_code); } }
void vm_exit(int code) { exit_hook_t exit_hook = Arguments::exit_hook(); Thread* thread = Thread::current(); if (thread == NULL) { // we have serious problems -- just exit if(exit_hook!=NULL){ exit_hook(code); } else { vm_direct_exit(code); } } if (VMThread::vm_thread() != NULL) { // Fire off a VM_Exit operation to bring VM to a safepoint and exit VM_Exit op(code); VMThread::execute(&op); // should never reach here; but in case something wrong with VM Thread. vm_direct_exit(code); } else { // VM thread is gone, just exit if(exit_hook!=NULL){ exit_hook(code); } else { vm_direct_exit(code); } } ShouldNotReachHere(); }
void vm_exit(int code) { Thread* thread = ThreadLocalStorage::thread_index() == -1 ? NULL : ThreadLocalStorage::get_thread_slow(); if (thread == NULL) { // we have serious problems -- just exit vm_direct_exit(code); } if (VMThread::vm_thread() != NULL) { // Fire off a VM_Exit operation to bring VM to a safepoint and exit VM_Exit op(code); if (thread->is_Java_thread()) ((JavaThread*)thread)->set_thread_state(_thread_in_vm); VMThread::execute(&op); // should never reach here; but in case something wrong with VM Thread. vm_direct_exit(code); } else { // VM thread is gone, just exit vm_direct_exit(code); } ShouldNotReachHere(); }