RFR JDK-8141491: Unaligned memory access in Bits.c
Andrew Haley
aph at redhat.com
Thu Feb 4 12:22:34 UTC 2016
On 02/02/2016 07:25 PM, Mikael Vidstedt wrote:
> Please review this change which introduces a Copy::conjoint_swap and an
> Unsafe.copySwapMemory method to call it from Java, along with the
> necessary changes to have java.nio.Bits call it instead of the Bits.c code.
>
> http://cr.openjdk.java.net/~mikael/webrevs/8141491/webrev.03/hotspot/webrev/
> http://cr.openjdk.java.net/~mikael/webrevs/8141491/webrev.03/jdk/webrev/
One other little thing: why are the byte-swapping methods in class nio.Bits
not called copySwapSomething? e.g.:
826 /**
827 * Copy and byte swap 16 bit elements from off-heap memory to a heap array
828 *
829 * @param srcAddr
830 * source address
831 * @param dst
832 * destination array, must be a 16-bit primitive array type
833 * @param dstPos
834 * byte offset within the destination array of the first element to write
835 * @param length
836 * number of bytes to copy
837 */
838 static void copyToCharArray(long srcAddr, Object dst, long dstPos, long length) {
839 unsafe.copySwapMemory(null, srcAddr, dst, unsafe.arrayBaseOffset(dst.getClass()) + dstPos, length, 2);
840 }
Andrew.
More information about the hotspot-dev
mailing list