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

checkcast operations should be profiled to improve code which uses generics

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • hs10
    • 7
    • hotspot
    • b08
    • generic
    • generic

        Generic types in the Java language are represented by their bounds in the JVM, and mismatches are made up by dynamic casts. These casts are invisible to the programmer but frequent in the bytecodes. We need better optimization of these casts in order to get top performance from generic Java code.

        We can do much better if we treat casts like call sites, when profiling and optimizing. If we profile receiver types at casts, we will be able to hoist profiled type information up to the place where a new value is pulled from a generic List or Set, which is typically much earlier than a call site that uses the new value. If the profile is monomorphic (which is a typical case, especially in hot code), then all subsequent type checks will fold away, and all calls will be devirtualized. We have benchmarks where this happens in hot code.

              jrose John Rose
              jrose John Rose
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: