Skip to content

Commit 2b33c84

Browse files
authored
Merge pull request #21359 from tajila/vt2
IMSE support for vthreads
2 parents 78878f2 + abda470 commit 2b33c84

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

runtime/vm/BytecodeInterpreter.hpp

+18-13
Original file line numberDiff line numberDiff line change
@@ -5216,21 +5216,26 @@ class INTERPRETER_CLASS
52165216
updateVMStruct(REGISTER_ARGS);
52175217
#if JAVA_SPEC_VERSION >= 24
52185218
if (VM_ContinuationHelpers::isYieldableVirtualThread(_currentThread)) {
5219-
UDATA newState = JAVA_LANG_VIRTUALTHREAD_WAITING;
5220-
if ((millis > 0) || (nanos > 0)) {
5221-
newState = JAVA_LANG_VIRTUALTHREAD_TIMED_WAITING;
5222-
}
5223-
/* Try to yield the virtual thread if it will be blocked. */
5224-
UDATA result = preparePinnedVirtualThreadForUnmount(_currentThread, object, true);
5225-
VMStructHasBeenUpdated(REGISTER_ARGS);
5226-
if (J9_OBJECT_MONITOR_OOM != result) {
5227-
restoreInternalNativeStackFrame(REGISTER_ARGS);
5228-
/* Handle the virtual thread Object.wait call. */
5229-
J9VMJAVALANGVIRTUALTHREAD_SET_NOTIFIED(_currentThread, _currentThread->threadObject, JNI_FALSE);
5230-
rc = yieldPinnedContinuation(REGISTER_ARGS, newState, J9VM_CONTINUATION_RETURN_FROM_OBJECT_WAIT);
5219+
if (getObjectMonitorOwner(_vm, object, NULL) == _currentThread) {
5220+
UDATA newState = JAVA_LANG_VIRTUALTHREAD_WAITING;
5221+
if ((millis > 0) || (nanos > 0)) {
5222+
newState = JAVA_LANG_VIRTUALTHREAD_TIMED_WAITING;
5223+
}
5224+
/* Try to yield the virtual thread if it will be blocked. */
5225+
UDATA result = preparePinnedVirtualThreadForUnmount(_currentThread, object, true);
5226+
VMStructHasBeenUpdated(REGISTER_ARGS);
5227+
if (J9_OBJECT_MONITOR_OOM != result) {
5228+
restoreInternalNativeStackFrame(REGISTER_ARGS);
5229+
/* Handle the virtual thread Object.wait call. */
5230+
J9VMJAVALANGVIRTUALTHREAD_SET_NOTIFIED(_currentThread, _currentThread->threadObject, JNI_FALSE);
5231+
rc = yieldPinnedContinuation(REGISTER_ARGS, newState, J9VM_CONTINUATION_RETURN_FROM_OBJECT_WAIT);
5232+
} else {
5233+
rc = THROW_MONITOR_ALLOC_FAIL;
5234+
}
52315235
} else {
5232-
rc = THROW_MONITOR_ALLOC_FAIL;
5236+
rc = THROW_ILLEGAL_MONITOR_STATE;
52335237
}
5238+
52345239
return rc;
52355240
}
52365241
#endif /* JAVA_SPEC_VERSION >= 24 */

0 commit comments

Comments
 (0)