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.