Skip to content

Commit 554dd29

Browse files
author
David Holmes
committed
8263564: Consolidate POSIX code for runtime exit support: os::shutdown, os::abort and os::die
Reviewed-by: mikael
1 parent da9ead5 commit 554dd29

File tree

4 files changed

+55
-152
lines changed

4 files changed

+55
-152
lines changed

src/hotspot/os/aix/os_aix.cpp

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,54 +1046,6 @@ struct tm* os::localtime_pd(const time_t* clock, struct tm* res) {
10461046
return localtime_r(clock, res);
10471047
}
10481048

1049-
////////////////////////////////////////////////////////////////////////////////
1050-
// runtime exit support
1051-
1052-
// Note: os::shutdown() might be called very early during initialization, or
1053-
// called from signal handler. Before adding something to os::shutdown(), make
1054-
// sure it is async-safe and can handle partially initialized VM.
1055-
void os::shutdown() {
1056-
1057-
// allow PerfMemory to attempt cleanup of any persistent resources
1058-
perfMemory_exit();
1059-
1060-
// needs to remove object in file system
1061-
AttachListener::abort();
1062-
1063-
// flush buffered output, finish log files
1064-
ostream_abort();
1065-
1066-
// Check for abort hook
1067-
abort_hook_t abort_hook = Arguments::abort_hook();
1068-
if (abort_hook != NULL) {
1069-
abort_hook();
1070-
}
1071-
}
1072-
1073-
// Note: os::abort() might be called very early during initialization, or
1074-
// called from signal handler. Before adding something to os::abort(), make
1075-
// sure it is async-safe and can handle partially initialized VM.
1076-
void os::abort(bool dump_core, void* siginfo, const void* context) {
1077-
os::shutdown();
1078-
if (dump_core) {
1079-
::abort(); // dump core
1080-
}
1081-
1082-
::exit(1);
1083-
}
1084-
1085-
// Die immediately, no exit hook, no abort hook, no cleanup.
1086-
// Dump a core file, if possible, for debugging.
1087-
void os::die() {
1088-
if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) {
1089-
// For TimeoutInErrorHandlingTest.java, we just kill the VM
1090-
// and don't take the time to generate a core file.
1091-
os::signal_raise(SIGKILL);
1092-
} else {
1093-
::abort();
1094-
}
1095-
}
1096-
10971049
intx os::current_thread_id() {
10981050
return (intx)pthread_self();
10991051
}

src/hotspot/os/bsd/os_bsd.cpp

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -867,56 +867,6 @@ struct tm* os::localtime_pd(const time_t* clock, struct tm* res) {
867867
return localtime_r(clock, res);
868868
}
869869

870-
////////////////////////////////////////////////////////////////////////////////
871-
// runtime exit support
872-
873-
// Note: os::shutdown() might be called very early during initialization, or
874-
// called from signal handler. Before adding something to os::shutdown(), make
875-
// sure it is async-safe and can handle partially initialized VM.
876-
void os::shutdown() {
877-
878-
// allow PerfMemory to attempt cleanup of any persistent resources
879-
perfMemory_exit();
880-
881-
// needs to remove object in file system
882-
AttachListener::abort();
883-
884-
// flush buffered output, finish log files
885-
ostream_abort();
886-
887-
// Check for abort hook
888-
abort_hook_t abort_hook = Arguments::abort_hook();
889-
if (abort_hook != NULL) {
890-
abort_hook();
891-
}
892-
893-
}
894-
895-
// Note: os::abort() might be called very early during initialization, or
896-
// called from signal handler. Before adding something to os::abort(), make
897-
// sure it is async-safe and can handle partially initialized VM.
898-
void os::abort(bool dump_core, void* siginfo, const void* context) {
899-
os::shutdown();
900-
if (dump_core) {
901-
::abort(); // dump core
902-
}
903-
904-
::exit(1);
905-
}
906-
907-
// Die immediately, no exit hook, no abort hook, no cleanup.
908-
// Dump a core file, if possible, for debugging.
909-
void os::die() {
910-
if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) {
911-
// For TimeoutInErrorHandlingTest.java, we just kill the VM
912-
// and don't take the time to generate a core file.
913-
os::signal_raise(SIGKILL);
914-
} else {
915-
// _exit() on BsdThreads only kills current thread
916-
::abort();
917-
}
918-
}
919-
920870
// Information of current thread in variety of formats
921871
pid_t os::Bsd::gettid() {
922872
int retval = -1;

src/hotspot/os/linux/os_linux.cpp

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
// no precompiled headers
2626
#include "jvm.h"
27-
#include "classfile/classLoader.hpp"
2827
#include "classfile/vmSymbols.hpp"
2928
#include "code/icBuffer.hpp"
3029
#include "code/vtableStubs.hpp"
@@ -65,7 +64,6 @@
6564
#include "runtime/vm_version.hpp"
6665
#include "signals_posix.hpp"
6766
#include "semaphore_posix.hpp"
68-
#include "services/attachListener.hpp"
6967
#include "services/memTracker.hpp"
7068
#include "services/runtimeService.hpp"
7169
#include "utilities/align.hpp"
@@ -1356,58 +1354,6 @@ struct tm* os::localtime_pd(const time_t* clock, struct tm* res) {
13561354
return localtime_r(clock, res);
13571355
}
13581356

1359-
////////////////////////////////////////////////////////////////////////////////
1360-
// runtime exit support
1361-
1362-
// Note: os::shutdown() might be called very early during initialization, or
1363-
// called from signal handler. Before adding something to os::shutdown(), make
1364-
// sure it is async-safe and can handle partially initialized VM.
1365-
void os::shutdown() {
1366-
1367-
// allow PerfMemory to attempt cleanup of any persistent resources
1368-
perfMemory_exit();
1369-
1370-
// needs to remove object in file system
1371-
AttachListener::abort();
1372-
1373-
// flush buffered output, finish log files
1374-
ostream_abort();
1375-
1376-
// Check for abort hook
1377-
abort_hook_t abort_hook = Arguments::abort_hook();
1378-
if (abort_hook != NULL) {
1379-
abort_hook();
1380-
}
1381-
1382-
}
1383-
1384-
// Note: os::abort() might be called very early during initialization, or
1385-
// called from signal handler. Before adding something to os::abort(), make
1386-
// sure it is async-safe and can handle partially initialized VM.
1387-
void os::abort(bool dump_core, void* siginfo, const void* context) {
1388-
os::shutdown();
1389-
if (dump_core) {
1390-
if (DumpPrivateMappingsInCore) {
1391-
ClassLoader::close_jrt_image();
1392-
}
1393-
::abort(); // dump core
1394-
}
1395-
1396-
::exit(1);
1397-
}
1398-
1399-
// Die immediately, no exit hook, no abort hook, no cleanup.
1400-
// Dump a core file, if possible, for debugging.
1401-
void os::die() {
1402-
if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) {
1403-
// For TimeoutInErrorHandlingTest.java, we just kill the VM
1404-
// and don't take the time to generate a core file.
1405-
os::signal_raise(SIGKILL);
1406-
} else {
1407-
::abort();
1408-
}
1409-
}
1410-
14111357
// thread_id is kernel thread id (similar to Solaris LWP id)
14121358
intx os::current_thread_id() { return os::Linux::gettid(); }
14131359
int os::current_process_id() {

src/hotspot/os/posix/os_posix.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
*
2323
*/
2424

25+
2526
#include "jvm.h"
27+
#ifdef LINUX
28+
#include "classfile/classLoader.hpp"
29+
#endif
2630
#include "jvmtifiles/jvmti.h"
2731
#include "logging/log.hpp"
2832
#include "memory/allocation.inline.hpp"
@@ -33,10 +37,12 @@
3337
#include "runtime/frame.inline.hpp"
3438
#include "runtime/interfaceSupport.inline.hpp"
3539
#include "runtime/sharedRuntime.hpp"
40+
#include "services/attachListener.hpp"
3641
#include "services/memTracker.hpp"
3742
#include "runtime/atomic.hpp"
3843
#include "runtime/java.hpp"
3944
#include "runtime/orderAccess.hpp"
45+
#include "runtime/perfMemory.hpp"
4046
#include "utilities/align.hpp"
4147
#include "utilities/events.hpp"
4248
#include "utilities/formatBuffer.hpp"
@@ -1843,3 +1849,52 @@ int os::fork_and_exec(const char* cmd, bool prefer_vfork) {
18431849
}
18441850
}
18451851
}
1852+
1853+
////////////////////////////////////////////////////////////////////////////////
1854+
// runtime exit support
1855+
1856+
// Note: os::shutdown() might be called very early during initialization, or
1857+
// called from signal handler. Before adding something to os::shutdown(), make
1858+
// sure it is async-safe and can handle partially initialized VM.
1859+
void os::shutdown() {
1860+
1861+
// allow PerfMemory to attempt cleanup of any persistent resources
1862+
perfMemory_exit();
1863+
1864+
// needs to remove object in file system
1865+
AttachListener::abort();
1866+
1867+
// flush buffered output, finish log files
1868+
ostream_abort();
1869+
1870+
// Check for abort hook
1871+
abort_hook_t abort_hook = Arguments::abort_hook();
1872+
if (abort_hook != NULL) {
1873+
abort_hook();
1874+
}
1875+
1876+
}
1877+
1878+
// Note: os::abort() might be called very early during initialization, or
1879+
// called from signal handler. Before adding something to os::abort(), make
1880+
// sure it is async-safe and can handle partially initialized VM.
1881+
void os::abort(bool dump_core, void* siginfo, const void* context) {
1882+
os::shutdown();
1883+
if (dump_core) {
1884+
LINUX_ONLY(if (DumpPrivateMappingsInCore) ClassLoader::close_jrt_image();)
1885+
::abort(); // dump core
1886+
}
1887+
::exit(1);
1888+
}
1889+
1890+
// Die immediately, no exit hook, no abort hook, no cleanup.
1891+
// Dump a core file, if possible, for debugging.
1892+
void os::die() {
1893+
if (TestUnresponsiveErrorHandler && !CreateCoredumpOnCrash) {
1894+
// For TimeoutInErrorHandlingTest.java, we just kill the VM
1895+
// and don't take the time to generate a core file.
1896+
os::signal_raise(SIGKILL);
1897+
} else {
1898+
::abort();
1899+
}
1900+
}

0 commit comments

Comments
 (0)