Skip to content
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

Recognize and handle Memory Segment View VarHandles in JDK21+ #19662

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions runtime/compiler/codegen/J9RecognizedMethodsEnum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,8 @@
java_lang_invoke_VarHandleByteArrayAsX_ArrayHandle_method,
java_lang_invoke_VarHandleByteArrayAsX_ByteBufferHandle_method,

java_lang_invoke_VarHandleSegmentAsX_method,

// Clone and Deep Copy
java_lang_J9VMInternals_is32Bit,
java_lang_J9VMInternals_isClassModifierPublic,
Expand Down
15 changes: 14 additions & 1 deletion runtime/compiler/env/j9method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4765,8 +4765,20 @@ void TR_ResolvedJ9Method::construct()
{
setRecognizedMethodInfo(TR::java_lang_invoke_VarHandleByteArrayAsX_ByteBufferHandle_method);
}
#if JAVA_SPEC_VERSION >= 21
else if ((classNameLen == 39 && !strncmp(className, "java/lang/invoke/VarHandleSegmentAsInts", 39))
|| (classNameLen == 40 && !strncmp(className, "java/lang/invoke/VarHandleSegmentAsBytes", 40))
|| (classNameLen == 40 && !strncmp(className, "java/lang/invoke/VarHandleSegmentAsChars", 40))
|| (classNameLen == 40 && !strncmp(className, "java/lang/invoke/VarHandleSegmentAsLongs", 40))
|| (classNameLen == 41 && !strncmp(className, "java/lang/invoke/VarHandleSegmentAsFloats", 41))
|| (classNameLen == 41 && !strncmp(className, "java/lang/invoke/VarHandleSegmentAsShorts", 41))
|| (classNameLen == 42 && !strncmp(className, "java/lang/invoke/VarHandleSegmentAsDoubles", 42)))
{
setRecognizedMethodInfo(TR::java_lang_invoke_VarHandleSegmentAsX_method);
}
#endif // JAVA_SPEC_VERSION >= 21
}
#endif
#endif // defined(J9VM_OPT_OPENJDK_METHODHANDLE)
else if ((classNameLen >= 59 + 3 && classNameLen <= 59 + 7) && !strncmp(className, "java/lang/invoke/ArrayVarHandle$ArrayVarHandleOperations$Op", 59))
{
setRecognizedMethodInfo(TR::java_lang_invoke_ArrayVarHandle_ArrayVarHandleOperations_OpMethod);
Expand Down Expand Up @@ -5879,6 +5891,7 @@ TR_J9MethodBase::isVarHandleOperationMethod(TR::RecognizedMethod rm)
case TR::java_lang_invoke_VarHandleX_FieldStaticReadOnlyOrReadWrite_method:
case TR::java_lang_invoke_VarHandleByteArrayAsX_ArrayHandle_method:
case TR::java_lang_invoke_VarHandleByteArrayAsX_ByteBufferHandle_method:
case TR::java_lang_invoke_VarHandleSegmentAsX_method:
#else
case TR::java_lang_invoke_ArrayVarHandle_ArrayVarHandleOperations_OpMethod:
case TR::java_lang_invoke_StaticFieldVarHandle_StaticFieldVarHandleOperations_OpMethod:
Expand Down
2 changes: 2 additions & 0 deletions runtime/compiler/optimizer/UnsafeFastPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static bool isVarHandleOperationMethodOnArray(TR::RecognizedMethod rm)
case TR::java_lang_invoke_VarHandleX_Array_method:
case TR::java_lang_invoke_VarHandleByteArrayAsX_ArrayHandle_method:
case TR::java_lang_invoke_VarHandleByteArrayAsX_ByteBufferHandle_method:
case TR::java_lang_invoke_VarHandleSegmentAsX_method:
#else
case TR::java_lang_invoke_ArrayVarHandle_ArrayVarHandleOperations_OpMethod:
case TR::java_lang_invoke_ByteArrayViewVarHandle_ByteArrayViewVarHandleOperations_OpMethod:
Expand Down Expand Up @@ -188,6 +189,7 @@ static bool isVarHandleOperationMethodOnNonStaticField(TR::RecognizedMethod rm)
case TR::java_lang_invoke_VarHandleX_Array_method:
case TR::java_lang_invoke_VarHandleByteArrayAsX_ArrayHandle_method:
case TR::java_lang_invoke_VarHandleByteArrayAsX_ByteBufferHandle_method:
case TR::java_lang_invoke_VarHandleSegmentAsX_method:
#else
case TR::java_lang_invoke_InstanceFieldVarHandle_InstanceFieldVarHandleOperations_OpMethod:
case TR::java_lang_invoke_ArrayVarHandle_ArrayVarHandleOperations_OpMethod:
Expand Down