Earlier quoted context omitted.
The JVM has been capable of this for a while. I think the overhead of profiling and applying optimizations has always been greater than any efficiency gains.
'the overhead of profiling and applying optimizations has always been greater than any efficiency gains.' Not necessarily, especially if you explicitly rely on them. For example in C++ you deliberately have to avoid overusing virtual functions if you don't want the overhead. In Java, virtual functions are the default, and you usually don't care: if you call them a lot (e.g. in a tight loop) JVM will adaptively give y…
So if G++ is able to tell the code paths leading to the virtual call, it does the same optimization as the JVM.