8263564: Consolidate POSIX code for runtime exit support: os::shutdown, os::abort and os::die
Reviewed-by: mikael
This commit is contained in:
parent
da9ead5e7f
commit
554dd29fb6
@ -1046,54 +1046,6 @@ struct tm* os::localtime_pd(const time_t* clock, struct tm* res) {
|
||||
return localtime_r(clock, res);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// runtime exit support
|
||||
|
||||
// Note: os::shutdown() might be called very early during initialization, or
|
||||
// called from signal handler. Before adding something to os::shutdown(), make
|
||||
// sure it is async-safe and can handle partially initialized VM.
|
||||
void os::shutdown() {
|
||||
|
||||
// allow PerfMemory to attempt cleanup of any persistent resources
|
||||
perfMemory_exit();
|
||||
|
||||
// needs to remove object in file system
|
||||
AttachListener::abort();
|
||||
|
||||
// flush buffered output, finish log files
|
||||
ostream_abort();
|
||||
|
||||
// Check for abort hook
|
||||
abort_hook_t abort_hook = Arguments::abort_hook();
|
||||
if (abort_hook != NULL) {
|
||||
abort_hook();
|
||||
}
|
||||
}
|
||||
|
||||
// Note: os::abort() might be called very early during initialization, or
|
||||
// called from signal handler. Before adding something to os::abort(), make
|
||||
// sure it is async-safe and can handle partially initialized VM.
|
||||
void os::abort(bool dump_core, void* siginfo, const void* context) {
|
||||
os::shutdown();
|
||||
if (dump_core) {
|
||||
::abort(); // dump core
|
||||
}
|
||||
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
// Die immediately, no exit hook, no abort hook, no cleanup.
|
||||
// Dump a core file, if possible, for debugging.
|
||||
void os::die() {
|
||||
if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) {
|
||||
// For TimeoutInErrorHandlingTest.java, we just kill the VM
|
||||
// and don't take the time to generate a core file.
|
||||
os::signal_raise(SIGKILL);
|
||||
} else {
|
||||
::abort();
|
||||
}
|
||||
}
|
||||
|
||||
intx os::current_thread_id() {
|
||||
return (intx)pthread_self();
|
||||
}
|
||||
|
@ -867,56 +867,6 @@ struct tm* os::localtime_pd(const time_t* clock, struct tm* res) {
|
||||
return localtime_r(clock, res);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// runtime exit support
|
||||
|
||||
// Note: os::shutdown() might be called very early during initialization, or
|
||||
// called from signal handler. Before adding something to os::shutdown(), make
|
||||
// sure it is async-safe and can handle partially initialized VM.
|
||||
void os::shutdown() {
|
||||
|
||||
// allow PerfMemory to attempt cleanup of any persistent resources
|
||||
perfMemory_exit();
|
||||
|
||||
// needs to remove object in file system
|
||||
AttachListener::abort();
|
||||
|
||||
// flush buffered output, finish log files
|
||||
ostream_abort();
|
||||
|
||||
// Check for abort hook
|
||||
abort_hook_t abort_hook = Arguments::abort_hook();
|
||||
if (abort_hook != NULL) {
|
||||
abort_hook();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Note: os::abort() might be called very early during initialization, or
|
||||
// called from signal handler. Before adding something to os::abort(), make
|
||||
// sure it is async-safe and can handle partially initialized VM.
|
||||
void os::abort(bool dump_core, void* siginfo, const void* context) {
|
||||
os::shutdown();
|
||||
if (dump_core) {
|
||||
::abort(); // dump core
|
||||
}
|
||||
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
// Die immediately, no exit hook, no abort hook, no cleanup.
|
||||
// Dump a core file, if possible, for debugging.
|
||||
void os::die() {
|
||||
if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) {
|
||||
// For TimeoutInErrorHandlingTest.java, we just kill the VM
|
||||
// and don't take the time to generate a core file.
|
||||
os::signal_raise(SIGKILL);
|
||||
} else {
|
||||
// _exit() on BsdThreads only kills current thread
|
||||
::abort();
|
||||
}
|
||||
}
|
||||
|
||||
// Information of current thread in variety of formats
|
||||
pid_t os::Bsd::gettid() {
|
||||
int retval = -1;
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
// no precompiled headers
|
||||
#include "jvm.h"
|
||||
#include "classfile/classLoader.hpp"
|
||||
#include "classfile/vmSymbols.hpp"
|
||||
#include "code/icBuffer.hpp"
|
||||
#include "code/vtableStubs.hpp"
|
||||
@ -65,7 +64,6 @@
|
||||
#include "runtime/vm_version.hpp"
|
||||
#include "signals_posix.hpp"
|
||||
#include "semaphore_posix.hpp"
|
||||
#include "services/attachListener.hpp"
|
||||
#include "services/memTracker.hpp"
|
||||
#include "services/runtimeService.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
@ -1356,58 +1354,6 @@ struct tm* os::localtime_pd(const time_t* clock, struct tm* res) {
|
||||
return localtime_r(clock, res);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// runtime exit support
|
||||
|
||||
// Note: os::shutdown() might be called very early during initialization, or
|
||||
// called from signal handler. Before adding something to os::shutdown(), make
|
||||
// sure it is async-safe and can handle partially initialized VM.
|
||||
void os::shutdown() {
|
||||
|
||||
// allow PerfMemory to attempt cleanup of any persistent resources
|
||||
perfMemory_exit();
|
||||
|
||||
// needs to remove object in file system
|
||||
AttachListener::abort();
|
||||
|
||||
// flush buffered output, finish log files
|
||||
ostream_abort();
|
||||
|
||||
// Check for abort hook
|
||||
abort_hook_t abort_hook = Arguments::abort_hook();
|
||||
if (abort_hook != NULL) {
|
||||
abort_hook();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Note: os::abort() might be called very early during initialization, or
|
||||
// called from signal handler. Before adding something to os::abort(), make
|
||||
// sure it is async-safe and can handle partially initialized VM.
|
||||
void os::abort(bool dump_core, void* siginfo, const void* context) {
|
||||
os::shutdown();
|
||||
if (dump_core) {
|
||||
if (DumpPrivateMappingsInCore) {
|
||||
ClassLoader::close_jrt_image();
|
||||
}
|
||||
::abort(); // dump core
|
||||
}
|
||||
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
// Die immediately, no exit hook, no abort hook, no cleanup.
|
||||
// Dump a core file, if possible, for debugging.
|
||||
void os::die() {
|
||||
if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) {
|
||||
// For TimeoutInErrorHandlingTest.java, we just kill the VM
|
||||
// and don't take the time to generate a core file.
|
||||
os::signal_raise(SIGKILL);
|
||||
} else {
|
||||
::abort();
|
||||
}
|
||||
}
|
||||
|
||||
// thread_id is kernel thread id (similar to Solaris LWP id)
|
||||
intx os::current_thread_id() { return os::Linux::gettid(); }
|
||||
int os::current_process_id() {
|
||||
|
@ -22,7 +22,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "jvm.h"
|
||||
#ifdef LINUX
|
||||
#include "classfile/classLoader.hpp"
|
||||
#endif
|
||||
#include "jvmtifiles/jvmti.h"
|
||||
#include "logging/log.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
@ -33,10 +37,12 @@
|
||||
#include "runtime/frame.inline.hpp"
|
||||
#include "runtime/interfaceSupport.inline.hpp"
|
||||
#include "runtime/sharedRuntime.hpp"
|
||||
#include "services/attachListener.hpp"
|
||||
#include "services/memTracker.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "runtime/java.hpp"
|
||||
#include "runtime/orderAccess.hpp"
|
||||
#include "runtime/perfMemory.hpp"
|
||||
#include "utilities/align.hpp"
|
||||
#include "utilities/events.hpp"
|
||||
#include "utilities/formatBuffer.hpp"
|
||||
@ -1843,3 +1849,52 @@ int os::fork_and_exec(const char* cmd, bool prefer_vfork) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// runtime exit support
|
||||
|
||||
// Note: os::shutdown() might be called very early during initialization, or
|
||||
// called from signal handler. Before adding something to os::shutdown(), make
|
||||
// sure it is async-safe and can handle partially initialized VM.
|
||||
void os::shutdown() {
|
||||
|
||||
// allow PerfMemory to attempt cleanup of any persistent resources
|
||||
perfMemory_exit();
|
||||
|
||||
// needs to remove object in file system
|
||||
AttachListener::abort();
|
||||
|
||||
// flush buffered output, finish log files
|
||||
ostream_abort();
|
||||
|
||||
// Check for abort hook
|
||||
abort_hook_t abort_hook = Arguments::abort_hook();
|
||||
if (abort_hook != NULL) {
|
||||
abort_hook();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Note: os::abort() might be called very early during initialization, or
|
||||
// called from signal handler. Before adding something to os::abort(), make
|
||||
// sure it is async-safe and can handle partially initialized VM.
|
||||
void os::abort(bool dump_core, void* siginfo, const void* context) {
|
||||
os::shutdown();
|
||||
if (dump_core) {
|
||||
LINUX_ONLY(if (DumpPrivateMappingsInCore) ClassLoader::close_jrt_image();)
|
||||
::abort(); // dump core
|
||||
}
|
||||
::exit(1);
|
||||
}
|
||||
|
||||
// Die immediately, no exit hook, no abort hook, no cleanup.
|
||||
// Dump a core file, if possible, for debugging.
|
||||
void os::die() {
|
||||
if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) {
|
||||
// For TimeoutInErrorHandlingTest.java, we just kill the VM
|
||||
// and don't take the time to generate a core file.
|
||||
os::signal_raise(SIGKILL);
|
||||
} else {
|
||||
::abort();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user