Skip to content

Commit

Permalink
Disallow NotifyFramePop for enter/enter0/VirtualThread.run/VThreadCon…
Browse files Browse the repository at this point in the history
…tinuation.run
  • Loading branch information
sspitsyn committed Oct 9, 2024
1 parent 8ec7bd3 commit 3317ea8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/hotspot/share/prims/jvmtiEnvBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,8 @@ JvmtiEnvBase::set_frame_pop(JvmtiThreadState* state, javaVFrame* jvf, jint depth
if (jvf == nullptr) {
return JVMTI_ERROR_NO_MORE_FRAMES;
}
if (jvf->method()->is_native()) {
if (jvf->method()->is_native() ||
(state->is_virtual() && (jvf->is_vthread_entry() || jvf->method()->jvmti_mount_transition()))) {
return JVMTI_ERROR_OPAQUE_FRAME;
}
assert(jvf->frame_pointer() != nullptr, "frame pointer mustn't be null");
Expand Down
12 changes: 7 additions & 5 deletions src/java.base/share/classes/java/lang/VirtualThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,15 @@ protected void onPinned(Continuation.Pinned reason) {
private static Runnable wrap(VirtualThread vthread, Runnable task) {
return new Runnable() {
@Hidden
@JvmtiMountTransition
public void run() {
// notify JVMTI
vthread.notifyJvmtiStart();

vthread.run(task);

// notify JVMTI
vthread.notifyJvmtiEnd();
}
};
}
Expand Down Expand Up @@ -389,9 +396,6 @@ private void submitFailed(RejectedExecutionException ree) {
private void run(Runnable task) {
assert Thread.currentThread() == this && state == RUNNING;

// notify JVMTI, may post VirtualThreadStart event
notifyJvmtiStart();

// emit JFR event if enabled
if (VirtualThreadStartEvent.isTurnedOn()) {
var event = new VirtualThreadStartEvent();
Expand All @@ -417,8 +421,6 @@ private void run(Runnable task) {
}

} finally {
// notify JVMTI, may post VirtualThreadEnd event
notifyJvmtiEnd();
}
}
}
Expand Down

0 comments on commit 3317ea8

Please sign in to comment.