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

klassVtable and klassItable should be ValueObj

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P3 P3
    • 10
    • 9
    • hotspot
    • b21

      We have a start-up benchmark that shows Klass::vtable() was called 32458 times, and cost about 2~3% of a elapsed time of 720 ms.

      klassVtable* Klass::vtable() const {
        return new klassVtable(const_cast<Klass*>(this), start_of_vtable(), vtable_length() / vtableEntry::size());
      }

      Because the THREAD is not known here, in order to allocate from resource, we need to call Thread::current(), which is expensive.

      klassVtable is a fixed-size object with only 4 fields. It should be changed to a ValueObj and passed around as a plain old struct:

      klassVtable Klass::vtable() const {
        return klassVtable(const_cast<Klass*>(this), start_of_vtable(), vtable_length() / vtableEntry::size());
      }

      A similar optimization can be done to InstanceKlass::itable() to avoid resource allocation there.

            iklam Ioi Lam
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: