@@ -597,10 +597,11 @@ void ObjectMonitor::enter_with_contention_mark(JavaThread *current, ObjectMonito
597
597
enter_event.commit ();
598
598
}
599
599
600
- ContinuationEntry* ce = current->last_continuation ();
601
- if (ce != nullptr && ce->is_virtual_thread ()) {
602
- assert (result != freeze_ok, " sanity check" );
603
- current->post_vthread_pinned_event (&vthread_pinned_event, " Contended monitor enter" , result);
600
+ if (current->current_waiting_monitor () == nullptr ) {
601
+ ContinuationEntry* ce = current->last_continuation ();
602
+ if (ce != nullptr && ce->is_virtual_thread ()) {
603
+ current->post_vthread_pinned_event (&vthread_pinned_event, " Contended monitor enter" , result);
604
+ }
604
605
}
605
606
606
607
OM_PERFDATA_OP (ContendedLockAttempts, inc ());
@@ -1819,11 +1820,6 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) {
1819
1820
post_monitor_wait_event (&wait_event, this , node._notifier_tid , millis, ret == OS_TIMEOUT);
1820
1821
}
1821
1822
1822
- if (ce != nullptr && ce->is_virtual_thread ()) {
1823
- assert (result != freeze_ok, " sanity check" );
1824
- current->post_vthread_pinned_event (&vthread_pinned_event, " Object.wait" , result);
1825
- }
1826
-
1827
1823
OrderAccess::fence ();
1828
1824
1829
1825
assert (!has_owner (current), " invariant" );
@@ -1863,6 +1859,10 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) {
1863
1859
assert (!has_successor (current), " invariant" );
1864
1860
assert_mark_word_consistency ();
1865
1861
1862
+ if (ce != nullptr && ce->is_virtual_thread ()) {
1863
+ current->post_vthread_pinned_event (&vthread_pinned_event, " Object.wait" , result);
1864
+ }
1865
+
1866
1866
// check if the notification happened
1867
1867
if (!WasNotified) {
1868
1868
// no, it could be timeout or Thread.interrupt() or both
0 commit comments