Skip to content

Commit

Permalink
Skip methods with JvmtiMountTransition annotation in findDecompileInfo
Browse files Browse the repository at this point in the history
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 <gengchen.tuo@ibm.com>
Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
  • Loading branch information
thallium authored and babsingh committed Jul 26, 2023
1 parent 15f5859 commit e7220c5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import jdk.internal.access.JavaLangAccess;
import jdk.internal.access.SharedSecrets;
import jdk.internal.misc.Unsafe;
import jdk.internal.vm.annotation.JvmtiMountTransition;

/**
* Continuation class performing the mount/unmount operation for VirtualThread
Expand Down Expand Up @@ -277,7 +278,9 @@ public PreemptStatus tryPreempt(Thread t) {
}

/* Continuation Native APIs */
@JvmtiMountTransition
private native boolean enterImpl();
private static native boolean yieldImpl(boolean isFinished);

@JvmtiMountTransition
private static native boolean yieldImpl(boolean isFinished);
}
24 changes: 23 additions & 1 deletion runtime/jvmti/jvmtiHelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1791,21 +1791,43 @@ static UDATA
findDecompileInfoFrameIterator(J9VMThread *currentThread, J9StackWalkState *walkState)
{
UDATA rc = J9_STACKWALK_KEEP_ITERATING;
J9Method *method = walkState->method;

#if JAVA_SPEC_VERSION >= 20
J9ROMMethod *romMethod = NULL;
U_32 extendedModifiers = 0;

/* walkState->method can never be NULL since the J9_STACKWALK_VISIBLE_ONLY flag is set. */
Assert_JVMTI_true(NULL != method);

romMethod = J9_ROM_METHOD_FROM_RAM_METHOD(method);
extendedModifiers = getExtendedModifiersDataFromROMMethod(romMethod);

if (J9_ARE_ANY_BITS_SET(extendedModifiers, CFR_METHOD_EXT_JVMTIMOUNTTRANSITION_ANNOTATION)) {
goto skip;
}
#endif /* JAVA_SPEC_VERSION >= 20 */

if (JVMTI_ERROR_NONE != (UDATA)walkState->userData1) {
/* The current frame is the requested frame. Record the inline depth for the decompiler
* and the method and bytecodePCOffset for the slot validator.
*/
walkState->userData1 = (void*)JVMTI_ERROR_NONE;
walkState->userData2 = (void*)walkState->inlineDepth;
walkState->userData3 = walkState->method;
walkState->userData3 = method;
walkState->userData4 = (void*)(UDATA)walkState->bytecodePCOffset;
}

/* Keep walking until the outer method is reached (the inline decompiler requires that
* the walkState be at this point).
*/
if (0 == walkState->inlineDepth) {
rc = J9_STACKWALK_STOP_ITERATING;
}

#if JAVA_SPEC_VERSION >= 20
skip:
#endif /* JAVA_SPEC_VERSION >= 20 */
return rc;
}

Expand Down

0 comments on commit e7220c5

Please sign in to comment.