--- old/src/hotspot/share/runtime/arguments.cpp 2017-10-11 15:25:34.586287318 +0200 +++ new/src/hotspot/share/runtime/arguments.cpp 2017-10-11 15:25:34.344276927 +0200 @@ -50,6 +50,7 @@ #include "runtime/globals_extension.hpp" #include "runtime/java.hpp" #include "runtime/os.hpp" +#include "runtime/safepointMechanism.hpp" #include "runtime/vm_version.hpp" #include "services/management.hpp" #include "services/memTracker.hpp" @@ -4613,6 +4614,19 @@ } #endif + bool aot_enabled = UseAOT && ((AOTLibrary != NULL) || !FLAG_IS_DEFAULT(UseAOT)); + bool jvmci_enabled = NOT_JVMCI(false) JVMCI_ONLY(EnableJVMCI || UseJVMCICompiler); + bool handshakes_supported = SafepointMechanism::supports_thread_local_poll() && !aot_enabled && !jvmci_enabled; + if (handshakes_supported) { + if (FLAG_IS_DEFAULT(UseAOT)) { + FLAG_SET_DEFAULT(UseAOT, false); // Clear the AOT flag to make sure it doesn't try to initialize. + } + if (FLAG_IS_DEFAULT(ThreadLocalHandshakes) && !ThreadLocalHandshakes) { + FLAG_SET_ERGO(bool, ThreadLocalHandshakes, true); + log_info(ergo)("Enabling ThreadLocalHandshakes on supported platform"); + } + } + return JNI_OK; }