From 9fd2738026fc250eb620fc19627cf26a8c73d6a8 Mon Sep 17 00:00:00 2001 From: rwestberg Date: Tue, 13 Feb 2018 15:48:23 +0100 Subject: [PATCH] 8041626: Shutdown tracing event Reviewed-by: dholmes, alanb, rriggs --- make/aix/makefiles/mapfile-vers-debug | 1 + make/aix/makefiles/mapfile-vers-product | 1 + make/bsd/makefiles/mapfile-vers-debug | 1 + make/bsd/makefiles/mapfile-vers-product | 1 + make/linux/makefiles/mapfile-vers-debug | 1 + make/linux/makefiles/mapfile-vers-product | 1 + make/solaris/makefiles/mapfile-vers | 1 + src/share/vm/prims/jvm.cpp | 10 ++++++++++ src/share/vm/prims/jvm.h | 3 +++ src/share/vm/runtime/thread.cpp | 6 ++++++ 10 files changed, 26 insertions(+) diff --git a/make/aix/makefiles/mapfile-vers-debug b/make/aix/makefiles/mapfile-vers-debug index 8f28690b4..9d1d947f2 100644 --- a/make/aix/makefiles/mapfile-vers-debug +++ b/make/aix/makefiles/mapfile-vers-debug @@ -39,6 +39,7 @@ SUNWprivate_1.1 { JVM_ArrayCopy; JVM_AssertionStatusDirectives; JVM_Available; + JVM_BeforeHalt; JVM_Bind; JVM_ClassDepth; JVM_ClassLoaderDepth; diff --git a/make/aix/makefiles/mapfile-vers-product b/make/aix/makefiles/mapfile-vers-product index adcb3fc6d..a54644dcb 100644 --- a/make/aix/makefiles/mapfile-vers-product +++ b/make/aix/makefiles/mapfile-vers-product @@ -39,6 +39,7 @@ SUNWprivate_1.1 { JVM_ArrayCopy; JVM_AssertionStatusDirectives; JVM_Available; + JVM_BeforeHalt; JVM_Bind; JVM_ClassDepth; JVM_ClassLoaderDepth; diff --git a/make/bsd/makefiles/mapfile-vers-debug b/make/bsd/makefiles/mapfile-vers-debug index 5e4a6a52a..49a70edcb 100644 --- a/make/bsd/makefiles/mapfile-vers-debug +++ b/make/bsd/makefiles/mapfile-vers-debug @@ -37,6 +37,7 @@ _JVM_ArrayCopy _JVM_AssertionStatusDirectives _JVM_Available + _JVM_BeforeHalt _JVM_Bind _JVM_ClassDepth _JVM_ClassLoaderDepth diff --git a/make/bsd/makefiles/mapfile-vers-product b/make/bsd/makefiles/mapfile-vers-product index b8a83d630..502746713 100644 --- a/make/bsd/makefiles/mapfile-vers-product +++ b/make/bsd/makefiles/mapfile-vers-product @@ -37,6 +37,7 @@ _JVM_ArrayCopy _JVM_AssertionStatusDirectives _JVM_Available + _JVM_BeforeHalt _JVM_Bind _JVM_ClassDepth _JVM_ClassLoaderDepth diff --git a/make/linux/makefiles/mapfile-vers-debug b/make/linux/makefiles/mapfile-vers-debug index f16822b20..d9ca7f79a 100644 --- a/make/linux/makefiles/mapfile-vers-debug +++ b/make/linux/makefiles/mapfile-vers-debug @@ -39,6 +39,7 @@ SUNWprivate_1.1 { JVM_ArrayCopy; JVM_AssertionStatusDirectives; JVM_Available; + JVM_BeforeHalt; JVM_Bind; JVM_ClassDepth; JVM_ClassLoaderDepth; diff --git a/make/linux/makefiles/mapfile-vers-product b/make/linux/makefiles/mapfile-vers-product index f96c86b4b..9b04f7281 100644 --- a/make/linux/makefiles/mapfile-vers-product +++ b/make/linux/makefiles/mapfile-vers-product @@ -39,6 +39,7 @@ SUNWprivate_1.1 { JVM_ArrayCopy; JVM_AssertionStatusDirectives; JVM_Available; + JVM_BeforeHalt; JVM_Bind; JVM_ClassDepth; JVM_ClassLoaderDepth; diff --git a/make/solaris/makefiles/mapfile-vers b/make/solaris/makefiles/mapfile-vers index d76be6ccc..f36847169 100644 --- a/make/solaris/makefiles/mapfile-vers +++ b/make/solaris/makefiles/mapfile-vers @@ -39,6 +39,7 @@ SUNWprivate_1.1 { JVM_ArrayCopy; JVM_AssertionStatusDirectives; JVM_Available; + JVM_BeforeHalt; JVM_Bind; JVM_ClassDepth; JVM_ClassLoaderDepth; diff --git a/src/share/vm/prims/jvm.cpp b/src/share/vm/prims/jvm.cpp index e60463191..bc3ff540d 100644 --- a/src/share/vm/prims/jvm.cpp +++ b/src/share/vm/prims/jvm.cpp @@ -443,6 +443,16 @@ JVM_ENTRY_NO_ENV(void, JVM_Exit(jint code)) JVM_END +JVM_ENTRY_NO_ENV(void, JVM_BeforeHalt()) + JVMWrapper("JVM_BeforeHalt"); + EventShutdown event; + if (event.should_commit()) { + event.set_reason("Shutdown requested from Java"); + event.commit(); + } +JVM_END + + JVM_ENTRY_NO_ENV(void, JVM_Halt(jint code)) before_exit(thread); vm_exit(code); diff --git a/src/share/vm/prims/jvm.h b/src/share/vm/prims/jvm.h index 2c64341b7..d8f8e873a 100644 --- a/src/share/vm/prims/jvm.h +++ b/src/share/vm/prims/jvm.h @@ -158,6 +158,9 @@ JVM_CopySwapMemory(JNIEnv *env, jobject srcObj, jlong srcOffset, JNIEXPORT void JNICALL JVM_Exit(jint code); +JNIEXPORT void JNICALL +JVM_BeforeHalt(); + JNIEXPORT void JNICALL JVM_Halt(jint code); diff --git a/src/share/vm/runtime/thread.cpp b/src/share/vm/runtime/thread.cpp index 0c4e14828..42fc46841 100644 --- a/src/share/vm/runtime/thread.cpp +++ b/src/share/vm/runtime/thread.cpp @@ -4012,6 +4012,12 @@ bool Threads::destroy_vm() { Mutex::_as_suspend_equivalent_flag); } + EventShutdown e; + if (e.should_commit()) { + e.set_reason("No remaining non-daemon Java threads"); + e.commit(); + } + // Hang forever on exit if we are reporting an error. if (ShowMessageBoxOnError && is_error_reported()) { os::infinite_sleep(); -- GitLab