8341273: JVMTI is not properly hiding some continuation related methods

Reviewed-by: alanb, amenkov
This commit is contained in:
Serguei Spitsyn 2024-10-29 19:59:43 +00:00
parent 520ddac970
commit 60364ef001
15 changed files with 316 additions and 79 deletions

View file

@ -56,6 +56,7 @@ import jdk.internal.vm.ThreadContainers;
import jdk.internal.vm.annotation.ChangesCurrentThread;
import jdk.internal.vm.annotation.Hidden;
import jdk.internal.vm.annotation.IntrinsicCandidate;
import jdk.internal.vm.annotation.JvmtiHideEvents;
import jdk.internal.vm.annotation.JvmtiMountTransition;
import jdk.internal.vm.annotation.ReservedStackAccess;
import sun.nio.ch.Interruptible;
@ -213,8 +214,14 @@ final class VirtualThread extends BaseVirtualThread {
private static Runnable wrap(VirtualThread vthread, Runnable task) {
return new Runnable() {
@Hidden
@JvmtiHideEvents
public void run() {
vthread.run(task);
vthread.notifyJvmtiStart(); // notify JVMTI
try {
vthread.run(task);
} finally {
vthread.notifyJvmtiEnd(); // notify JVMTI
}
}
};
}
@ -389,9 +396,6 @@ final class VirtualThread extends BaseVirtualThread {
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();
@ -405,20 +409,14 @@ final class VirtualThread extends BaseVirtualThread {
} catch (Throwable exc) {
dispatchUncaughtException(exc);
} finally {
try {
// pop any remaining scopes from the stack, this may block
StackableScope.popAll();
// pop any remaining scopes from the stack, this may block
StackableScope.popAll();
// emit JFR event if enabled
if (VirtualThreadEndEvent.isTurnedOn()) {
var event = new VirtualThreadEndEvent();
event.javaThreadId = threadId();
event.commit();
}
} finally {
// notify JVMTI, may post VirtualThreadEnd event
notifyJvmtiEnd();
// emit JFR event if enabled
if (VirtualThreadEndEvent.isTurnedOn()) {
var event = new VirtualThreadEndEvent();
event.javaThreadId = threadId();
event.commit();
}
}
}