Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement JVM_VirtualThreadHideFrames() #16654

Merged
merged 1 commit into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions runtime/bcutil/ClassFileOracle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ ClassFileOracle::KnownAnnotation ClassFileOracle::_knownAnnotations[] = {
{NOTCHECKPOINTSAFE_SIGNATURE, sizeof(NOTCHECKPOINTSAFE_SIGNATURE)},
#undef NOTCHECKPOINTSAFE_SIGNATURE
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
#if JAVA_SPEC_VERSION >= 20
#define JVMTIMOUNTTRANSITION_SIGNATURE "Ljdk/internal/vm/annotation/JvmtiMountTransition;"
{JVMTIMOUNTTRANSITION_SIGNATURE , sizeof(JVMTIMOUNTTRANSITION_SIGNATURE)},
#undef JVMTIMOUNTTRANSITION_SIGNATURE
#endif /* JAVA_SPEC_VERSION >= 20 */
{0, 0}
};

Expand Down Expand Up @@ -937,6 +942,9 @@ ClassFileOracle::walkMethodAttributes(U_16 methodIndex)
#if defined(J9VM_OPT_CRIU_SUPPORT)
knownAnnotations = addAnnotationBit(knownAnnotations, NOT_CHECKPOINT_SAFE_ANNOTATION);
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
#if JAVA_SPEC_VERSION >= 20
knownAnnotations = addAnnotationBit(knownAnnotations, JVMTIMOUNTTRANSITION_ANNOTATION);
#endif /* JAVA_SPEC_VERSION >= 20 */

J9CfrAttributeRuntimeVisibleAnnotations *attribAnnotations = (J9CfrAttributeRuntimeVisibleAnnotations *)attrib;
if (0 == attribAnnotations->rawDataLength) { /* rawDataLength non-zero in case of error in the attribute */
Expand Down Expand Up @@ -977,6 +985,12 @@ ClassFileOracle::walkMethodAttributes(U_16 methodIndex)
_methodsInfo[methodIndex].extendedModifiers |= CFR_METHOD_EXT_NOT_CHECKPOINT_SAFE_ANNOTATION;
}
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
#if JAVA_SPEC_VERSION >= 20
if (containsKnownAnnotation(foundAnnotations, JVMTIMOUNTTRANSITION_ANNOTATION)) {
/* JvmtiMountTransition annotation is used by OpenJDK to tag methods which should be hidden for JVMTI and stackwalk */
_methodsInfo[methodIndex].extendedModifiers |= CFR_METHOD_EXT_JVMTIMOUNTTRANSITION_ANNOTATION;
}
#endif /* JAVA_SPEC_VERSION >= 20 */
}
_methodsInfo[methodIndex].annotationsAttribute = attribAnnotations;
_methodsInfo[methodIndex].modifiers |= J9AccMethodHasMethodAnnotations;
Expand Down
3 changes: 3 additions & 0 deletions runtime/bcutil/ClassFileOracle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,9 @@ class RecordComponentIterator
#if defined(J9VM_OPT_CRIU_SUPPORT)
NOT_CHECKPOINT_SAFE_ANNOTATION,
#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */
#if JAVA_SPEC_VERSION >= 20
JVMTIMOUNTTRANSITION_ANNOTATION,
#endif /* JAVA_SPEC_VERSION >= 20 */
KNOWN_ANNOTATION_COUNT
};

Expand Down
11 changes: 10 additions & 1 deletion runtime/j9vm/javanextvmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,16 @@ JVM_GetClassFileVersion(JNIEnv *env, jclass cls)
JNIEXPORT void JNICALL
JVM_VirtualThreadHideFrames(JNIEnv *env, jobject vthread, jboolean hide)
{
/* TODO toggle hiding of stack frames for JVMTI */
J9VMThread *currentThread = (J9VMThread *)env;
Assert_SC_true(IS_JAVA_LANG_VIRTUALTHREAD(currentThread, currentThread->threadObject));

if (hide) {
Assert_SC_true(J9_ARE_NO_BITS_SET(currentThread->privateFlags, J9_PRIVATE_FLAGS_VIRTUAL_THREAD_HIDDEN_FRAMES));
currentThread->privateFlags |= J9_PRIVATE_FLAGS_VIRTUAL_THREAD_HIDDEN_FRAMES;
} else {
Assert_SC_true(J9_ARE_ALL_BITS_SET(currentThread->privateFlags, J9_PRIVATE_FLAGS_VIRTUAL_THREAD_HIDDEN_FRAMES));
currentThread->privateFlags &= ~(UDATA)J9_PRIVATE_FLAGS_VIRTUAL_THREAD_HIDDEN_FRAMES;
}
}
#endif /* JAVA_SPEC_VERSION >= 20 */

Expand Down
Loading