diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index 6b5edc85b2369..687b05002dadd 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -188,20 +188,16 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJVM, \ DISABLED_WARNINGS_gcc_cgroupV1Subsystem_linux.cpp := address, \ DISABLED_WARNINGS_gcc_cgroupV2Subsystem_linux.cpp := address, \ DISABLED_WARNINGS_gcc_g1FreeIdSet.cpp := unused-const-variable, \ - DISABLED_WARNINGS_gcc_handshake.cpp := stringop-overflow, \ DISABLED_WARNINGS_gcc_interp_masm_x86.cpp := uninitialized, \ DISABLED_WARNINGS_gcc_javaClasses.cpp := unused-const-variable, \ DISABLED_WARNINGS_gcc_jfrChunkWriter.cpp := unused-const-variable, \ DISABLED_WARNINGS_gcc_jfrMemorySizer.cpp := unused-const-variable, \ DISABLED_WARNINGS_gcc_jfrTraceIdKlassQueue.cpp := unused-const-variable, \ - DISABLED_WARNINGS_gcc_jvmciCodeInstaller.cpp := stringop-overflow, \ DISABLED_WARNINGS_gcc_jvmFlag.cpp := unused-const-variable, \ - DISABLED_WARNINGS_gcc_jvmtiTagMap.cpp := stringop-overflow, \ DISABLED_WARNINGS_gcc_macroAssembler_ppc_sha.cpp := unused-const-variable, \ DISABLED_WARNINGS_gcc_postaloc.cpp := address, \ DISABLED_WARNINGS_gcc_shenandoahLock.cpp := stringop-overflow, \ DISABLED_WARNINGS_gcc_stubGenerator_s390.cpp := unused-const-variable, \ - DISABLED_WARNINGS_gcc_synchronizer.cpp := stringop-overflow, \ DISABLED_WARNINGS_gcc_templateInterpreterGenerator_x86.cpp := unused-const-variable, \ DISABLED_WARNINGS_gcc_xGlobals_ppc.cpp := unused-const-variable, \ DISABLED_WARNINGS_clang := $(DISABLED_WARNINGS_clang), \ diff --git a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp index 3a9fbc54bf941..a6433d28d9ba4 100644 --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp +++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp @@ -923,6 +923,17 @@ int CodeInstaller::estimate_stubs_size(HotSpotCompiledCodeStream* stream, JVMCI_ // perform data and call relocation on the CodeBuffer JVMCI::CodeInstallResult CodeInstaller::initialize_buffer(JVMCIObject compiled_code, CodeBuffer& buffer, HotSpotCompiledCodeStream* stream, u1 code_flags, JVMCI_TRAPS) { JavaThread* thread = stream->thread(); +#if defined(__GNUC__) && !defined(__clang__) && !defined(PRODUCT) + if (thread == nullptr) { + // This is to prevent --stringop-overflow warning from GCC on linux/fastdebug. + // GCC does believe that JavaThread::current() can return nullptr, + // though it cannot. + // GCC seems to not remember that this hint has been given to it when initializing + // HotSpotCompiledCodeStream object with a thread returned by JavaThread::current(), + // therefore 2nd hint is needed. + __builtin_unreachable(); + } +#endif HandleMark hm(thread); int locs_buffer_size = _sites_count * (relocInfo::length_limit + sizeof(relocInfo)); diff --git a/src/hotspot/share/runtime/javaThread.hpp b/src/hotspot/share/runtime/javaThread.hpp index af46492622d5d..a85521b5057f3 100644 --- a/src/hotspot/share/runtime/javaThread.hpp +++ b/src/hotspot/share/runtime/javaThread.hpp @@ -1067,7 +1067,16 @@ class JavaThread: public Thread { public: // Returns the running thread as a JavaThread static JavaThread* current() { - return JavaThread::cast(Thread::current()); + auto result = JavaThread::cast(Thread::current()); +#if defined(__GNUC__) && !defined(__clang__) && !defined(PRODUCT) + if (result == nullptr) { + // This is to prevent --stringop-overflow warning from GCC on linux/fastdebug. + // GCC does believe that JavaThread::current() can return nullptr, + // though it cannot. + __builtin_unreachable(); + } +#endif + return result; } // Returns the current thread as a JavaThread, or nullptr if not attached