United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6431242 Optimize Integer.reverseBytes()
JDK-6431242 : Optimize Integer.reverseBytes()

Details
Type:
Enhancement
Submit Date:
2006-05-27
Status:
Resolved
Updated Date:
2010-04-03
Project Name:
JDK
Resolved Date:
2006-11-14
Component:
hotspot
OS:
generic
Sub-Component:
compiler
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
hs10 (b03)

Related Reports
Backport:
Backport:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
Integer.reverseBytes() implements endianness conversion as:

    public static int reverseBytes(int i) {
        return ((i >>> 24)           ) |
               ((i >>   8) &   0xFF00) |
               ((i <<   8) & 0xFF0000) |
               ((i << 24));
    }

Some architectures include instructions that do just that: BSWAP on x86 and LDUWA on SPARC, but HotSpot currently does not take advantage of them.

Similarly for Long.reverseBytes().

                                    

Comments
EVALUATION

This is a candidate for intrinsification.
                                     
2006-05-30
SUGGESTED FIX

http://javaweb.sfbay/~yq123930/webrev/6431242
                                     
2006-10-16



Hardware and Software, Engineered to Work Together