JDK-6431242 : Optimize Integer.reverseBytes()
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-05-27
  • Updated: 2010-04-03
  • Resolved: 2006-11-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 Other
6u4Fixed 7Fixed hs10Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
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
SUGGESTED FIX http://javaweb.sfbay/~yq123930/webrev/6431242
16-10-2006

EVALUATION This is a candidate for intrinsification.
30-05-2006