-
Notifications
You must be signed in to change notification settings - Fork 730
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
Add a walk state flag to skip methods with the JvmtiMountTransition annotation #17758
Conversation
…nnotation Since it's only related to JVMTI, a walk state flag is added to enable the behaviour when doing JVMTI-related stack walk. Related: eclipse-openj9#17490 Signed-off-by: Gengchen Tuo <[email protected]>
@babsingh FYI |
The current title exceeds the allowed character limit. Revised commit message and PR description:
|
#define J9_IS_JVMTI_MOUNT_TRANSITION(method) \ | ||
((NULL != (method)) && (J9_ARE_ANY_BITS_SET(getExtendedModifiersDataFromROMMethod(J9_ROM_METHOD_FROM_RAM_METHOD(method)), CFR_METHOD_EXT_JVMTIMOUNTTRANSITION_ANNOTATION))) | ||
#if defined(OPENJ9_BUILD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a new line and wrap with JAVA_SPEC_VERSION >= 20
to avoid compilation errors since CFR_METHOD_EXT_JVMTIMOUNTTRANSITION_ANNOTATION
is only defined in JDK20+.
#define J9_IS_JVMTI_MOUNT_TRANSITION(method) \ | |
((NULL != (method)) && (J9_ARE_ANY_BITS_SET(getExtendedModifiersDataFromROMMethod(J9_ROM_METHOD_FROM_RAM_METHOD(method)), CFR_METHOD_EXT_JVMTIMOUNTTRANSITION_ANNOTATION))) | |
#if defined(OPENJ9_BUILD) | |
#if JAVA_SPEC_VERSION >= 20 | |
#define J9_IS_JVMTI_MOUNT_TRANSITION(method) \ | |
((NULL != (method)) && (J9_ARE_ANY_BITS_SET(getExtendedModifiersDataFromROMMethod(J9_ROM_METHOD_FROM_RAM_METHOD(method)), CFR_METHOD_EXT_JVMTIMOUNTTRANSITION_ANNOTATION))) | |
#endif /* JAVA_SPEC_VERSION >= 20 */ | |
#if defined(OPENJ9_BUILD) |
/* Skip methods with JvmtiMountTransition annotation */ | ||
if (J9_ARE_ALL_BITS_SET(walkState->flags, J9_STACKWALK_SKIP_JVMTI_MOUNT_TRANSITION_FRAMES) | ||
&& J9_IS_JVMTI_MOUNT_TRANSITION(walkState->method) | ||
) { | ||
return J9_STACKWALK_KEEP_ITERATING; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with #16654, the code changes in this PR should be wrapped with JAVA_SPEC_VERSION >= 20
.
/* Skip methods with JvmtiMountTransition annotation */ | |
if (J9_ARE_ALL_BITS_SET(walkState->flags, J9_STACKWALK_SKIP_JVMTI_MOUNT_TRANSITION_FRAMES) | |
&& J9_IS_JVMTI_MOUNT_TRANSITION(walkState->method) | |
) { | |
return J9_STACKWALK_KEEP_ITERATING; | |
} | |
#if JAVA_SPEC_VERSION >= 20 | |
/* Skip methods with JvmtiMountTransition annotation. */ | |
if (J9_ARE_ALL_BITS_SET(walkState->flags, J9_STACKWALK_SKIP_JVMTI_MOUNT_TRANSITION_FRAMES) | |
&& J9_IS_JVMTI_MOUNT_TRANSITION(walkState->method) | |
) { | |
return J9_STACKWALK_KEEP_ITERATING; | |
} | |
#endif /* JAVA_SPEC_VERSION >= 20 */ |
@@ -401,6 +401,7 @@ extern "C" { | |||
#define J9_STACKWALK_CACHE_METHODS 0x400 | |||
#define J9_STACKWALK_CACHE_MASK 0x700 | |||
#define J9_STACKWALK_SKIP_HIDDEN_FRAMES 0x800 | |||
#define J9_STACKWALK_SKIP_JVMTI_MOUNT_TRANSITION_FRAMES 0x1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Macro definitions don't need JAVA_SPEC_VERSION >= 20
.
++ @gacholio for a second set of eyes. |
This stuff really doesn't belong in the stack walker (I know previous hacks for hidden have made it in). Really, it should be handled in the frame iterators, much like we do to hide the old reflect implementation). |
@@ -1813,7 +1813,7 @@ UDATA | |||
findDecompileInfo(J9VMThread *currentThread, J9VMThread *targetThread, UDATA depth, J9StackWalkState *walkState) | |||
{ | |||
walkState->walkThread = targetThread; | |||
walkState->flags = J9_STACKWALK_ITERATE_FRAMES | J9_STACKWALK_INCLUDE_NATIVES | J9_STACKWALK_VISIBLE_ONLY | J9_STACKWALK_RECORD_BYTECODE_PC_OFFSET | J9_STACKWALK_MAINTAIN_REGISTER_MAP; | |||
walkState->flags = J9_STACKWALK_ITERATE_FRAMES | J9_STACKWALK_INCLUDE_NATIVES | J9_STACKWALK_VISIBLE_ONLY | J9_STACKWALK_RECORD_BYTECODE_PC_OFFSET | J9_STACKWALK_MAINTAIN_REGISTER_MAP | J9_STACKWALK_SKIP_JVMTI_MOUNT_TRANSITION_FRAMES; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is certainly a place that should not be changed - this wants the true view of the stack, not a user-facing one.
The only place using the new flag is using it incorrectly as far as I can see, so we should probably just abandon this PR. |
Java methods tagged with the JvmtiMountTransition annotation are involved in transitioning between carrier to virtual threads, and vice-versa. These methods are not part of the thread's scope. So, they are skipped during introspection by the following JVMTI functions: - ForceEarlyReturn - NotifyFramePop - Local Variable (GetOrSetLocal) This PR allows us to match the RI in jvmti/vthread/MethodExitTest. Related eclipse-openj9#17490 Closes eclipse-openj9#17758 Co-authored-by: Gengchen Tuo <[email protected]> Signed-off-by: Babneet Singh <[email protected]>
Since it's only related to JVMTI, a walk state flag is added to enable the behaviour when doing JVMTI-related stack walk.
Related: #17490