Unsafe.{get,put}-X-Unaligned; Efficient array comparison intrinsics
John Rose
john.r.rose at oracle.com
Mon Mar 9 05:53:18 UTC 2015
On Mar 8, 2015, at 4:11 PM, David Holmes <david.holmes at oracle.com> wrote:
>
> On 7/03/2015 4:50 AM, 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/
>
> I think it is cleaner and more efficient if Unsafe maintains BE as an instance variable (initialized at construction) and that isBigEndian() simply returns that. The native check should only need to be called once in the lifetime of the VM.
It should be a static final variable, since those have the most robust constant folding optimizations.
— John
More information about the core-libs-dev
mailing list