From e20f0ce7f17f5eb62492082f8190762766685c7f Mon Sep 17 00:00:00 2001 From: Justin King Date: Wed, 22 Feb 2023 07:37:56 -0800 Subject: [PATCH 1/3] Disable RTTI with MSVC Signed-off-by: Justin King --- make/autoconf/flags-cflags.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 1fdd0143adf80..e99dc3efc1541 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -535,7 +535,7 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], TOOLCHAIN_CFLAGS_JVM="-qtbtable=full -qtune=balanced -fno-exceptions \ -qalias=noansi -qstrict -qtls=default -qnortti -qnoeh -qignerrno -qstackprotect" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - TOOLCHAIN_CFLAGS_JVM="-nologo -MD -Zc:preprocessor -Zc:strictStrings -MP" + TOOLCHAIN_CFLAGS_JVM="-nologo -MD -Zc:preprocessor -Zc:strictStrings -MP -GR-" TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:preprocessor -Zc:strictStrings -Zc:wchar_t-" fi From 87d707eb45b832926cd60cd450791bbbbfe711ab Mon Sep 17 00:00:00 2001 From: Justin King Date: Fri, 24 Feb 2023 07:04:58 -0800 Subject: [PATCH 2/3] Force MSVC to emit unique vtable for NotificationThread Signed-off-by: Justin King --- src/hotspot/share/runtime/notificationThread.hpp | 8 +++++++- src/hotspot/share/runtime/thread.hpp | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/runtime/notificationThread.hpp b/src/hotspot/share/runtime/notificationThread.hpp index 17977e9353950..8875dd2694052 100644 --- a/src/hotspot/share/runtime/notificationThread.hpp +++ b/src/hotspot/share/runtime/notificationThread.hpp @@ -37,11 +37,17 @@ class NotificationThread : public JavaThread { private: static void notification_thread_entry(JavaThread* thread, TRAPS); - NotificationThread(ThreadFunction entry_point) : JavaThread(entry_point) {}; + NotificationThread(ThreadFunction entry_point) : JavaThread(entry_point) {} public: static void initialize(); + // Serviceability Agent relies on being able to identify types based on their vtable address. If + // we do not override any virtual methods and RTTI is disabled, MSVC may emit a single vtable for + // JavaThread and NotificationThread. This results in the vtable symbols for both classes pointing + // to the same address and Serviceability Agent thinking all JavaThread are NotificationThread. So + // while this method is not directly used anywhere, it must exist. + bool is_Notification_thread() const override { return true; } }; #endif // SHARE_RUNTIME_NOTIFICATIONTHREAD_HPP diff --git a/src/hotspot/share/runtime/thread.hpp b/src/hotspot/share/runtime/thread.hpp index b057413910ded..ed31b85acf812 100644 --- a/src/hotspot/share/runtime/thread.hpp +++ b/src/hotspot/share/runtime/thread.hpp @@ -327,6 +327,7 @@ class Thread: public ThreadShadow { virtual bool is_Named_thread() const { return false; } virtual bool is_Worker_thread() const { return false; } virtual bool is_JfrSampler_thread() const { return false; } + virtual bool is_Notification_thread() const { return false; } // Can this thread make Java upcalls virtual bool can_call_java() const { return false; } From 9a8822074bb7aca9ca8bf7d8f67c9ef49f7e7e27 Mon Sep 17 00:00:00 2001 From: Justin King Date: Fri, 24 Feb 2023 11:48:19 -0800 Subject: [PATCH 3/3] Update src/hotspot/share/runtime/notificationThread.hpp Co-authored-by: Chris Plummer --- src/hotspot/share/runtime/notificationThread.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/runtime/notificationThread.hpp b/src/hotspot/share/runtime/notificationThread.hpp index 8875dd2694052..e6b66594463c4 100644 --- a/src/hotspot/share/runtime/notificationThread.hpp +++ b/src/hotspot/share/runtime/notificationThread.hpp @@ -45,7 +45,7 @@ class NotificationThread : public JavaThread { // Serviceability Agent relies on being able to identify types based on their vtable address. If // we do not override any virtual methods and RTTI is disabled, MSVC may emit a single vtable for // JavaThread and NotificationThread. This results in the vtable symbols for both classes pointing - // to the same address and Serviceability Agent thinking all JavaThread are NotificationThread. So + // to the same address, and Serviceability Agent thinking all JavaThreads are NotificationThreads. So // while this method is not directly used anywhere, it must exist. bool is_Notification_thread() const override { return true; } };