@@ -1024,7 +1024,7 @@ preparePinnedVirtualThreadForUnmount(J9VMThread *currentThread, j9object_t syncO
1024
1024
currentThread->currentContinuation ->objectWaitMonitor = syncObjectMonitor;
1025
1025
omrthread_monitor_exit (vm->blockedVirtualThreadsMutex );
1026
1026
} else {
1027
- syncObjectMonitor->virtualThreadWaitCount += 1 ;
1027
+ VM_AtomicSupport::addU32 (& syncObjectMonitor->virtualThreadWaitCount , 1 ) ;
1028
1028
}
1029
1029
1030
1030
/* Clear the blocking object on the carrier thread. */
@@ -1096,15 +1096,20 @@ takeVirtualThreadListToUnblock(J9VMThread *currentThread)
1096
1096
}
1097
1097
} else {
1098
1098
lock = J9OBJECT_MONITOR (currentThread, syncObject);
1099
- syncObjectMonitor = J9_INFLLOCK_OBJECT_MONITOR (lock);
1099
+ if (J9_LOCK_IS_INFLATED (lock)) {
1100
+ syncObjectMonitor = J9_INFLLOCK_OBJECT_MONITOR (lock);
1101
+ }
1100
1102
}
1101
- omrthread_monitor_t monitor = syncObjectMonitor->monitor ;
1102
- if (0 == monitor->count ) {
1103
- unblocked = true ;
1104
- if (syncObjectMonitor->virtualThreadWaitCount >= 1 ) {
1105
- syncObjectMonitor->virtualThreadWaitCount -= 1 ;
1103
+ /* Only perform the below operations for inflated monitors. */
1104
+ if (NULL != syncObjectMonitor) {
1105
+ omrthread_monitor_t monitor = syncObjectMonitor->monitor ;
1106
+ if (0 == monitor->count ) {
1107
+ unblocked = true ;
1108
+ if (syncObjectMonitor->virtualThreadWaitCount >= 1 ) {
1109
+ VM_AtomicSupport::subtractU32 (&syncObjectMonitor->virtualThreadWaitCount , 1 );
1110
+ }
1111
+ J9VMJAVALANGVIRTUALTHREAD_SET_ONWAITINGLIST (currentThread, current->vthread , JNI_TRUE);
1106
1112
}
1107
- J9VMJAVALANGVIRTUALTHREAD_SET_ONWAITINGLIST (currentThread, current->vthread , JNI_TRUE);
1108
1113
}
1109
1114
}
1110
1115
0 commit comments