diff -r cf127be65014 -r 0ce0ac68ace7 src/hotspot/share/runtime/thread.cpp --- a/src/hotspot/share/runtime/thread.cpp Sat Nov 11 01:21:09 2017 +0100 +++ b/src/hotspot/share/runtime/thread.cpp Thu Aug 31 10:00:28 2017 +0200 @@ -65,6 +65,7 @@ #include "runtime/deoptimization.hpp" #include "runtime/frame.inline.hpp" #include "runtime/globals.hpp" +#include "runtime/handshake.hpp" #include "runtime/init.hpp" #include "runtime/interfaceSupport.hpp" #include "runtime/java.hpp" @@ -77,6 +78,7 @@ #include "runtime/orderAccess.inline.hpp" #include "runtime/osThread.hpp" #include "runtime/safepoint.hpp" +#include "runtime/safepointMechanism.inline.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/statSampler.hpp" #include "runtime/stubRoutines.hpp" @@ -1494,6 +1496,10 @@ _popframe_preserved_args_size = 0; _frames_to_pop_failed_realloc = 0; + if (SafepointMechanism::uses_thread_local_poll()) { + SafepointMechanism::initialize_header(this); + } + pd_initialize(); } @@ -1910,6 +1916,11 @@ // Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread Threads::remove(this); + + // If someone set a handshake on us just as we entered exit path, we simple cancel it. + if (ThreadLocalHandshakes) { + cancel_handshake(); + } } #if INCLUDE_ALL_GCS @@ -2372,11 +2383,7 @@ InterfaceSupport::serialize_thread_state_with_handler(thread); } - if (SafepointSynchronize::do_call_back()) { - // If we are safepointing, then block the caller which may not be - // the same as the target thread (see above). - SafepointSynchronize::block(curJT); - } + SafepointMechanism::block_if_requested(curJT); if (thread->is_deopt_suspend()) { thread->clear_deopt_suspend(); @@ -3551,6 +3558,8 @@ // Timing (must come after argument parsing) TraceTime timer("Create VM", TRACETIME_LOG(Info, startuptime)); + SafepointMechanism::initialize(); + // Initialize the os module after parsing the args jint os_init_2_result = os::init_2(); if (os_init_2_result != JNI_OK) return os_init_2_result;