--- old/src/hotspot/share/runtime/arguments.cpp 2017-10-30 15:12:30.518371350 +0100 +++ new/src/hotspot/share/runtime/arguments.cpp 2017-10-30 15:12:30.174360045 +0100 @@ -4616,16 +4616,35 @@ 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; + bool handshakes_supported = SafepointMechanism::supports_thread_local_poll() && !aot_enabled && !jvmci_enabled && ThreadLocalHandshakes; + // ThreadLocalHandshakesConstraintFunc handles the constraints. + // Here we try to figure out if a mutual exclusive option have been set. 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"); + } else { + if (FLAG_IS_DEFAULT(ThreadLocalHandshakes) && ThreadLocalHandshakes) { + if (!SafepointMechanism::supports_thread_local_poll()) { + // Unsupported platform should have ThreadLocalHandshakes default set to false. + log_debug(ergo)("Disabling ThreadLocalHandshakes unsupported plaform."); + FLAG_SET_ERGO(bool, ThreadLocalHandshakes, false); + } else if (!FLAG_IS_DEFAULT(UseAOT) && UseAOT) { + // If user enabled AOT but ThreadLocalHandshakes is at default set it to false. + log_debug(ergo)("Disabling ThreadLocalHandshakes for UseAOT."); + FLAG_SET_ERGO(bool, ThreadLocalHandshakes, false); + } else if (jvmci_enabled){ + // If user enabled JVMCI but ThreadLocalHandshakes is at default set it to false. + log_debug(ergo)("Disabling ThreadLocalHandshakes for EnableJVMCI/UseJVMCICompiler."); + FLAG_SET_ERGO(bool, ThreadLocalHandshakes, false); + } } } + if (FLAG_IS_DEFAULT(ThreadLocalHandshakes) || !SafepointMechanism::supports_thread_local_poll()) { + log_debug(ergo)("ThreadLocalHandshakes %s", ThreadLocalHandshakes ? "enabled." : "disabled."); + } else { + log_info(ergo)("ThreadLocalHandshakes %s", ThreadLocalHandshakes ? "enabled." : "disabled."); + } return JNI_OK; } --- old/src/hotspot/share/runtime/globals.hpp 2017-10-30 15:12:31.503403722 +0100 +++ new/src/hotspot/share/runtime/globals.hpp 2017-10-30 15:12:31.248395341 +0100 @@ -598,7 +598,7 @@ develop(bool, CleanChunkPoolAsync, true, \ "Clean the chunk pool asynchronously") \ \ - product(bool, ThreadLocalHandshakes, false, \ + product(bool, ThreadLocalHandshakes, true, \ "Use thread-local polls instead of global poll for safepoints.") \ constraint(ThreadLocalHandshakesConstraintFunc,AfterErgo) \ \