8233520: Shenandoah: do not sleep when thread is attaching
authorshade
Mon, 04 Nov 2019 19:40:58 +0100
changeset 58918 c727d5d4c22e
parent 58917 33f9271b3167
child 58919 1d1f9c43138f
8233520: Shenandoah: do not sleep when thread is attaching Reviewed-by: rkennke
src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp	Mon Nov 04 13:13:34 2019 -0500
+++ b/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp	Mon Nov 04 19:40:58 2019 +0100
@@ -238,6 +238,15 @@
     return;
   }
 
+  // Threads that are attaching should not block at all: they are not
+  // fully initialized yet. Calling sleep() on them would be awkward.
+  // This is probably the path that allocates the thread oop itself.
+  // Forcefully claim without waiting.
+  if (JavaThread::current()->is_attaching_via_jni()) {
+    claim_for_alloc(words, true);
+    return;
+  }
+
   size_t max = ShenandoahPacingMaxDelay;
   double start = os::elapsedTime();