< prev index next >

src/hotspot/share/runtime/thread.cpp

Print this page
rev 47413 : Introduce SafepointMechanism
rev 47414 : Move polling page allocation to SafepointMechanism initialization
rev 47415 : Add Thread Local handshakes and thread local polling

@@ -63,10 +63,11 @@
 #include "runtime/commandLineFlagWriteableList.hpp"
 #include "runtime/commandLineFlagRangeList.hpp"
 #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"
 #include "runtime/javaCalls.hpp"
 #include "runtime/jniPeriodicChecker.hpp"

@@ -1493,10 +1494,14 @@
   _popframe_condition = popframe_inactive;
   _popframe_preserved_args = NULL;
   _popframe_preserved_args_size = 0;
   _frames_to_pop_failed_realloc = 0;
 
+  if (SafepointMechanism::uses_thread_local_poll()) {
+    SafepointMechanism::initialize_header(this);
+  }
+
   pd_initialize();
 }
 
 #if INCLUDE_ALL_GCS
 SATBMarkQueueSet JavaThread::_satb_mark_queue_set;

@@ -1909,10 +1914,15 @@
     exit_type == JavaThread::normal_exit ? "exiting" : "detaching",
     os::current_thread_id());
 
   // 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
 // Flush G1-related queues.
 void JavaThread::flush_barrier_queues() {
< prev index next >