-
Notifications
You must be signed in to change notification settings - Fork 728
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
Update JVM_CopySwapMemory for off-heap enabled case #20742
Conversation
The java caller has added Unsafe.arrayBaseOffset() to the offset for JVM_CopySwapMemory JNI API, need to remove it as GetPrimitiveArrayCritical returns a pointer to the first element, need to replace J9VMTHREAD_CONTIGUOUS_INDEXABLE_HEADER_SIZE() with J9VMTHREAD_UNSAFE_INDEXABLE_HEADER_SIZE() for off-heap case, because arrayBaseOffset() == 0 when off-heap is enabled. Signed-off-by: lhu <[email protected]>
@amicic @dmitripivkine please review the changes, Thanks |
@@ -129,15 +129,15 @@ JVM_CopySwapMemory(JNIEnv *env, jobject srcObj, jlong srcOffset, jobject dstObj, | |||
/* The java caller has added Unsafe.arrayBaseOffset() to the offset. Remove it | |||
* here as GetPrimitiveArrayCritical returns a pointer to the first element. | |||
*/ | |||
srcOffset -= J9VMTHREAD_CONTIGUOUS_INDEXABLE_HEADER_SIZE((J9VMThread*)env); | |||
srcOffset -= J9VMTHREAD_UNSAFE_INDEXABLE_HEADER_SIZE((J9VMThread*)env); |
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.
not sure what's preferred, but wonder if can you call VM_UnsafeAPI::arrayBase() instead
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.
We cant use the C++ API in C files.
looks ok to me, but I think someone from VM team should approve/merge it |
jenkins test sanity alinux64 jdk21 |
@LinHu2016 does this need to go into 0.49? |
No need, the 2 values will only differ once offheap is enabled. |
The java caller has added Unsafe.arrayBaseOffset() to the offset for JVM_CopySwapMemory JNI API, need to remove it as GetPrimitiveArrayCritical returns a pointer to the first element, need to replace J9VMTHREAD_CONTIGUOUS_INDEXABLE_HEADER_SIZE() with J9VMTHREAD_UNSAFE_INDEXABLE_HEADER_SIZE() for off-heap case, because arrayBaseOffset() == 0 when off-heap is enabled.