Optimizing byte reverse code for int value
    Andrew Haley 
    aph at redhat.com
       
    Fri Apr  7 17:58:45 UTC 2017
    
    
  
On 07/04/17 18:51, Hiroshi H Horii wrote:
>> I suggest replacing the use of loadI by endianness specific code
>> (which could possibly use lwbrx on big endian).
> 
> I believe that lwbrx is necessary for BE.
> 
>> Surely the source code needs fixing.  It could be:
>>
>> public float readFloat(InputStream in) throws IOException {
>>   readFully(in, aByteBuffer, 0, 4);
>>   int val = aByteBuffer.getInt(0);
>>
>>   return Float.intBitsToFloat(val);
>> }
> 
> In my understanding, ByteBuffer.getInt() does the similar thing.
It doesn't.
> I guess that application does not use ByteBuffer only for calling getInt().
> 
> Heap-X-Buffer.java.template
>     public int getInt() {
>         return Bits.getInt(this, ix(nextGetIndex(4)), bigEndian);
>     }
This is old code.  In JDK9 it looks like
    public int getInt() {
        return unsafe.getIntUnaligned(hb, byteOffset(nextGetIndex(4)), bigEndian);
    }
Unsafe.getIntUnaligned is a HotSpot intrinsic.
Bits.java is not used for this.
Andrew.
    
    
More information about the hotspot-dev
mailing list