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

Speed up InstanceKlass subclass discrimination

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • hotspot
    • None
    • b89
    • generic
    • generic

        There are four kinds of InstanceKlass: concrete InstanceKlass, InstanceRefKlass, InstanceMirrorKlass, and InstanceClassLoaderKlass.

        Klass provides virtual functions oop_is_xxx for determing whether a klass is one of the latter three. This means that multiple virtual function calls are needed to dispatch among these types. In particular, concrete InstanceKlass, which is the most frequently occurring, always requires 3 virtual function calls to select.

        Certain operations might be sped up by having a faster mechanism for dispatching among these classes, and in particular detecting the concrete InstanceKlass case quickly. One way to address these would be to add operation-specific virtual functions. That doesn't scale well as the number of such operations increases, and also introduces tight coupling between the Klass hierarchy and whatever subsystem needs the dispatch.

        A different solution involves associating a unique value with each of those four classes, and providing an accessor for that value.

        This could be expanded to include ObjArrayKlass and TypeArrayKlass, or the existing layout_helper-based discrimination can be used to discriminate among InstanceKlass (or subclass) and the array klasses.

              kbarrett Kim Barrett
              kbarrett Kim Barrett
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: