From e133d9b73125ea907111a2a869ed824aca9bfa3d Mon Sep 17 00:00:00 2001 From: Axel Boldt-Christmas Date: Thu, 9 Oct 2025 08:03:24 +0000 Subject: [PATCH 1/4] 8369482: JVMTI + Loom: JDK-8368159 introduced safepoint poll in disallowed state --- src/hotspot/share/runtime/continuationFreezeThaw.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/runtime/continuationFreezeThaw.cpp b/src/hotspot/share/runtime/continuationFreezeThaw.cpp index 33b4f2bf488a0..20b8ef0955159 100644 --- a/src/hotspot/share/runtime/continuationFreezeThaw.cpp +++ b/src/hotspot/share/runtime/continuationFreezeThaw.cpp @@ -42,6 +42,7 @@ #include "oops/objArrayOop.inline.hpp" #include "oops/oopsHierarchy.hpp" #include "oops/stackChunkOop.inline.hpp" +#include "prims/jvmtiExport.hpp" #include "prims/jvmtiThreadState.hpp" #include "runtime/arguments.hpp" #include "runtime/continuation.hpp" @@ -1626,11 +1627,14 @@ static void invalidate_jvmti_stack(JavaThread* thread) { } static void jvmti_yield_cleanup(JavaThread* thread, ContinuationWrapper& cont) { - if (JvmtiExport::has_frame_pops(thread)) { - int num_frames = num_java_frames(cont); - + if (JvmtiExport::can_post_frame_pop()) { + // JvmtiExport::has_frame_pops and JvmtiExport::continuation_yield_cleanup may safepoint ContinuationWrapper::SafepointOp so(Thread::current(), cont); - JvmtiExport::continuation_yield_cleanup(JavaThread::current(), num_frames); + + if (JvmtiExport::has_frame_pops(thread)) { + int num_frames = num_java_frames(cont); + JvmtiExport::continuation_yield_cleanup(JavaThread::current(), num_frames); + } } invalidate_jvmti_stack(thread); } From 2c7a2c3b2ce1d23162878259a48059abe5c3ece2 Mon Sep 17 00:00:00 2001 From: Axel Boldt-Christmas Date: Fri, 10 Oct 2025 06:24:40 +0000 Subject: [PATCH 2/4] Revert "8369482: JVMTI + Loom: JDK-8368159 introduced safepoint poll in disallowed state" This reverts commit e133d9b73125ea907111a2a869ed824aca9bfa3d. --- src/hotspot/share/runtime/continuationFreezeThaw.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/hotspot/share/runtime/continuationFreezeThaw.cpp b/src/hotspot/share/runtime/continuationFreezeThaw.cpp index 20b8ef0955159..33b4f2bf488a0 100644 --- a/src/hotspot/share/runtime/continuationFreezeThaw.cpp +++ b/src/hotspot/share/runtime/continuationFreezeThaw.cpp @@ -42,7 +42,6 @@ #include "oops/objArrayOop.inline.hpp" #include "oops/oopsHierarchy.hpp" #include "oops/stackChunkOop.inline.hpp" -#include "prims/jvmtiExport.hpp" #include "prims/jvmtiThreadState.hpp" #include "runtime/arguments.hpp" #include "runtime/continuation.hpp" @@ -1627,14 +1626,11 @@ static void invalidate_jvmti_stack(JavaThread* thread) { } static void jvmti_yield_cleanup(JavaThread* thread, ContinuationWrapper& cont) { - if (JvmtiExport::can_post_frame_pop()) { - // JvmtiExport::has_frame_pops and JvmtiExport::continuation_yield_cleanup may safepoint - ContinuationWrapper::SafepointOp so(Thread::current(), cont); + if (JvmtiExport::has_frame_pops(thread)) { + int num_frames = num_java_frames(cont); - if (JvmtiExport::has_frame_pops(thread)) { - int num_frames = num_java_frames(cont); - JvmtiExport::continuation_yield_cleanup(JavaThread::current(), num_frames); - } + ContinuationWrapper::SafepointOp so(Thread::current(), cont); + JvmtiExport::continuation_yield_cleanup(JavaThread::current(), num_frames); } invalidate_jvmti_stack(thread); } From 4ec7ce98acf4154d93978c3e38ecb59cefda5260 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Fri, 10 Oct 2025 06:21:07 +0000 Subject: [PATCH 3/4] sspitsyn patch --- src/hotspot/share/prims/jvmtiExport.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/prims/jvmtiExport.cpp b/src/hotspot/share/prims/jvmtiExport.cpp index 077b3fec505ec..fa6ede86cd9a4 100644 --- a/src/hotspot/share/prims/jvmtiExport.cpp +++ b/src/hotspot/share/prims/jvmtiExport.cpp @@ -1694,7 +1694,7 @@ bool JvmtiExport::has_frame_pops(JavaThread* thread) { if (!can_post_frame_pop()) { return false; } - JvmtiThreadState *state = get_jvmti_thread_state(thread); + JvmtiThreadState *state = thread->jvmti_thread_state(); if (state == nullptr) { return false; } @@ -1713,7 +1713,7 @@ void JvmtiExport::continuation_yield_cleanup(JavaThread* thread, jint continuati } assert(thread == JavaThread::current(), "must be"); - JvmtiThreadState *state = get_jvmti_thread_state(thread); + JvmtiThreadState *state = thread->jvmti_thread_state(); if (state == nullptr) { return; } From d5a2cc0c342390ab833a8ba32349b8205cdd2379 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Mon, 13 Oct 2025 08:26:51 +0000 Subject: [PATCH 4/4] Check !cont.entry()->is_virtual_thread() --- src/hotspot/share/runtime/continuationFreezeThaw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/runtime/continuationFreezeThaw.cpp b/src/hotspot/share/runtime/continuationFreezeThaw.cpp index 33b4f2bf488a0..3e509e71551da 100644 --- a/src/hotspot/share/runtime/continuationFreezeThaw.cpp +++ b/src/hotspot/share/runtime/continuationFreezeThaw.cpp @@ -1626,7 +1626,7 @@ static void invalidate_jvmti_stack(JavaThread* thread) { } static void jvmti_yield_cleanup(JavaThread* thread, ContinuationWrapper& cont) { - if (JvmtiExport::has_frame_pops(thread)) { + if (!cont.entry()->is_virtual_thread() && JvmtiExport::has_frame_pops(thread)) { int num_frames = num_java_frames(cont); ContinuationWrapper::SafepointOp so(Thread::current(), cont);