From 89cf06aac90f364872c703b1b4dfdd0989ac4cfe Mon Sep 17 00:00:00 2001 From: Tobi Ajila Date: Mon, 8 Jun 2026 16:24:54 -0400 Subject: [PATCH 1/2] Add pinning checks to blocking operations co-author: Ravali Yatham Signed-off-by: Tobi Ajila --- runtime/vm/BytecodeInterpreter.hpp | 7 +- runtime/vm/monhelpers.c | 204 +++++++++++++++-------------- 2 files changed, 110 insertions(+), 101 deletions(-) diff --git a/runtime/vm/BytecodeInterpreter.hpp b/runtime/vm/BytecodeInterpreter.hpp index a672983ca59..5e06ba8d04d 100644 --- a/runtime/vm/BytecodeInterpreter.hpp +++ b/runtime/vm/BytecodeInterpreter.hpp @@ -1207,11 +1207,14 @@ class INTERPRETER_CLASS enterObjectMonitor(REGISTER_ARGS_LIST, j9object_t obj) { UDATA rc = (UDATA)obj; +#if JAVA_SPEC_VERSION >= 24 + bool pinningSupportEnabled = J9_ARE_ANY_BITS_SET(_vm->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION); +#endif /* JAVA_SPEC_VERSION >= 24 */ if (!VM_ObjectMonitor::inlineFastObjectMonitorEnter(_currentThread, obj)) { rc = objectMonitorEnterNonBlocking(_currentThread, obj); if (J9_OBJECT_MONITOR_BLOCKING == rc) { #if JAVA_SPEC_VERSION >= 24 - if (VM_ContinuationHelpers::isYieldableVirtualThread(_currentThread)) { + if (pinningSupportEnabled && VM_ContinuationHelpers::isYieldableVirtualThread(_currentThread)) { /* Try to yield the virtual thread if it will be blocked. */ updateVMStruct(REGISTER_ARGS); rc = preparePinnedVirtualThreadForUnmount(_currentThread, obj, false); @@ -1225,7 +1228,7 @@ class INTERPRETER_CLASS } } #if JAVA_SPEC_VERSION >= 24 - if (rc == (UDATA)obj) { + if (pinningSupportEnabled && (rc == (UDATA)obj)) { J9VMContinuation *continuation = _currentThread->currentContinuation; if (NULL != continuation) { if (J9_ARE_ALL_BITS_SET(continuation->runtimeFlags, J9VM_CONTINUATION_RUNTIMEFLAG_JVMTI_CONTENDED_MONITOR_ENTER_RECORDED)) { diff --git a/runtime/vm/monhelpers.c b/runtime/vm/monhelpers.c index b2d8ae63b0b..52d6303ccd2 100644 --- a/runtime/vm/monhelpers.c +++ b/runtime/vm/monhelpers.c @@ -71,6 +71,9 @@ objectMonitorExit(J9VMThread* vmStruct, j9object_t object) lock = J9_LOAD_LOCKWORD(vmStruct, lockEA); if (J9_FLATLOCK_OWNER(lock) == vmStruct) { +#if JAVA_SPEC_VERSION >= 24 + J9JavaVM *vm = vmStruct->javaVM; +#endif /* JAVA_SPEC_VERSION >= 24 */ /* The current thread owns the monitor, and it's a flat lock. */ UDATA count = (UDATA)lock & OBJECT_HEADER_LOCK_BITS_MASK; /* @@ -96,133 +99,136 @@ objectMonitorExit(J9VMThread* vmStruct, j9object_t object) #endif /* if !(defined(AIXPPC) || defined(LINUXPPC)) */ #endif /* ifndef J9VM_THR_LOCK_RESERVATION */ #if JAVA_SPEC_VERSION >= 24 - if (OBJECT_HEADER_LOCK_FLC == count) { - /* FLC set, non-recursive. */ - J9ObjectMonitor *objectMonitor = objectMonitorInflate(vmStruct, object, lock); - - if (NULL == objectMonitor) { - /* Out of memory - impossible? */ - monitorExitWriteBarrier(); - J9_STORE_LOCKWORD(vmStruct, lockEA, 0); - } else { - omrthread_monitor_t monitor = objectMonitor->monitor; - J9JavaVM *vm = vmStruct->javaVM; + if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION)) { + if (OBJECT_HEADER_LOCK_FLC == count) { + /* FLC set, non-recursive. */ + J9ObjectMonitor *objectMonitor = objectMonitorInflate(vmStruct, object, lock); + + if (NULL == objectMonitor) { + /* Out of memory - impossible? */ + monitorExitWriteBarrier(); + J9_STORE_LOCKWORD(vmStruct, lockEA, 0); + } else { + omrthread_monitor_t monitor = objectMonitor->monitor; - TRIGGER_J9HOOK_VM_MONITOR_CONTENDED_EXIT(vm->hookInterface, vmStruct, monitor); + TRIGGER_J9HOOK_VM_MONITOR_CONTENDED_EXIT(vm->hookInterface, vmStruct, monitor); - omrthread_monitor_exit(monitor); + omrthread_monitor_exit(monitor); - if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION) - && (0 != objectMonitor->virtualThreadWaitCount) + if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION) + && (0 != objectMonitor->virtualThreadWaitCount) + ) { + J9VM_SEND_VIRTUAL_UNBLOCKER_THREAD_SIGNAL(vm); + } + } + } else { + j9objectmonitor_t newLock = 0; + BOOLEAN casSuccess = FALSE; + if (0x00 == count) { + /* Just release the flatlock. */ + } else if (J9_ARE_ANY_BITS_SET(count, OBJECT_HEADER_LOCK_LEARNING) + && J9_ARE_ANY_BITS_SET(count, OBJECT_HEADER_LOCK_LEARNING_RECURSION_MASK) ) { - J9VM_SEND_VIRTUAL_UNBLOCKER_THREAD_SIGNAL(vm); + /* Learning state case. */ + newLock = lock - OBJECT_HEADER_LOCK_LEARNING_FIRST_RECURSION_BIT; + } else if (J9_ARE_ANY_BITS_SET(count, OBJECT_HEADER_LOCK_LEARNING)) { + /* Lock is in Learning state but unowned. + * (if it were owned it would have been caught by the first Learning state check) + */ + goto done; + } else if (count >= OBJECT_HEADER_LOCK_FIRST_RECURSION_BIT) { + /* Just decrement the flatlock recursion count. */ + newLock = lock - OBJECT_HEADER_LOCK_FIRST_RECURSION_BIT; +#ifdef J9VM_THR_LOCK_RESERVATION + } else if (J9_ARE_ANY_BITS_SET(count, OBJECT_HEADER_LOCK_RESERVED)) { + /* Lock is reserved but unowned. + * (if it were owned the count would be >= OBJECT_HEADER_LOCK_FIRST_RECURSION_BIT) + */ + Trc_VM_objectMonitorExit_Exit_ReservedButUnownedFlatLock(vmStruct, lock, object); + goto done; +#endif /* J9VM_THR_LOCK_RESERVATION */ + } + + monitorExitWriteBarrier(); + if (J9VMTHREAD_COMPRESS_OBJECT_REFERENCES(vmStruct)) { + casSuccess = (lock == compareAndSwapU32((uint32_t *)lockEA, (uint32_t)lock, (uint32_t)newLock)); + } else { + casSuccess = (lock == compareAndSwapUDATA((uintptr_t *)lockEA, (uintptr_t)lock, (uintptr_t)newLock)); + } + + if (!casSuccess) { + /* Another thread has attempted to get the lock and may have update the FLC flag. */ + goto restart; } } - } else { - j9objectmonitor_t newLock = 0; - BOOLEAN casSuccess = FALSE; + } else +#endif /* JAVA_SPEC_VERSION >= 24 */ + { if (0x00 == count) { /* Just release the flatlock. */ + monitorExitWriteBarrier(); + J9_STORE_LOCKWORD(vmStruct, lockEA, 0); } else if (J9_ARE_ANY_BITS_SET(count, OBJECT_HEADER_LOCK_LEARNING) && J9_ARE_ANY_BITS_SET(count, OBJECT_HEADER_LOCK_LEARNING_RECURSION_MASK) ) { /* Learning state case. */ - newLock = lock - OBJECT_HEADER_LOCK_LEARNING_FIRST_RECURSION_BIT; + BOOLEAN casSuccess = FALSE; + + if (1 == J9_FLATLOCK_COUNT(lock)) { + /* If RC field is 1, this fully unlocks the object so a write barrier is needed. */ + monitorExitWriteBarrier(); + } + + if (J9VMTHREAD_COMPRESS_OBJECT_REFERENCES(vmStruct)) { + casSuccess = (lock == compareAndSwapU32((uint32_t*)lockEA, (uint32_t)lock, + (uint32_t)(lock - OBJECT_HEADER_LOCK_LEARNING_FIRST_RECURSION_BIT))); + } else { + casSuccess = (lock == compareAndSwapUDATA((uintptr_t*)lockEA, (uintptr_t)lock, + (uintptr_t)(lock - OBJECT_HEADER_LOCK_LEARNING_FIRST_RECURSION_BIT))); + } + + if (!casSuccess) { + /* + * Another thread has attempted to get the lock and atomically changed the state to Flat. + * Start over and read the new lockword. The lock can not go back to Learning so this will + * only happen once. + */ + goto restart; + } } else if (J9_ARE_ANY_BITS_SET(count, OBJECT_HEADER_LOCK_LEARNING)) { /* Lock is in Learning state but unowned. - * (if it were owned it would have been caught by the first Learning state check) - */ + * (if it were owned it would have been caught by the first Learning state check) + */ + Trc_VM_objectMonitorExit_Exit_LearningStateUnowned(vmStruct, lock, object); goto done; } else if (count >= OBJECT_HEADER_LOCK_FIRST_RECURSION_BIT) { /* Just decrement the flatlock recursion count. */ - newLock = lock - OBJECT_HEADER_LOCK_FIRST_RECURSION_BIT; + lock -= OBJECT_HEADER_LOCK_FIRST_RECURSION_BIT; + J9_STORE_LOCKWORD(vmStruct, lockEA, lock); #ifdef J9VM_THR_LOCK_RESERVATION } else if (J9_ARE_ANY_BITS_SET(count, OBJECT_HEADER_LOCK_RESERVED)) { /* Lock is reserved but unowned. - * (if it were owned the count would be >= OBJECT_HEADER_LOCK_FIRST_RECURSION_BIT) - */ + * (if it were owned the count would be >= OBJECT_HEADER_LOCK_FIRST_RECURSION_BIT) + */ Trc_VM_objectMonitorExit_Exit_ReservedButUnownedFlatLock(vmStruct, lock, object); goto done; #endif /* J9VM_THR_LOCK_RESERVATION */ - } - - monitorExitWriteBarrier(); - if (J9VMTHREAD_COMPRESS_OBJECT_REFERENCES(vmStruct)) { - casSuccess = (lock == compareAndSwapU32((uint32_t *)lockEA, (uint32_t)lock, (uint32_t)newLock)); } else { - casSuccess = (lock == compareAndSwapUDATA((uintptr_t *)lockEA, (uintptr_t)lock, (uintptr_t)newLock)); - } + /* FLC set, non-recursive. */ + J9ObjectMonitor *objectMonitor = objectMonitorInflate(vmStruct, object, lock); - if (!casSuccess) { - /* Another thread has attempted to get the lock and may have update the FLC flag. */ - goto restart; + if (NULL == objectMonitor) { + /* Out of memory - impossible? */ + monitorExitWriteBarrier(); + J9_STORE_LOCKWORD(vmStruct, lockEA, 0); + } else { + omrthread_monitor_t monitor = objectMonitor->monitor; + TRIGGER_J9HOOK_VM_MONITOR_CONTENDED_EXIT(vmStruct->javaVM->hookInterface, vmStruct, monitor); + omrthread_monitor_exit(monitor); + } } } -#else /* JAVA_SPEC_VERSION >= 24 */ - if (0x00 == count) { - /* Just release the flatlock. */ - monitorExitWriteBarrier(); - J9_STORE_LOCKWORD(vmStruct, lockEA, 0); - } else if (J9_ARE_ANY_BITS_SET(count, OBJECT_HEADER_LOCK_LEARNING) - && J9_ARE_ANY_BITS_SET(count, OBJECT_HEADER_LOCK_LEARNING_RECURSION_MASK) - ) { - /* Learning state case. */ - BOOLEAN casSuccess = FALSE; - - if (1 == J9_FLATLOCK_COUNT(lock)) { - /* If RC field is 1, this fully unlocks the object so a write barrier is needed. */ - monitorExitWriteBarrier(); - } - - if (J9VMTHREAD_COMPRESS_OBJECT_REFERENCES(vmStruct)) { - casSuccess = (lock == compareAndSwapU32((uint32_t*)lockEA, (uint32_t)lock, - (uint32_t)(lock - OBJECT_HEADER_LOCK_LEARNING_FIRST_RECURSION_BIT))); - } else { - casSuccess = (lock == compareAndSwapUDATA((uintptr_t*)lockEA, (uintptr_t)lock, - (uintptr_t)(lock - OBJECT_HEADER_LOCK_LEARNING_FIRST_RECURSION_BIT))); - } - if (!casSuccess) { - /* - * Another thread has attempted to get the lock and atomically changed the state to Flat. - * Start over and read the new lockword. The lock can not go back to Learning so this will - * only happen once. - */ - goto restart; - } - } else if (J9_ARE_ANY_BITS_SET(count, OBJECT_HEADER_LOCK_LEARNING)) { - /* Lock is in Learning state but unowned. - * (if it were owned it would have been caught by the first Learning state check) - */ - Trc_VM_objectMonitorExit_Exit_LearningStateUnowned(vmStruct, lock, object); - goto done; - } else if (count >= OBJECT_HEADER_LOCK_FIRST_RECURSION_BIT) { - /* Just decrement the flatlock recursion count. */ - lock -= OBJECT_HEADER_LOCK_FIRST_RECURSION_BIT; - J9_STORE_LOCKWORD(vmStruct, lockEA, lock); -#ifdef J9VM_THR_LOCK_RESERVATION - } else if (J9_ARE_ANY_BITS_SET(count, OBJECT_HEADER_LOCK_RESERVED)) { - /* Lock is reserved but unowned. - * (if it were owned the count would be >= OBJECT_HEADER_LOCK_FIRST_RECURSION_BIT) - */ - Trc_VM_objectMonitorExit_Exit_ReservedButUnownedFlatLock(vmStruct, lock, object); - goto done; -#endif /* J9VM_THR_LOCK_RESERVATION */ - } else { - /* FLC set, non-recursive. */ - J9ObjectMonitor *objectMonitor = objectMonitorInflate(vmStruct, object, lock); - - if (NULL == objectMonitor) { - /* Out of memory - impossible? */ - monitorExitWriteBarrier(); - J9_STORE_LOCKWORD(vmStruct, lockEA, 0); - } else { - omrthread_monitor_t monitor = objectMonitor->monitor; - TRIGGER_J9HOOK_VM_MONITOR_CONTENDED_EXIT(vmStruct->javaVM->hookInterface, vmStruct, monitor); - omrthread_monitor_exit(monitor); - } - } -#endif /* JAVA_SPEC_VERSION >= 24 */ Trc_VM_objectMonitorExit_Exit_FCBSet(vmStruct); rc = 0; goto done; From 845ef4e894c457ad45642b769905bcab63c1568a Mon Sep 17 00:00:00 2001 From: Tobi Ajila Date: Mon, 8 Jun 2026 14:23:45 -0400 Subject: [PATCH 2/2] Add check for live Vthreads in pinned checks Signed-off-by: Tobi Ajila --- runtime/oti/j9.h | 8 ++++++++ runtime/oti/j9consts.h | 1 + runtime/vm/BytecodeInterpreter.hpp | 15 +++++++-------- runtime/vm/ContinuationHelpers.cpp | 2 ++ runtime/vm/FastJNI_java_lang_Object.cpp | 4 ++-- runtime/vm/monhelpers.c | 6 +++--- runtime/vm/threadhelp.cpp | 2 +- 7 files changed, 24 insertions(+), 14 deletions(-) diff --git a/runtime/oti/j9.h b/runtime/oti/j9.h index 5eb8530c232..2cdecffac91 100644 --- a/runtime/oti/j9.h +++ b/runtime/oti/j9.h @@ -450,6 +450,14 @@ static_assert((LITERAL_STRLEN(J9_UNMODIFIABLE_CLASS_ANNOTATION) < (size_t)'/'), } while (0) #endif /* JAVA_SPEC_VERSION >= 24 */ +#if JAVA_SPEC_VERSION >= 24 +#define J9VM_ARE_PINNED_YIELDABLE_VIRTUALTHREADS_ACTIVE(vm) \ + (J9_ARE_ANY_BITS_SET((vm)->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION) \ + && J9_ARE_ANY_BITS_SET((vm)->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION)) +#else +#define J9VM_ARE_PINNED_YIELDABLE_VIRTUALTHREADS_ACTIVE(vm) (1 == 0) +#endif + #define DIR_LIB_STR "lib" #if defined(J9VM_OPT_JFR) diff --git a/runtime/oti/j9consts.h b/runtime/oti/j9consts.h index 8e245b37a53..d521db1d696 100644 --- a/runtime/oti/j9consts.h +++ b/runtime/oti/j9consts.h @@ -391,6 +391,7 @@ extern "C" { #define J9_EXTENDED_RUNTIME3_GCCONTAINERHEURISTICS 0x400 #define J9_EXTENDED_RUNTIME3_USE_VECTOR_LENGTH_256 0x800 #define J9_EXTENDED_RUNTIME3_USE_VECTOR_LENGTH_512 0x1000 +#define J9_EXTENDED_RUNTIME3_VTHREAD_CREATED 0x2000 #define J9_OBJECT_HEADER_AGE_DEFAULT 0xA /* OBJECT_HEADER_AGE_DEFAULT */ diff --git a/runtime/vm/BytecodeInterpreter.hpp b/runtime/vm/BytecodeInterpreter.hpp index 5e06ba8d04d..7eca2f89d74 100644 --- a/runtime/vm/BytecodeInterpreter.hpp +++ b/runtime/vm/BytecodeInterpreter.hpp @@ -1207,14 +1207,11 @@ class INTERPRETER_CLASS enterObjectMonitor(REGISTER_ARGS_LIST, j9object_t obj) { UDATA rc = (UDATA)obj; -#if JAVA_SPEC_VERSION >= 24 - bool pinningSupportEnabled = J9_ARE_ANY_BITS_SET(_vm->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION); -#endif /* JAVA_SPEC_VERSION >= 24 */ if (!VM_ObjectMonitor::inlineFastObjectMonitorEnter(_currentThread, obj)) { rc = objectMonitorEnterNonBlocking(_currentThread, obj); if (J9_OBJECT_MONITOR_BLOCKING == rc) { #if JAVA_SPEC_VERSION >= 24 - if (pinningSupportEnabled && VM_ContinuationHelpers::isYieldableVirtualThread(_currentThread)) { + if (_pinningSupportEnabled && VM_ContinuationHelpers::isYieldableVirtualThread(_currentThread)) { /* Try to yield the virtual thread if it will be blocked. */ updateVMStruct(REGISTER_ARGS); rc = preparePinnedVirtualThreadForUnmount(_currentThread, obj, false); @@ -1228,7 +1225,7 @@ class INTERPRETER_CLASS } } #if JAVA_SPEC_VERSION >= 24 - if (pinningSupportEnabled && (rc == (UDATA)obj)) { + if (_pinningSupportEnabled && (rc == (UDATA)obj)) { J9VMContinuation *continuation = _currentThread->currentContinuation; if (NULL != continuation) { if (J9_ARE_ALL_BITS_SET(continuation->runtimeFlags, J9VM_CONTINUATION_RUNTIMEFLAG_JVMTI_CONTENDED_MONITOR_ENTER_RECORDED)) { @@ -3044,7 +3041,7 @@ class INTERPRETER_CLASS { if (VM_ObjectMonitor::getMonitorForNotify(_currentThread, receiver, &monitorPtr, true)) { #if JAVA_SPEC_VERSION >= 24 - if (J9_ARE_ANY_BITS_SET(_vm->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION)) { + if (J9VM_ARE_PINNED_YIELDABLE_VIRTUALTHREADS_ACTIVE(_vm)) { j9objectmonitor_t lock = 0; j9objectmonitor_t *lockEA = NULL; J9ObjectMonitor *objectMonitor = NULL; @@ -6004,7 +6001,7 @@ class INTERPRETER_CLASS buildInternalNativeStackFrame(REGISTER_ARGS); updateVMStruct(REGISTER_ARGS); #if JAVA_SPEC_VERSION >= 24 - if (J9_ARE_ANY_BITS_SET(_vm->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION) + if (_pinningSupportEnabled) && (_currentThread->ownedMonitorCount > 0) && !isFinished ) { @@ -10395,7 +10392,9 @@ class INTERPRETER_CLASS #if defined(LOCAL_LITERALS) J9Method *_literals = vmThread->literals; #endif - +#if JAVA_SPEC_VERSION >= 24 + const bool _pinningSupportEnabled = J9_ARE_ANY_BITS_SET(vmThread->javaVM->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION +#endif /* JAVA_SPEC_VERSION >= 24 */ DEBUG_MUST_HAVE_VM_ACCESS(vmThread); vmThread->jitStackFrameFlags = 0; diff --git a/runtime/vm/ContinuationHelpers.cpp b/runtime/vm/ContinuationHelpers.cpp index 8e4ee78e205..19fe39af7f2 100644 --- a/runtime/vm/ContinuationHelpers.cpp +++ b/runtime/vm/ContinuationHelpers.cpp @@ -45,6 +45,8 @@ createContinuation(J9VMThread *currentThread, j9object_t continuationObject) I_64 start = j9time_hires_clock(); #endif /* defined(J9VM_PROF_CONTINUATION_ALLOCATION) */ + vm->extendedRuntimeFlags3 |= J9_EXTENDED_RUNTIME3_VTHREAD_CREATED; + /* First check if local cache is available. */ if (NULL != currentThread->continuationT1Cache) { for (U_32 i = 0; i < vm->continuationT1Size; i++) { diff --git a/runtime/vm/FastJNI_java_lang_Object.cpp b/runtime/vm/FastJNI_java_lang_Object.cpp index fb4e9fda921..04dafc7d9ac 100644 --- a/runtime/vm/FastJNI_java_lang_Object.cpp +++ b/runtime/vm/FastJNI_java_lang_Object.cpp @@ -62,7 +62,7 @@ Fast_java_lang_Object_notifyAll(J9VMThread *currentThread, j9object_t receiverOb if (VM_ObjectMonitor::getMonitorForNotify(currentThread, receiverObject, &monitorPtr, true)) { #if JAVA_SPEC_VERSION >= 24 J9JavaVM *vm = currentThread->javaVM; - if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION)) { + if (J9VM_ARE_PINNED_YIELDABLE_VIRTUALTHREADS_ACTIVE(vm)) { j9objectmonitor_t lock = 0; j9objectmonitor_t *lockEA = NULL; J9ObjectMonitor *objectMonitor = NULL; @@ -107,7 +107,7 @@ Fast_java_lang_Object_notify(J9VMThread *currentThread, j9object_t receiverObjec if (VM_ObjectMonitor::getMonitorForNotify(currentThread, receiverObject, &monitorPtr, true)) { #if JAVA_SPEC_VERSION >= 24 J9JavaVM *vm = currentThread->javaVM; - if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION)) { + if (J9VM_ARE_PINNED_YIELDABLE_VIRTUALTHREADS_ACTIVE(vm)) { j9objectmonitor_t lock = 0; j9objectmonitor_t *lockEA = NULL; J9ObjectMonitor *objectMonitor = NULL; diff --git a/runtime/vm/monhelpers.c b/runtime/vm/monhelpers.c index 52d6303ccd2..da3e8218f30 100644 --- a/runtime/vm/monhelpers.c +++ b/runtime/vm/monhelpers.c @@ -99,7 +99,7 @@ objectMonitorExit(J9VMThread* vmStruct, j9object_t object) #endif /* if !(defined(AIXPPC) || defined(LINUXPPC)) */ #endif /* ifndef J9VM_THR_LOCK_RESERVATION */ #if JAVA_SPEC_VERSION >= 24 - if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION)) { + if (J9VM_ARE_PINNED_YIELDABLE_VIRTUALTHREADS_ACTIVE(vm)) { if (OBJECT_HEADER_LOCK_FLC == count) { /* FLC set, non-recursive. */ J9ObjectMonitor *objectMonitor = objectMonitorInflate(vmStruct, object, lock); @@ -115,7 +115,7 @@ objectMonitorExit(J9VMThread* vmStruct, j9object_t object) omrthread_monitor_exit(monitor); - if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION) + if (J9VM_ARE_PINNED_YIELDABLE_VIRTUALTHREADS_ACTIVE(vm) && (0 != objectMonitor->virtualThreadWaitCount) ) { J9VM_SEND_VIRTUAL_UNBLOCKER_THREAD_SIGNAL(vm); @@ -314,7 +314,7 @@ objectMonitorExit(J9VMThread* vmStruct, j9object_t object) #endif /* JAVA_SPEC_VERSION >= 24 */ rc = omrthread_monitor_exit((omrthread_monitor_t)monitor); #if JAVA_SPEC_VERSION >= 24 - if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION) + if (J9VM_ARE_PINNED_YIELDABLE_VIRTUALTHREADS_ACTIVE(vm) && (0 != objectMonitor->virtualThreadWaitCount) ) { J9VM_SEND_VIRTUAL_UNBLOCKER_THREAD_SIGNAL(vm); diff --git a/runtime/vm/threadhelp.cpp b/runtime/vm/threadhelp.cpp index bc9bc8b91fc..218ad0dcaed 100644 --- a/runtime/vm/threadhelp.cpp +++ b/runtime/vm/threadhelp.cpp @@ -465,7 +465,7 @@ notifyUnblocker(void *userData) { J9VMThread *currentThread = (J9VMThread *)userData; J9JavaVM *vm = currentThread->javaVM; - if (J9_ARE_ANY_BITS_SET(vm->extendedRuntimeFlags3, J9_EXTENDED_RUNTIME3_YIELD_PINNED_CONTINUATION)) { + if (J9VM_ARE_PINNED_YIELDABLE_VIRTUALTHREADS_ACTIVE(vm)) { J9VM_SEND_VIRTUAL_UNBLOCKER_THREAD_SIGNAL(vm); Trc_VM_ThreadHelp_notifyUnblocker(currentThread); }