RFR JDK-8141491: Unaligned memory access in Bits.c

Andrew Haley aph at redhat.com
Tue Jan 26 18:48:27 UTC 2016

On 01/26/2016 06:32 PM, John Rose wrote:
> On Jan 26, 2016, at 1:04 AM, Andrew Haley <aph at redhat.com> wrote:
>> I agree that memcpy is the right thing to use.  It's portable and is
>> inlined well on production-quality C compilers.
> But it is not strong enough to uphold the Java memory model,
> because it is allows to copy byte-wise, which can tear shorts,
> ints, or longs, creating illegal race states.
> So we try to avoid memcpy when we can.

Yes, I see.  I guess the best we can do is something like the fun and
games in Unsafe.{get, put}LongUnaligned(), which always do the best
they can to align everything.


More information about the hotspot-dev mailing list