Regarding Java code:
Let's suppose you have a static method that accepts a few interfaces. Different object instances always call it with a concrete combination of the interfaces, but C2 ends up with megamorphic code. How would you improve that?
When you have a static method that accepts interfaces and different object instances call it with various combinations of those interfaces, and you observe megamorphic behavior (where the JVM struggles to optimize due to multiple possible types), you can consider a few strategies to improve performance: >