Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6431242

Optimize Integer.reverseBytes()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • hs10
    • 6
    • hotspot
    • None
    • b03
    • generic
    • generic

        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().

              minqi Yumin Qi
              andreas Andreas Sterbenz
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: