Optimize Integer.reverseBytes()

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P3
    • hs10
    • Affects Version/s: 6
    • Component/s: 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().

              Assignee:
              Yumin Qi
              Reporter:
              Andreas Sterbenz
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: