Skip to content

Commit

Permalink
Merge pull request #16654 from thallium/hideFramesPR
Browse files Browse the repository at this point in the history
Implement JVM_VirtualThreadHideFrames()
  • Loading branch information
keithc-ca committed May 8, 2023
2 parents 8f80c76 + 7e91e03 commit 36f6357
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 137 deletions.
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

0 comments on commit 36f6357

Please sign in to comment.