RFR JDK-8141491: Unaligned memory access in Bits.c
mikael.vidstedt at oracle.com
Wed Feb 3 16:13:38 UTC 2016
On 2016-02-03 01:43, Andrew Haley wrote:
> On 02/02/16 19:25, 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.
> There doesn't seem to be any way to use a byte-swap instruction
> in the swapping code. This will make it unnecessarily slow.
To be clear, this isn't trying to provide the absolutely most optimal
copy+swap implementation. It's trying to fix the Bits.c unaligned bug
and pave the way for further improvements. Further performance
improvements here are certainly possible, but at this point I'm happy as
long as the performance is on par (or better) with the Bits.c
implementation it's replacing.
That said, at least gcc seems to recognize the byte swapping pattern and
does emit a bswap on linux-x64. I'm not sure about the other platforms
More information about the core-libs-dev