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

Endian in libjimage should avoid virtual functions

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • None
    • tools

      libjimage abstracts away endianness using the Endian class. It does so using virtual and having concrete classes for swapping and native. In C++ calls to virtual functions are not free and typically require a vtable lookup. Since this code is used during startup, it probably should be as fast as feasible.

      Instead an enumeration representing the endianness should be used and functions on Endian should be made static and defined in the header. This will allow the compiler to optimize usages, including inlining, in addition to avoiding virtual calls. The enumeration representing the endianness would be passed around in place of a pointer to Endian, Endian would take the enumeration as the first argument to its methods.

            Unassigned Unassigned
            jcking Justin King
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: