Skip to content

Commit

Permalink
8346120: VirtualThreadPinned event recorded for Object.wait may have …
Browse files Browse the repository at this point in the history
…wrong duration or may record second event

Reviewed-by: dholmes, pchilanomate
  • Loading branch information
Alan Bateman committed Dec 17, 2024
1 parent 466c00a commit fbbc7c3
Show file tree
Hide file tree
Showing 2 changed files with 485 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/hotspot/share/runtime/objectMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,11 @@ void ObjectMonitor::enter_with_contention_mark(JavaThread *current, ObjectMonito
enter_event.commit();
}

ContinuationEntry* ce = current->last_continuation();
if (ce != nullptr && ce->is_virtual_thread()) {
assert(result != freeze_ok, "sanity check");
current->post_vthread_pinned_event(&vthread_pinned_event, "Contended monitor enter", result);
if (current->current_waiting_monitor() == nullptr) {
ContinuationEntry* ce = current->last_continuation();
if (ce != nullptr && ce->is_virtual_thread()) {
current->post_vthread_pinned_event(&vthread_pinned_event, "Contended monitor enter", result);
}
}

OM_PERFDATA_OP(ContendedLockAttempts, inc());
Expand Down Expand Up @@ -1819,11 +1820,6 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) {
post_monitor_wait_event(&wait_event, this, node._notifier_tid, millis, ret == OS_TIMEOUT);
}

if (ce != nullptr && ce->is_virtual_thread()) {
assert(result != freeze_ok, "sanity check");
current->post_vthread_pinned_event(&vthread_pinned_event, "Object.wait", result);
}

OrderAccess::fence();

assert(!has_owner(current), "invariant");
Expand Down Expand Up @@ -1863,6 +1859,10 @@ void ObjectMonitor::wait(jlong millis, bool interruptible, TRAPS) {
assert(!has_successor(current), "invariant");
assert_mark_word_consistency();

if (ce != nullptr && ce->is_virtual_thread()) {
current->post_vthread_pinned_event(&vthread_pinned_event, "Object.wait", result);
}

// check if the notification happened
if (!WasNotified) {
// no, it could be timeout or Thread.interrupt() or both
Expand Down
Loading

1 comment on commit fbbc7c3

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.