Skip to content

Commit

Permalink
Skip JLIMethodHandle$AsVarargsCollector.invoke while iterating stack …
Browse files Browse the repository at this point in the history
…similar to other reflection invoke methods
  • Loading branch information
r30shah committed Sep 10, 2024
1 parent 3dc041d commit ea51632
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions runtime/jcl/common/java_lang_Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ isPrivilegedFrameIterator(J9VMThread * currentThread, J9StackWalkState * walkSta
if ((walkState->method == vm->jlrMethodInvoke)
#if JAVA_SPEC_VERSION >= 18
|| (walkState->method == vm->jlrMethodInvokeMH)
|| (walkState->method == vm->jliMethodHandleAsVarargsCollectorInvokeWithArgs)
#endif /* JAVA_SPEC_VERSION >= 18 */
|| (walkState->method == vm->jliMethodHandleInvokeWithArgs)
|| (walkState->method == vm->jliMethodHandleInvokeWithArgsList)
Expand Down Expand Up @@ -1276,6 +1277,7 @@ isPrivilegedFrameIteratorGetAccSnapshot(J9VMThread * currentThread, J9StackWalkS
if ((walkState->method == vm->jlrMethodInvoke)
#if JAVA_SPEC_VERSION >= 18
|| (walkState->method == vm->jlrMethodInvokeMH)
|| (walkState->method == vm->jliMethodHandleAsVarargsCollectorInvokeWithArgs)
#endif /* JAVA_SPEC_VERSION >= 18 */
|| (walkState->method == vm->jliMethodHandleInvokeWithArgs)
|| (walkState->method == vm->jliMethodHandleInvokeWithArgsList)
Expand Down Expand Up @@ -1700,6 +1702,7 @@ isPrivilegedFrameIteratorGetCallerPD(J9VMThread * currentThread, J9StackWalkStat
if ((walkState->method == vm->jlrMethodInvoke)
#if JAVA_SPEC_VERSION >= 18
|| (walkState->method == vm->jlrMethodInvokeMH)
|| (walkState->method == vm->jliMethodHandleAsVarargsCollectorInvokeWithArgs)
#endif /* JAVA_SPEC_VERSION >= 18 */
|| (walkState->method == vm->jliMethodHandleInvokeWithArgs)
|| (walkState->method == vm->jliMethodHandleInvokeWithArgsList)
Expand Down
10 changes: 10 additions & 0 deletions runtime/jcl/common/stdinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,16 @@ standardInit(J9JavaVM *vm, char *dllName)
goto _fail;
}
vm->jlrMethodInvokeMH = ((J9JNIMethodID*)invokeMethodMH)->method;
(*(JNIEnv*)vmThread)->DeleteLocalRef((JNIEnv*)vmThread, clazz);
clazz = (*(JNIEnv*)vmThread)->FindClass((JNIEnv*)vmThread, "java/lang/invoke/MethodHandleImpl$AsVarargsCollector");
if (NULL == clazz) {
goto _fail;
}
jmethodID invokeAsVarargsMethodMH = invokeMethod = (*(JNIEnv*)vmThread)->GetMethodID((JNIEnv*)vmThread, clazz, "invokeWithArguments", "([Ljava/lang/Object;)Ljava/lang/Object;");
if (NULL == invokeAsVarargsMethodMH) {
goto _fail;
}
vm->jliMethodHandleAsVarargsCollectorInvokeWithArgs = ((J9JNIMethodID*)invokeAsVarargsMethodMH)->method;
}
#endif /* JAVA_SPEC_VERSION >= 18 */
(*(JNIEnv*)vmThread)->DeleteLocalRef((JNIEnv*)vmThread, clazz);
Expand Down
1 change: 1 addition & 0 deletions runtime/oti/VMHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,7 @@ class VM_VMHelpers
return ((method == vm->jlrMethodInvoke)
#if JAVA_SPEC_VERSION >= 18
|| (method == vm->jlrMethodInvokeMH)
|| (method == vm->jliMethodHandleAsVarargsCollectorInvokeWithArgs)
#endif /* JAVA_SPEC_VERSION >= 18 */
|| (method == vm->jliMethodHandleInvokeWithArgs)
|| (method == vm->jliMethodHandleInvokeWithArgsList)
Expand Down
1 change: 1 addition & 0 deletions runtime/oti/j9nonbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -5892,6 +5892,7 @@ typedef struct J9JavaVM {
struct J9Method* jlrMethodInvoke;
#if JAVA_SPEC_VERSION >= 18
struct J9Method* jlrMethodInvokeMH;
struct J9Method* jliMethodHandleAsVarargsCollectorInvokeWithArgs;
#endif /* JAVA_SPEC_VERSION >= 18 */
struct J9Method* jliMethodHandleInvokeWithArgs;
struct J9Method* jliMethodHandleInvokeWithArgsList;
Expand Down
3 changes: 3 additions & 0 deletions runtime/sunvmi/sunvmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ getCallerClassIterator(J9VMThread * currentThread, J9StackWalkState * walkState)
if ((walkState->method != vm->jlrMethodInvoke)
#if JAVA_SPEC_VERSION >= 18
&& (walkState->method != vm->jlrMethodInvokeMH)
&& (walkState->method != vm->jliMethodHandleAsVarargsCollectorInvokeWithArgs)
#endif /* JAVA_SPEC_VERSION >= 18 */
&& (walkState->method != vm->jliMethodHandleInvokeWithArgs)
&& (walkState->method != vm->jliMethodHandleInvokeWithArgsList)
Expand Down Expand Up @@ -239,6 +240,7 @@ getCallerClassJEP176Iterator(J9VMThread *currentThread, J9StackWalkState *walkSt
|| (walkState->method == vm->jlrMethodInvoke)
#if JAVA_SPEC_VERSION >= 18
|| (walkState->method == vm->jlrMethodInvokeMH)
|| (walkState->method == vm->jliMethodHandleAsVarargsCollectorInvokeWithArgs)
#endif /* JAVA_SPEC_VERSION >= 18 */
|| (vm->srMethodAccessor && vmFuncs->instanceOfOrCheckCast(currentClass, J9VM_J9CLASS_FROM_HEAPCLASS(currentThread, *((j9object_t *)vm->srMethodAccessor))))
|| (vm->srConstructorAccessor && vmFuncs->instanceOfOrCheckCast(currentClass, J9VM_J9CLASS_FROM_HEAPCLASS(currentThread, *((j9object_t *)vm->srConstructorAccessor))))
Expand Down Expand Up @@ -576,6 +578,7 @@ getClassContextIterator(J9VMThread * currentThread, J9StackWalkState * walkState
if ((walkState->method != vm->jlrMethodInvoke)
#if JAVA_SPEC_VERSION >= 18
&& (walkState->method != vm->jlrMethodInvokeMH)
&& (walkState->method != vm->jliMethodHandleAsVarargsCollectorInvokeWithArgs)
#endif /* JAVA_SPEC_VERSION >= 18 */
&& (walkState->method != vm->jliMethodHandleInvokeWithArgs)
&& (walkState->method != vm->jliMethodHandleInvokeWithArgsList)
Expand Down
1 change: 1 addition & 0 deletions runtime/vm/NativeHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ cInterpGetStackClassJEP176Iterator(J9VMThread *currentThread, J9StackWalkState *
|| (walkState->method == vm->jlrMethodInvoke)
#if JAVA_SPEC_VERSION >= 18
|| (walkState->method == vm->jlrMethodInvokeMH)
|| (walkState->method == vm->jliMethodHandleAsVarargsCollectorInvokeWithArgs)
#endif /* JAVA_SPEC_VERSION >= 18 */
|| (vm->srMethodAccessor && vmFuncs->instanceOfOrCheckCast(currentClass, J9VM_J9CLASS_FROM_HEAPCLASS(currentThread, *((j9object_t *)vm->srMethodAccessor))))
|| (vm->srConstructorAccessor && vmFuncs->instanceOfOrCheckCast(currentClass, J9VM_J9CLASS_FROM_HEAPCLASS(currentThread, *((j9object_t *)vm->srConstructorAccessor))))
Expand Down

0 comments on commit ea51632

Please sign in to comment.