From 030102454a5ea9ea6167499dd06d6f4c55eaa72a Mon Sep 17 00:00:00 2001 From: Tomas Zezula Date: Sun, 18 Aug 2024 14:53:15 +0200 Subject: [PATCH] JDK-8338538: [JVMCI] Allow HotSpotJVMCIRuntime#getJObjectValue to be called by host compiler threads. --- src/hotspot/share/jvmci/jvmciCompilerToVM.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp index af72322ff4bf2..5f1de1c9221ef 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp @@ -710,8 +710,9 @@ C2V_END C2V_VMENTRY_0(jlong, getJObjectValue, (JNIEnv* env, jobject, jobject constant_jobject)) requireNotInHotSpot("getJObjectValue", JVMCI_CHECK_0); - if (!THREAD->has_last_Java_frame()) { - JVMCI_THROW_MSG_0(IllegalStateException, err_msg("Cannot call getJObjectValue without Java frame anchor")); + // Ensure that we are not using the top-most JNIHandleBlock, which is never released. + if (!THREAD->has_last_Java_frame() && THREAD->active_handles()->pop_frame_link() == nullptr) { + JVMCI_THROW_MSG_0(IllegalStateException, err_msg("Cannot call getJObjectValue without Java frame anchor or a pushed JNI handle block")); } JVMCIObject constant = JVMCIENV->wrap(constant_jobject); Handle constant_value = JVMCIENV->asConstant(constant, JVMCI_CHECK_0);