Skip to content

Commit

Permalink
Add a walk state flag to skip methods with the JvmtiMountTransition a…
Browse files Browse the repository at this point in the history
…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 <gengchen.tuo@ibm.com>
  • Loading branch information
thallium committed Jul 7, 2023
1 parent 30b4219 commit 8a6f5c0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
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,6 +278,7 @@ public PreemptStatus tryPreempt(Thread t) {
}

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

Expand Down
2 changes: 1 addition & 1 deletion runtime/jvmti/jvmtiHelpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
walkState->skipCount = depth;
walkState->userData1 = (void *)JVMTI_ERROR_NO_MORE_FRAMES;
walkState->frameWalkFunction = findDecompileInfoFrameIterator;
Expand Down
2 changes: 2 additions & 0 deletions runtime/oti/j9.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ static const struct { \

#define J9VM_VIRTUALTHREAD_ROOT_NODE_STATE ((I_32)0xBAADF00D)

#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)
#define J9_SHARED_CACHE_DEFAULT_BOOT_SHARING(vm) TRUE
#else /* defined(OPENJ9_BUILD) */
Expand Down
1 change: 1 addition & 0 deletions runtime/oti/j9consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
#define J9_STACKWALK_UNUSED_0x10000 0x10000
#define J9_STACKWALK_LINEAR 0x20000
#define J9_STACKWALK_VISIBLE_ONLY 0x40000
Expand Down
7 changes: 7 additions & 0 deletions runtime/vm/swalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,13 @@ UDATA walkFrame(J9StackWalkState * walkState)
return J9_STACKWALK_KEEP_ITERATING;
}

/* 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 (walkState->skipCount) {
--walkState->skipCount;
return J9_STACKWALK_KEEP_ITERATING;
Expand Down

0 comments on commit 8a6f5c0

Please sign in to comment.