Unsafe.{get,put}-X-Unaligned; Efficient array comparison intrinsics

Peter Levart peter.levart at gmail.com
Sat Mar 7 21:23:06 UTC 2015

On 03/06/2015 07:50 PM, Andrew Haley wrote:
> I've tried to so everything I've been asked.  If this version passes
> muster with everyone I'll Javadoc all the public methods and fields
> and put it up for RFA next week.
> I guess it's going to need a lot of testing and security analysis.
> I added versions of all {put,get} methods with the boolean bigEndian
> argument.  This makes HeapByteBuffer much cleaner, and it does not
> need to know the machine endianness at all.  I hope that's OK.
> Andrew.
> http://cr.openjdk.java.net/~aph/unaligned.hotspot.4/
> http://cr.openjdk.java.net/~aph/unaligned.jdk.4/

Hi Andrew,

I see you're not using Unsafe.unalignedAccess() method in Unsafe code at 
all. So the approach to use this information and decide whether to use 
Unsafe.getXXX() or Unsafe.getXXXUnaligned() is left to the user of 
Unsafe API. That's OK if you think this approach is a better division of 
concerns (Unsafe being low-level), but in Heap-X-Buffer you are only 
using Unsafe.get|putXXXUnaligned() and don't consider using get|putXXX 
directly when unalignedAccess() == true.

In java.nio.Bits, the Unsafe.unalignedAccess() is used to lazily 
initialize the Bits.unaligned static field. This lazy initialization is 
unnecessary now and 'unaligned' field can be made final.

Regards, Peter

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20150307/17a485ef/attachment.html>

More information about the hotspot-compiler-dev mailing list