798
798
updateMonitorInfo (J9VMThread *currentThread, J9ObjectMonitor *objectMonitor)
799
799
{
800
800
J9ThreadAbstractMonitor *monitor = (J9ThreadAbstractMonitor *)objectMonitor->monitor ;
801
+ Assert_VM_true (1 == (UDATA)monitor->owner );
801
802
monitor->owner = currentThread->osThread ;
802
803
objectMonitor->ownerContinuation = NULL ;
803
804
}
@@ -937,6 +938,8 @@ preparePinnedVirtualThreadForUnmount(J9VMThread *currentThread, j9object_t syncO
937
938
syncObjectMonitor = J9_INFLLOCK_OBJECT_MONITOR (lock);
938
939
} else {
939
940
if (isObjectWait) {
941
+ /* Current thread must own at least one monitor if wait was called. */
942
+ Assert_VM_true (currentThread->ownedMonitorCount > 0 );
940
943
syncObjectMonitor = objectMonitorInflate (currentThread, syncObj, lock);
941
944
if (NULL == syncObjectMonitor) {
942
945
result = J9_OBJECT_MONITOR_OOM;
@@ -1074,11 +1077,11 @@ preparePinnedVirtualThreadForUnmount(J9VMThread *currentThread, j9object_t syncO
1074
1077
1075
1078
if (NULL != syncObj) {
1076
1079
j9object_t continuationObj = J9VMJAVALANGVIRTUALTHREAD_CONT (currentThread, currentThread->threadObject );
1080
+ omrthread_monitor_t monitor = syncObjectMonitor->monitor ;
1077
1081
J9VMJDKINTERNALVMCONTINUATION_SET_BLOCKER (currentThread, continuationObj, syncObj);
1078
1082
1079
1083
if (isObjectWait) {
1080
1084
J9VMContinuation *continuation = currentThread->currentContinuation ;
1081
- omrthread_monitor_t monitor = syncObjectMonitor->monitor ;
1082
1085
1083
1086
/* Record wait monitor state. */
1084
1087
continuation->waitingMonitorEnterCount = monitor->count ;
@@ -1100,6 +1103,11 @@ preparePinnedVirtualThreadForUnmount(J9VMThread *currentThread, j9object_t syncO
1100
1103
/* Increment the wait count on inflated monitor. */
1101
1104
VM_AtomicSupport::addU32 (&syncObjectMonitor->virtualThreadWaitCount , 1 );
1102
1105
currentThread->currentContinuation ->objectWaitMonitor = syncObjectMonitor;
1106
+
1107
+ if (NULL != monitor) {
1108
+ /* If we are blocking to wait on a contended monitor then we can't be the owner. */
1109
+ // Assert_VM_false(monitor->owner == currentThread->osThread);
1110
+ }
1103
1111
}
1104
1112
}
1105
1113
0 commit comments